简体   繁体   English

如何在iOS场景工具箱中添加自定义动画

[英]How to add custom animations in ios scene kit swift

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? 我正在使用场景套件制作游戏,并且其中一部分掷出一些骰子以生成数字,我已经在3DS max 2016中制作了骰子。我可以轻松地在3DS max上制作动画,但是如何将其加载到场景中? 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, eg animation1, animation2. 我打算做的是使xcode生成一个数字,并用该数字从不同的文件(例如animation1,animation2)中选择一个文件。 Say the number generated was 2 it would run animation2. 假设生成的数字为2,它将运行animation2。

Thanks 谢谢

You can export animations from 3DS Max with OpenCOLLADA plugin . 您可以使用OpenCOLLADA插件从3DS Max导出动画。 Then you can get animations with SCNSceneSource , like: 然后,您可以使用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

Extract animations to array, and attach random one to your node with SCNNode's addAnimation(forKey:) 将动画提取到数组中,然后使用SCNNode的addAnimation(forKey :)将一个随机数附加到您的节点上

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM