Export animation from .dae

Hello guys,

In WWDC 2015 - Session 606 - Enhancements to SceneKit there was an Fox example project which is available to download.

Can anyone say what is the correct collada file setttings when exporting model with skeletal animation from 3D tool into .dae file? For example in the demo project there is a "walk.scn".

I used 3D tool (Cheetah3D) to make a simple model with simple skeletal animation and export it in .dae, but I can't get my model to be animated on the scene.


If I use non skeletal animation in 3D tool and export it in .dae then model animation on the scene works perfect.


Maybe someone succeed with exporting model with skeletal animation using another 3D tool like Blender?

Add a Comment

Accepted Reply

dropbox.com/s/ly8sof6y5px8wwo/Logan.zip?dl=0


It's not a simple cube it's a fully rigged human with the animation converted for xcode compatibility. It's in dae format so you can open it in cheetah, but it should work fine in xcode as is.

If you still need it to be a simple cube I'll try to get on that later today but this model was already built, rigged and animated from a project I have on the back burnder at the moment. The model was built in Makehuman, imported to Blender, animated in blender (using the cmu .bvh motion capture files and edited to fixate the model location and keep it's feet above the floor), then the animation was run through ConvertToXcodeCollada and placed in an scnassets folder in the project. The project this is part of is written in swift (which I hate) so if you're not familiar with swift any code I could provide may not be terribly helpful. The code I listed above assums the models are converted to scn. files. In the scenekit scene editor go to editor->convert to to scenekit scene file format(scn)

Add a Comment

Replies

In lieu of finding some service to convert the DAE files animations from Maya ("ConvertToXcodeCollada" stopped working for me), what I ended up doing was writing code to traverse the Maya-generated-DAE file's rootnode tree and gather up the individual node's CAKeyframeAnimations (which were inside CAAnimationGroups). Then I created a single CAKeyframeAnimation and loaded its 'animations' array with the individual CAKeyframeAnimations:


myCAAnimationGroup.animations = [ CAKeyframeAnimation1, CAKeyframeAnimation2, ..., CAKeyframeAnimationN]

myCAAnimationGroup.duration = CAKeyframeAnimation1.duration


if you do a recursive top-down traversal of the nodes stored in the DAE, then the first node you encounter with an animation, call it 'mySCNNode', can be used:


mySCNNode.addAnimation(myCAAnimationGroup, forKey: "myAnimationName")


I wrote the code in Swift (~25 lines) and even though it had to recurse through the node tree, it seemed to take negligable time. As a bonus, you will gain a lot of control by pulling out the animations explicitly. (i.e., you could break the animations into parts and animate the characters arms independently from the legs, you could store multiple animations in the same DAE file etc.).


I spent a week trying to find a prebuilt solution when I should have spent a couple of hours exploring the DAEs generated from my 3D program.


Note: you pull the NAME of the node you want to animate from the DAE file containing the animation, then if you have a mesh with the same node set up you can use the node name to identify the correct node to apply the animation to.

I still can't get animations to work when exporting .dae with Maya. But animation created in Cheetah3D is workint with a bug – animated object always change it's position to the center (0,0,0).



I did simple experiment – took "panda.scn" and "walk.scn" from Fox sample project provided by apple and just put "panda" on the scene and apply walk animation and it worked with no problem 🙂 Then I tried to do the same but using my model.dae and animation.dae (created in Cheetah3D) and the result – animation works but after applying animation model changes it's position to (0,0,0). So animation working but model resets it's position 😟 It seems that model changes position to the position of bones in skeleton in animation.dae.

Nils, would you be able to put your model.dae, animation.dae, and original Cheetah3D and Maya models someplace accessible? Or maybe make a couple of extremely simple sample Cheetah3D and/or Maya models with animation? I'd like to take a look, and I don't have the modeling chops to build an animated model. You can put it on Github, or Dropbox, or email me halmueller at gmail.


The handling of external model files was a frustrating area for students in a course I just finished teaching, and itef is a recurring question mark in all forums I've seen. Maybe if we put our heads together we can figure out a streamlined process.

Sure dropbox.com/s/p4kw3874p70v9zs/ModelsAnimations.zip?dl=0

I don't know if this will help but:


