Animated .X file refuses to move

Topics: User Forum
Apr 10, 2007 at 2:37 PM
Edited Apr 10, 2007 at 2:37 PM
I modified the DwarfModel demo to load in my own .X files, and while some work, others won't and I was wondering why that is.

I have uploaded 2 .X files (and corresponding .XMLs) at http://www.shrdlusblocks.com/files/SnakeNGuy.zip

In the zip are two folders: snake and guy, the snake works with ACL but the guy doesn't...

Both were exported with blender, if you want .blend files, I can provide them.

Both load properly into the project, and both are processed without errors, it is simply that when the project is run, guy refuses to move while snake does his coiling and uncoiling and finally his spasm thing.

If this was addressed in a previous discussion you can point me that way, I may just be really bad at searching...
Coordinator
Apr 10, 2007 at 3:22 PM
Hi. First of all, you don't need those xml files since you only have one anim per model. The xml is meant to split a single animation into multiple.

Your problem is that the keyframes in the guy.x file are all identical. For example, here is a snippet:

Animation {
{ LegL }
AnimationKey {
4;
20;
1;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
2;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
3;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
4;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
5;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
6;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
7;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
8;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
9;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
10;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
11;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
12;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
13;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
14;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
15;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
16;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
17;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
18;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
19;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;,
20;16;-1.000000,-0.007200,0.000000,0.000000,0.007200,-1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.455700,-1.273700,0.000000,1.000000;;;
}
}


Apr 10, 2007 at 10:51 PM
Edited Apr 10, 2007 at 11:02 PM

dastle wrote:
Hi. First of all, you don't need those xml files since you only have one anim per model. The xml is meant to split a single animation into multiple.

Your problem is that the keyframes in the guy.x file are all identical.


Thanks for the reply, check the ArmR Bone, however, it has varying keyframes, the rest are identical though, yes.


Also, the only changes I made to the DwarfModel Demo would be:
Model model = content.Load<Model>("guy"); // guy rather than dwarfmodel
// and futher on...
idle = new AnimationController(this,
                    dwarfAnimator.Animations[0]); // 0 rather than "idle" or something
Finally, I am using the XNA Importer with the ACL Processer, NOT the ACL Importer but that hasn't made much of a difference so far. (in other words, importer hasn't mattered, snake moves with either, dude is solid with either)
Coordinator
Apr 11, 2007 at 1:38 AM
Indeed. You are correct. The problem is that your guy.x file has about 25 frames, and no AnimTicksPerSecond node. The default ticks per second is around 1000, so the animation runs too fast.

Remedy:

1. Delete your guyanimation.xml file.
2. Add
AnimTicksPerSecond {
5;
}

To guy.x right before the first Frame node (well, you can it put it most places)
Apr 11, 2007 at 3:10 AM
Edited Apr 11, 2007 at 3:11 AM

dastle wrote:
Indeed. You are correct. The problem is that your guy.x file has about 25 frames, and no AnimTicksPerSecond node. The default ticks per second is around 1000, so the animation runs too fast.


Wow, that explains a lot, thanks. (This information was probably posted somewhere more obvious no doubt, and I just somehow over-looked it)

I tend to remember seeing something similar with my Snake file when I made it 2 weeks ago, but I could not for the life of me remember what it was, and thus have been throwing bricks at blender... I suppose it's time for a new monitor now ;)

I should compile a list of all the stupid mistakes I made modeling things in blender and exporting so that others can learn from all of them... off the top of my head they are having more than one root bone (parent-less bone if you will), leaving vertex groups empty, forgetting to bake my animation, and this: forgetting to export an animation speed out of haste/eagerness to get it going.
Apr 11, 2007 at 6:49 PM
MafaDG:
When exporting from Blender you must ensure to select the speed button (else you get no animtickpersecond node).

Jun 26, 2007 at 1:45 AM
I have a similar problem. I've exported an animation file from Blender using the ACL exporter. Even though I only have one animation I do use the animation.xml file and set "idle0" to the total number of frames in the animation 0-50. I have ensure there are AnimTicksPerSecond in both the X and XML file. And finally, I have ensured that the keyframes are not identical. Yet my model is not animating. This is what my animation.xml looks like:
<animation>
<name>AnimationSet0</name>
<tickspersecond>25.0</tickspersecond>
<animationsubset>
<name>idle0</name>
<startframe>0</startframe>
<endframe>50</endframe>
</animationsubset>
</animation>
and this is an excerpt of my keyframes in the X file:


