0

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.

iOScoder
  • 181
  • 1
  • 12
  • Did you mean to rotate the nodes or change their pivot? – David Rönnqvist Nov 15 '14 at 11:06
  • Also, why don't you get the bone nodes from the SCNSkinner's skeleton hierarchy? – David Rönnqvist Nov 15 '14 at 11:07
  • I do have pelvis, spine and neck represented as joints in my exported collada file from Cheetah3d. I would like to rotate and bend the pelvis/hips 45 degrees, then my spine 45 degrees. I just looked into SCNSkinner and perhaps that may be the way to approach this problem. Let me look into this some more and let me look into it deeper. If you have any additional suggestions that would be great. – iOScoder Nov 16 '14 at 06:15
  • @David Ronnqvist - As I was searching for examples for SCNSkinner, it look like it was appropriate but the search returned back less than 3 pages. I was hoping there would be examples. Can I just load in the model like above and perform transformation on the bones or do you think I need to create a SCNSkinner object (not sure the SCNGeometry and boneInverseBindTransforms parameters I would need to provide). Thank you so much. – iOScoder Nov 18 '14 at 08:56
  • I would expect the exported character in the dae-file to already have a SCNSkinner. If not, I would try and re-export the character. Creating a skinner object in code is fairly complicated. I would only recommend doing it if you are importing another file format isn't supported by SceneKit by default. – David Rönnqvist Nov 18 '14 at 09:43
  • Thanks. I realized I didn't answer the first question which is I am looking to rotate the SCNNode (marked as joint in .dae file) I do have a SCNScene created which I can see in Xcode with a low-resoution polygon mesh as the skin exported from Cheetah 3D. It renders correctly though. Do you think the code approach is correct above? Perhaps I need to attach the SCNNodes from the SCNSceneSource in the code above to the SCNScene itself? I'm quite new to 3D modeling and thank you for your help. – iOScoder Nov 18 '14 at 13:27

1 Answers1

0

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!

Community
  • 1
  • 1
iOScoder
  • 181
  • 1
  • 12