Loading Collada dae file into SceneKit for joint manipulation

1.4k views Asked by At

I am loading a rigged collada file into SceneKit and trying to rotate the pelvis forward 45 degrees and spine. The pelvis and spine nodes do load, however, the rotation does not appear to work. The 2 SCNNode classes that are extracted are "joint" nodes in the dad file.

NSURL *url = [[NSBundle mainBundle] URLForResource:@"rigged-character" withExtension:@"dae"];
SCNSceneSource *source = [SCNSceneSource sceneSourceWithURL:url options:nil];
pelvis = [source entryWithIdentifier:@"ID179469248" withClass:[SCNNode class]];
spine = [source entryWithIdentifier:@"ID179691712" withClass:[SCNNode class]];

[pelvis setPivot:SCNMatrix4MakeRotation(MCP_DEGREES_TO_RADIANS(45), 0, 1, 0)];
[spine setPivot:SCNMatrix4MakeRotation(MCP_DEGREES_TO_RADIANS(45), 0, 1, 0)];

Does anyone know why and do I need to add: [myView.scene.rootNode addChildNode:pelvis]; [pelvis addChildNode:spine];

Thank you for your assistance.

1

There are 1 answers

0
iOScoder On BEST ANSWER

In order to create the skeleton, I to build the skeleton as follows:

  1. Create an SCNView loading in the collada file
  2. Retrieve each of the SCNNode from the SCNView.scene.rootNode
  3. Add the child nodes to the SCNView's root node using addChildNode

Hope this helps!