Animation {
{ BoneTLeg2 }
AnimationKey {
4;
4;
1;16;0.816100,-0.575500,0.052500,0.000000,0.575500,0.801200,-0.164300,0.000000,0.052500,0.164300,0.985000,0.000000,0.603200,1.828800,2.824900,1.000000;;,
15;16;0.202200,0.192900,-0.960200,0.000000,-0.786000,-0.553000,-0.276600,0.000000,-0.584300,0.810600,0.039800,0.000000,0.603200,1.828800,2.824900,1.000000;;,
20;16;0.575700,0.325600,-0.750000,0.000000,-0.737100,-0.190300,-0.648500,0.000000,-0.353900,0.926200,0.130500,0.000000,0.603200,1.828800,2.824900,1.000000;;,
30;16;0.771700,-0.635400,0.026400,0.000000,0.636000,0.770600,-0.041800,0.000000,0.006200,0.049000,0.998800,0.000000,0.603200,1.828800,2.824900,1.000000;;;
}

Any thoughts?
Thanks,
JRT
}

Jun 28, 2007 at 3:26 PM
MafuDG,
You mentioned forgetting to bake your animation. Is that required to export from Blender correctly? How exactly is that done in Blender? Thanks for your help,
~/jt
Jun 29, 2007 at 3:28 AM
Baking is necessary from what I can tell (if you don't, things tend to move jerkier / faster than you may want)

Essentially, you need the Action Editor Pane open, and there is a Bake Button for your Action. You need to press this. This button will create a copy of the animation that is baked. It will have a suffix of ".baked". Here are some quick screen shots. The Exporter will grab the Active Action (from what I can best tell), so make the Baked Action active and have fun with it in XNA!

http://img176.imageshack.us/my.php?image=baketc5.png
http://img257.imageshack.us/my.php?image=bake2mh7.png
http://img401.imageshack.us/my.php?image=bake3sn2.png

I hope this helps. If you have any other questions about Blender and the like I suppose you can pm me if you like... I'm no expert, but I know enough to get by and do some fairly nifty things.
Jun 29, 2007 at 4:41 PM
Thanks for the tip. I hadn't used the action editor yet but everything you described worked for baking. I noticed the exported X file changed to include every frame in the animation - so it looked like it work. Still, my model is not animating with ACL. Very frustrating!
Thanks again,
~/jt
Jun 30, 2007 at 12:27 AM
Edited Jun 30, 2007 at 12:31 AM
If I were you, I'd grab a model I know works, and modify the DwarfDemo (see my above posts) to make sure you have a working C# code-base, then begin trying to diagnose your .X file issue.

The most common mistakes for me when exporting were (in order of frequency)
1) Forgetting to check Frames Per Second (default of 25) is set to export,
2) Forgetting to check that each vertex has a bone and each bone at least a vertex
3) Forgetting to bake my animation.
4) Having a Parent-less bone
Jun 30, 2007 at 4:18 PM
Yeah, my example program does load and animate the Dwarf correctly, so the problem is definitely with my exported model. I was beginning to wonder if the vertices were being exported as "skinned" to the bones. I'm just learning the X file format and it is so large I wasn't sure how to tell. Going through your checklist, I think #2 is a possibility. What did you see if some vertices were not attached to a bone? I'm confident each bone at least has some vertices and of course everything animates correctly in Blender? Also, is there a baking process (similar to the animation) for skinning the mesh before export?
Thanks for your help,
~/jt
Jun 30, 2007 at 10:49 PM
What I would do if you think some verts don't have bones is go through each vertex group in edit mode, and click "select", if some vertices are still not selected after you have done this for each vertex group, you need to assign those vertices to a group, and of course each group needs to belong to a bone (I think errors result otherwise, I forget... I haven't had as many issues lately... just forgetting to check the FPS button happens to me now)

How are you referencing the animation to be played? Are you using strings or integer indices? Specifying Animation index 0 will let you randomly load in models and play back the first animation without having to type in the name of it.

As for baking skinned animation into vertex keys, there may be a method, but I don't use it as it isn't necessary for ACL. I wonder though, what settings are you using when you export? I doubt this is an issue if you are getting Animation Frames exported into the .X file

The reason I had such small files in my first post was because I was having issues fixing larger files (and troubleshooting them).

Let me know if I'm way off base.