Scenekit:动画时模型更改大小

时间:2019-02-22 16:00:30

标签: ios swift animation scenekit blender

我使用Scenekit为模型(由Blender创建)制作动画,但是模型在动画时会更改大小(在Blender中,它可以正常工作)。 https://youtu.be/WCE_sXEyfXU

    let sceneView = SCNView(frame: self.view.frame)
    sceneView.allowsCameraControl = true
    self.view.addSubview(sceneView)

    let manScene = SCNScene(named: "art.scnassets/man.dae", inDirectory: nil, options: nil)
    sceneView.scene = manScene

    let camera = SCNCamera()
    let cameraNode = SCNNode()
    cameraNode.camera = camera
    cameraNode.position = SCNVector3(-3.0, 3.0, 3.0)

    let light = SCNLight()
    light.type = SCNLight.LightType.ambient
    let lightNode = SCNNode()
    lightNode.light = light
    lightNode.position = SCNVector3(10, 10, 10)

    manScene!.rootNode.addChildNode(cameraNode)

    let oneLegAnimation = SCNAnimationPlayer.loadAnimation(fromSceneNamed: "art.scnassets/oneLeg.dae")
    oneLegAnimation.animation.isCumulative = false
    oneLegAnimation.stop()
    manScene!.rootNode.addAnimationPlayer(oneLegAnimation, forKey: "man")
    manScene!.rootNode.animationPlayer(forKey: "man")?.play()

谢谢!

1 个答案:

答案 0 :(得分:0)

我认为Blender和Xcode之间有区别。最后,我通过添加IK骨骼和很多关键帧(每0.5秒)来修复它。