Extract animated vertices from DAE / COLLADA using SceneKit

Using SceneKit on Mac OS X to load the COLLADA (DAE) file, you can easily get all the geometry by going through the SCNNode: s tree and their corresponding SCNGeometry: s, and extract the vertex data using [ForSemantic: SCNGeometrySourceSemanticVertex geometry geometry].

However, given the DAE file containing the animated object, is it SceneKit able to give 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 rendering pipeline for everything else.

Clarification There are obviously two methods for how this could be done:

1) Get and analyze key frames from related animation

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

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

My problem is that for # 1 I am unable to complete the following steps:

SCNNode.animationKeys provides the animation keys available for this SCNNode, [SCNNode animationForKey: key] for CAAnimationGroup objects, from which CAAnimation objects are obtained through CAAnimationGroup.animations. CAAnimation objects are (for my DAE files) real instances of CAKeyframeAnimation, from which I get CAKeyframeAnimation.values:

Keyframe:

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

+4
source share
2 answers

I understand that you need to get nodes (position of objects) + geometry (vertices, normals ...) + animation information from SceneKit. Then convert this data to a representation of your engine, and then play the animation and convert the vertex in your engine.

SceneKit will provide you with geometry and hierarchy information using the SCNNode / SCNGeometry APIs. You can get animation with SCNNode SCNAnimatable protocol (animationKeys / animationForKey :)

And you can get individual keyframes of animations using the CoreAnimation CAKeyframeAnimation / CAAnimationGroup APIs.

+1
source

It looks like SCNNode has a presentationNode that can provide you with node information during the animation.

0
source

Source: https://habr.com/ru/post/1494967/


All Articles