animation controller issue.

Topics: User Forum
Dec 7, 2006 at 3:07 AM
Hi, all:
I use the XNA animation component lib(13277), I can run XNA animation demo sucessly, I also import tiny.x and render it OK. but after import my x file(export from maya 6.5 using DX default plugin) I fail in animationcontorller.cs when rendering:
animationcontorller.cs -> public void Draw(GameTime gameTime) -> matrixPaletteParamsindex.SetValue(pose);, the return exception meanu INVAVID CALL. It seemed I use too much bone in x file and beyond the limit. my pose matrix length is about 56. Could anybody give me any hint? Thank you very much.



Coordinator
Dec 7, 2006 at 3:26 AM
This is a problem in version 1.0.0.2. The bone palette is size is inefficient.

For example, if a model has 60 bones, and only 20 of them are used for animation, then the controller will still pass all 60 of them into the shader. Since the palette is capped at 50 bones, this will throw an exception.

This problem is fixed in the latest source code, so it won't be a problem in the next release unless you are actually using more than 50 bones in the animation. I'll add support for models of arbitrary bone size sometime in the future.

I'll also add a more informative error message that tells you when your model is using too many bones for an animation.

If you want to test it out, you can compile the latest source into a dll. I haven't released 1.0.0.3 yet because I don't think theres much point in releasing something without examples. The code has changed quite a bit since 1.0.0.2
Dec 7, 2006 at 8:36 AM
thank you very much for your quick replay,
I have download the lastest source code( till 3:00 7 dec 2006) and rebuild. It now can throw exception "Model uses to many bones for animation 50 ...". I use another lese bone animation, it is almost ok now(eys mesh didn't follow the body,some bone matrix isnot correct. later I post x file and snapshot). and I also find some little problem related maya X exporter:
1 sometimes the maya export x file skniweight is 1.000001 and > 1f so animation import will throw a exception.
2 sometimes, Maya Export X file have following skinweigh segment:
SkinWeights {
"polySurface50";
0;
;
;
0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000;;
}
when aniamtion importer import skinweight, it can't parse correcly and throw a exception, but I remove this segement, meshview.exe or directview.exe can't open this x file.

Thanks,
Coordinator
Dec 7, 2006 at 1:16 PM
If you could send the model to david_astle@hotmail.com, that would help the debugging a lot. I won't share the model with anyone. Of course, this is optional, and either way I will still try to find the source of the error. I'll look at it later today.
Coordinator
Dec 7, 2006 at 6:49 PM
1 sometimes the maya export x file skniweight is 1.000001 and > 1f so animation import will throw a exception.
2 sometimes, Maya Export X file have following skinweigh segment:
SkinWeights {
"polySurface50";
0;
;
;
0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000;;
}

1. XNA doesn't allow for any skin weight to be over 1; this is not a restriction I put in my importer code, it is something that was put in XNA. I can clamp any value over 1.0 to 1, and log a warning during build, which I will probably do.

2. This is intriguing - the SkinWeights section you show describes a bone pose but it is for a bone that does not influence any vertices. My importer will throw an exception for this since I didn't take this into account. The interesting part is that the .X viewer won't animate the mesh when you take this out... it seems to me like it is an unimportant piece of information. I'll think about it, but sending the model would help a lot.
Dec 11, 2006 at 3:36 AM
Hi, dastle,
thank you very much. I have send some demo X animation files to your email box. All demo x animation file are exported by DirectX Maya exporter.
Coordinator
Dec 12, 2006 at 12:45 AM
Thank you, I will try to find out what is causing them to not work.
Coordinator
Dec 12, 2006 at 8:00 PM
3 things:
1. The files contained some texture file names that were empty strings. I modified the importer to just throw these out.

2. The files contained some "bone influences" with weights of 0. I modified the importer to throw these out (at the cost of a noticeable amount of extra importing time for large files).

3. The files contain verts that are influencd by more than 4 bones. This currently isn't supported by the animation controller.

That sums up most of the errors; the only one I haven't figured out is why the pigs eyes dont show (although this could simply be because they are influenced by a large number of bones).
Coordinator
Dec 12, 2006 at 8:24 PM
I definitely plan on adding support for meshes that have verts influenced by more than 4 bones, however. I'll see how I can implement this without affecting the performance of animating simpler models.
Coordinator
Dec 12, 2006 at 9:24 PM
I added some temp support for 8 bones just to test it out, and I had to fix some quaternion importing code, but I got the pig model to animate properly, minus the eyes :-/

I'll work on those next.
Dec 13, 2006 at 12:34 AM
thanks a lot :). Regarding the Texture name, I don't know why maya exporter write 2 meterial and one texture is empty. I usually remove&ignore the second meterial segment. Pig 2 eyss are standalone mesh and not belong to body mesh, may need some special handle.
Coordinator
Dec 13, 2006 at 4:21 AM
Ok - I got all 3 models to animate correctly. A demo project has been sent to your email. It views frog in the model viwer, which lets you zoom in/out using the mouse wheel, left mouse button drag rotates the model, and right mouse button drag rotates the cam around the model.

I increased the max palette size to 56 bones, and added support for up to 8 bones per vertex. I also updated the source to the new version that animates your models.

One last thing - the lighting for the eyes may be slightly off because they are unskinned meshes and use BasicEffect while the main mesh uses BasicPaletteEffect. BasicPaletteEffect uses phong shading and BasicEffect uses a lower quality lighting.

By the way - VERY nice animations!

Slightly off topic:

Animating these models would not be possible with the default .X importer. It throws some error about how there is a vertex bound to a bone that is not part of the skeleton. So, I'm quite glad that I took the time to make my own importer. They haven't quite "finished" the .X importer in XNA 1.0 apparently.
Coordinator
Dec 14, 2006 at 4:40 AM
First, I'm glad that you got it working.

Second, the "eye color" issue is because I forgot to disable ambient lighting in the modeviewer for BasicEffect (unskinned meshes). This wIll be fixed in the next changeset.