I've imported a DAE file in XCode and converted it into a SCN file. This file contains some 3D objects with animations.
I'm trying to import all the nodes with their animations and play them on the scene. The nodes are imported but I can't get the animations playing.
NSURL *idleURL = [[NSBundle mainBundle] URLForResource:model.model3D
withExtension:@"scn" subdirectory:@"3d.scnassets"];
SCNScene *idleScene = [SCNScene sceneWithURL:idleURL
options:@{
SCNSceneSourceAnimationImportPolicyKey:SCNSceneSourceAnimationImportPolicyPlayRepeatedly}
error:nil];
// Merge the loaded scene into our main scene in order to
// place the object in our own scene
for (SCNNode *child in idleScene.rootNode.childNodes){
[_sceneView.scene.rootNode addChildNode:child];
if (child.animationKeys.count > 0) {
CAAnimation *animation = [child animationForKey:child.animationKeys[0]];
animation.repeatCount = INFINITY;
child.paused = NO;
[_sceneView.scene.rootNode addAnimation:animation forKey:child.animationKeys[0]];
}
}
[_sceneView setPlaying:YES];
This is a file that will convert mulitple key animations into one for DAE file
Automater collada converter download
Unzip and drop the file in your ~/Library/services folder. From there you can just right click on your collada file and scroll down to ConvertToXcodeCollada and presto! A window will pop up when complete (about half a second).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With