SCNAnimationPlayer()似乎在使用SceneKit时仅播放动画的一小部分 [英] SCNAnimationPlayer() Seems to be playing only small part of animation while using SceneKit

查看:236
本文介绍了SCNAnimationPlayer()似乎在使用SceneKit时仅播放动画的一小部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Blender中制作了一个动画,并将其移动到Xcode,然后Xcode将其从.dae文件
转换为.scn。

I made an animation in Blender and moved it to Xcode and it is converted from .dae file to .scn by Xcode.

我可以玩在混合器中设计的Xcode场景图中的动画。

I can play the animation in scene graph of Xcode as it is designed in the Blender.

我正在加载几何图形和动画并为动画对象创建节点。

I am loading geometry and animation and create node for animated object.

我使用SCNAnimationPlayer()加载动画。代码如下。

I use SCNAnimationPlayer() to load animation. The code is below.

let scene = SCNScene(named: "scene.scn")!
let geometry = scene.rootNode.childNode(withName: "animatedGeo",
                                              recursively:true).geometry!

let animationNode = SCNNode(geometry: geometry)


let armature = scene.rootNode.childNode(withName: "Armature", recursively: true)!
let animationPlayer = armature.animationPlayer(forKey: "action_container-Armature")!
animationNode.addAnimationPlayer(animationPlayer, forKey: "action_container-Armature")

rootNode.addChildNode(animationNode)

我没有以编程方式为animationPlayer设置任何内容,因为所有设置在Xcode的场景图窗口中看起来都为

I did not set anything for animationPlayer programmatically because all the settings looks Ok in scene graph window of Xcode.

但是,当场景加载时,我在iPhone屏幕上的动画对象上看到一个小的移动。
看起来只有第一个(父)骨骼动画正在播放。
我找不到为什么所有动画都无法在场景图中播放的原因。

However when scene loaded I see a small movement on animated object on iPhone screen. Looks like only first (parent) bone animation is partly playing. I could not find the why all of animation was not playing as it is played in scene graph.

推荐答案

是,当我尝试以编程方式操纵我在Blender中设计和制作的对象而不是我在Blender中制作的动画时,我发现了如何做。

Yes, I found how to do it when I was trying to manipulate my object designed and animated in Blender programmatically instead of animation I made in Blender.

您要做的是将 Armature节点添加到场景节点。
这就是全部。您不必使用SCNAnimationPlayer()。

What you have to do is to add "Armature" node to your scene node. This is all. You don't have to use SCNAnimationPlayer().

let scene = SCNScene(named: "scene.scn")!

let myObjectArmaturNode = scene.rootNode.childNode(withName: "Armature", recursively: true)!

rootNode.addChildNode(myObjectArmaturNode)

就是这样。
动画的运行就像在Blender中设计的一样。
动画由4条骨头组成。

This is it. The animation runs like it is designed in Blender. The animation consists of 4 bones by the way.

这篇关于SCNAnimationPlayer()似乎在使用SceneKit时仅播放动画的一小部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