如何在ios场景工具包swift中添加自定义动画(How to add custom animations in ios scene kit swift)

编程入门 行业动态 更新时间:2024-10-28 16:21:27
如何在ios场景工具包swift中添加自定义动画(How to add custom animations in ios scene kit swift)

我正在制作一个带有场景套件的游戏,其中一部分掷骰子生成一个数字,我已经在3DS max 2016中制作了骰子。我可以在3DS max上轻松制作动画,但我如何将它加载到我的场景中? 我已经加载了没有动画的骰子,但我不确定如何加载骰子动画以使其滚动。

我打算做的是让xcode生成一个数字,并使用该数字从不同的文件中选择一个文件,例如animation1,animation2。 假设生成的数字是2它将运行animation2。

谢谢

I am making a game with scene kit and part of it rolls some dice to generate a number, i have made the dice in 3DS max 2016. I can make the animations easily on 3DS max, but how would i load it into my scene? I have loaded in a dice with no animations, but I am not sure how I can load the dice animations so that it rolls.

What I intend to do is make xcode generate a number, and with that number is chooses a file out of different files, e.g. animation1, animation2. Say the number generated was 2 it would run animation2.

Thanks

最满意答案

您可以使用OpenCOLLADA插件从3DS Max导出动画。 然后你可以使用SCNSceneSource获取动画,例如:

let src = SCNSceneSource(URL: yourSceneURL, options: nil)
let node = src.entryWithIdentifier("yourNodeID", withClass: SCNNode.self) as SCNNode
let animation = node.entryWithIdentifier("yourAnimationID", withClass: CAAnimation.self) as CAAnimation
 

将动画提取到数组,并使用SCNNode的addAnimation(forKey :)将随机附加到您的节点

You can export animations from 3DS Max with OpenCOLLADA plugin. Then you can get animations with SCNSceneSource, like:

let src = SCNSceneSource(URL: yourSceneURL, options: nil)
let node = src.entryWithIdentifier("yourNodeID", withClass: SCNNode.self) as SCNNode
let animation = node.entryWithIdentifier("yourAnimationID", withClass: CAAnimation.self) as CAAnimation
 

Extract animations to array, and attach random one to your node with SCNNode's addAnimation(forKey:)

更多推荐

本文发布于:2023-08-07 07:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463189.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工具包   自定义   场景   动画   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!