4

I'm trying to animate my model on a SceneKit scene:

  1. create a simple cube model and export it to cube.dae
  2. create a simple skeleton for cube and make a simple rotation animation using bones and export it to animation.dae
  3. using Apple sample Fox demo (WWDC 2015), I tried to put model on scene and it works
  4. animate box rotation – it is working but after applying animation, the cube changes its position to (0,0,0)

Maybe someone has succeeded with skeletal animation and SceneKit using another 3d tool (Maya, Blender, 3D Max)?

to convert .dae to .scn I select DAE file and then in Xcode "editor" --> "convert to scenekit scene format"

link to archive with models and animations.

code: init model node

let characterScene = SCNScene(named: "game.scnassets/cube.scn")!
let characterTopLevelNode = characterScene.rootNode.childNodes[0]
characterNode.addChildNode(characterTopLevelNode)
let idleAnimation = CAAnimation.animationWithSceneNamed("game.scnassets/cubeWithMeshSkeletonAnimation.scn")!
idleAnimation.usesSceneTimeBase = false
idleAnimation.repeatCount = Float.infinity
characterNode.addAnimation(idleAnimation, forKey: "idle")

add model on scene

let scene = SCNScene(named: "game.scnassets/Level1.scn")!
gameView.scene = scene
gameView.playing = true
gameView.loops = true
scene.rootNode.addChildNode(unrealCharacter.characterNode)
let startPosition = scene.rootNode.childNodeWithName("startingPoint", recursively: true)!
unrealCharacter.characterNode.transform = startPosition.transform
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Manifestor
  • 575
  • 5
  • 19
  • Can you put your Cheetah3D file and exported results somewhere we can see them, and post the code you're using to load/play? – Hal Mueller Dec 21 '15 at 06:41
  • Sure, I edit my post and add link to archive with models and animations and put some code – Manifestor Dec 21 '15 at 15:22
  • I'm not sure to understand your issue. Can you please elaborate on what you want to do (expected behaviour) and what's going wrong? Also what is `unrealCharacter` and how is it related to the cube? – mnuages Dec 22 '15 at 10:07
  • 1
    Ok, I'll try to explain. What I want and expect is animation from .dae work as it expected to. I want a simple thing – animate model using .dae file just like in apple sample code. unrealCharacter.characterNode is an SCNNode. Archive contains models (cube and Mannequin) and there animations to test. The only unexpected thing is that after applying animation to SCNNode it changes it's position. – Manifestor Dec 22 '15 at 16:01
  • Would you take a look at my question, I am trying to emulate what you have done here https://stackoverflow.com/questions/46209555/scenekit-how-to-get-animations-for-a-dae-model – blue Sep 24 '17 at 18:39
  • for 2023 .. https://stackoverflow.com/a/75093081/294884 – Fattie Jan 18 '23 at 17:09

1 Answers1

2

It was my mistake, I need to save rig in initial model. Previously I saved rig only for animation. Now animation works fine.

Manifestor
  • 575
  • 5
  • 19