First off I use blender. I create my model, rig it. I then export the model (sans camera and lights etc) normally and convert it to scn in XCode.


Then create an animation and I export JUST the animted skeleton (though the whole model is fine too.) But you don't want to export the rest of the scene (lights/camera etc) . Just the model and it's animated rig or just the animated rig.


I then load the animation:

/
- (CAAnimation *)loadAnimationFromSceneNamed:(NSString *)path
{
    SCNScene *scene = [SCNScene sceneNamed:path];
/
  /
    __block CAAnimation *animation = nil;

    /
    [scene.rootNode enumerateChildNodesUsingBlock:^(SCNNode *child, BOOL *stop) {
        if (child.animationKeys.count > 0) {
            animation = [child animationForKey:child.animationKeys[0]];
            *stop = YES;
        }
    }];

    return animation;
}


then I call that :

NSString * scenePath = @"Path to my scene"; //(something like art.scnassets/walk.dae or art.scnassets/walk.scn)
CAAnimation * thisAnimation = [self loadAnimationFromScene:scenePath];


Finally I animate the model:

[myCorrispondingModel addAnimation:thisAnimation forKey:@"thisAnimationKey"];


There are timing functions, and setting the number of time it will repeat, like forever or 1 time etc. But by and large this should get you started.


The main thing I'm wondering and please don't take offense for me asking such an amature question, but when you export your model you include the rig right?. Because the animations map to the skeleton in the model. or something like that.

There's one more thing, Some 3d apps export animations and it's not 100% xcode compatible. There is a service script you can download I think it's called ConvertToXcodeCollada. I use it to clean up blender animations but I don't know about cheetah.

Can you please give me a very simpe example of cube.dae (simple cube) and cubeAnimation.dae (just rotation animation) made in blender, so I can try to make animations?

dropbox.com/s/ly8sof6y5px8wwo/Logan.zip?dl=0


It's not a simple cube it's a fully rigged human with the animation converted for xcode compatibility. It's in dae format so you can open it in cheetah, but it should work fine in xcode as is.

If you still need it to be a simple cube I'll try to get on that later today but this model was already built, rigged and animated from a project I have on the back burnder at the moment. The model was built in Makehuman, imported to Blender, animated in blender (using the cmu .bvh motion capture files and edited to fixate the model location and keep it's feet above the floor), then the animation was run through ConvertToXcodeCollada and placed in an scnassets folder in the project. The project this is part of is written in swift (which I hate) so if you're not familiar with swift any code I could provide may not be terribly helpful. The code I listed above assums the models are converted to scn. files. In the scenekit scene editor go to editor->convert to to scenekit scene file format(scn)

Add a Comment

Wow!!! Finaly, your animation works as expected 🙂 but it only works if I use .dae-files without converting them to .scn-format (Xcode Collada).

Now the most wanted information 🙂 can you please share the secret about "animation converted for xcode compatibility" – what that means? Is there some extra settings in blender when exporting to .dae?


"when you export your model you include the rig right" – for now I don't know about rig but I'll see how to work with rigid bodies, maybe that was my problem.

Finally!!! It worked for my model 🙂 thank you FNSApril for pointing on including rig 🙂

The utility is called ConvertToXcodeCollada : drive.google.com/file/d/0B1_uvI21ZYGUaGdJckdwaTRZUEk/edit?usp=sharing

download it and install it in ~/Library/Services

It will show up as a service when you right click the dae animation file.

you right click the animation in find and go to services and choose ConvertToXcodeCollada and it will convert it to a manageable xcode compatible animation with an identifier which you need when you are using it on mac (but not on iphone and I assumd you were using it on iphone) I'll have to dig the project up and go back through it to remember how to make animations work when they are converted to scn files on mac. that's a little more difficult as you have to use the animation identifier...


A little direction from a mac expert here would be great since I still have trouble getting animations to work on mac too.

hi Nils i have same problem i can't see my animation in fox sample provided by apple.when i change panda.scn and walk.scn animation with my animation made in blender then it run without error but not show my object....

please tell how you solve problem

TOTAL explanation for 2023 ... https://stackoverflow.com/a/75093081/294884

  • Thank you! That post explains the workflow perfectly!

Add a Comment