4
votes

Using SceneKit on Mac OS X to load a COLLADA (DAE) file you can easily obtain all geometry by traversing the tree of SCNNode:s and their respective SCNGeometry:s, and extract the vertex data using [geometry geometrySourcesForSemantic: SCNGeometrySourceSemanticVertex].

However, given a DAE file containing an animated object - is SceneKit capable of giving me the exact location of each vertex at a given time in the animation, or can I extract all the animation data from the associated CAAnimation objects?

My use case is that I would like to use SceneKit to import DAE files, but use my own render pipeline for everything else.

Clarification There are obviously two methods how this could be accomplished:

1) Obtain and parse the key frames from the associated animation

2) Let SceneKit evaluate the scene for a given time, and give me pre-calculated vertex (etc) coordinates

What I was aiming for in my use case was #2, but if I can find documentation of the key frame format used by SceneKit #1 is also acceptable.

My problem is that for #1 I don't manage to dig any further than the following:

SCNNode.animationKeys gives animation keys available for a given SCNNode, [SCNNode animationForKey:key] given CAAnimationGroup objects from which CAAnimation objects are obtained through CAAnimationGroup.animations. The CAAnimation objects are (for my DAE files) in reality instances of CAKeyframeAnimation, from which I get CAKeyframeAnimation.values:

Keyframe (1 / 40): <00000000 0000f0bf 00000080 d9956d3c 000000a0 0e32a13c 00000000 00000000 00000020 636772bc 00000020 2914ef3f 00000000 0f7ecebf 00000000 00000000 00000020 1324a1bc 00000000 0f7ecebf 00000020 2914efbf 00000000 00000000 00000000 00000000 000000c0 205c6d40 00000000 00a069c0 00000000 0000f03f>

etc.. So to solve the #1 approach above I would need to find the format used for these key frames.

2
The scene view as a scene renderer have a property for the currentTime. If you change it, does that update the geometry for you?David Rönnqvist
Since I'm not using SceneKit to do any rendering, just importing the geometry to my own renderer, I don't have any SceneView or SceneRenderer from SceneKit active in which I could modify the currentTime property, or do I misunderstand what you suggest?simonfi
You understood my question correctly.David Rönnqvist
Just curious: had you built your rendering pipeline before or was there something you couldn't do in SceneKit (even as the render delegate of the nodes)?David Rönnqvist
The reason is that the rendering pipeline is cross-platform, while the editor/tool part of what I'm building is OSX-only and I could save a bunch of time by letting SceneKit do imports of COLLADA files for me :)simonfi

2 Answers

1
votes

My understanding is that you need to retrieve the nodes (object positions) + geometry (vertex, normals...) + animation informations from SceneKit - Then convert these info into your engine's representation and then play the animations and transform the vertex in your engine.

SceneKit will give you the geometry and hierarchy information With the SCNNode / SCNGeometry APIs. You can retrieve the animations with SCNNode's SCNAnimatable protocol (animationKeys / animationForKey:)

And you can retrieve the individual keyframes of the animations with CoreAnimation's CAKeyframeAnimation/CAAnimationGroup APIs.

0
votes

Looks like SCNNode has presentationNode which can give you information of nodes during animations.