Hi
Our animators made the changes Spasi suggested, and I’ve implemented the loading of the horse geometry and skeletal animation from the dotXSI file into my JOGL viewer, but I just can’t get the animation to look right. The legs are just rotating in all directions.
I got a simple 2-legged xsi model with 6 bones to work perfectly in my viewer, with correct vertex blending and normals and everything. But the same viewer just won’t work with the more complex horse model (46 bones).
It looks like I’m maybe applying the rotations to the wrong bones, but I’ve checked and it’s (probably) not that. The base-pose (keyframe 0) is perfect, but after that everything goes wrong.
I’m converting Euler to Quaternions like this:
float sx = (float)Math.sin(eulerRotY / 2.0f);
float sy = (float)Math.sin(eulerRotX / 2.0f);
float sz = (float)Math.sin(eulerRotZ / 2.0f);
float cx = (float)Math.cos(eulerRotX / 2.0f);
float cy = (float)Math.cos(eulerRotY / 2.0f);
float cz = (float)Math.cos(eulerRotZ / 2.0f);
Quat4f q1 = new javax.vecmath.Quat4f(sy, 0.0f, 0.0f, cy);
Quat4f q2 = new javax.vecmath.Quat4f(0.0f, sz, 0.0f, cz);
Quat4f q3 = new javax.vecmath.Quat4f(0.0f, 0.0f, sx , cx);
this.rotation = new Quat4f(q1);
this.rotation.mul(q2);
this.rotation.mul(q3);
I found that for the simple 2-legged xsi model to work, I had to change the order to y-z-x in the creation of q1, q2, q3 above (I’ve no idea why). I’ve tried every combination here but not one corrects the horse animation.
After that, it’s a pretty generic skeletal animation system.
In this model I expect each bone and each limb to rotate (mostly) in a plane, even if the euler angles are assigned to the wrong axes, but that’s not what I’m seeing. Child bones sometimes seem to be rotating in planes at right angles to the parent’s plane, but this is not consistent to all the bones. Some bones don’t start and end on the same plane.
I found some anomalies in the horse’s Fcurve data, such as this:
1.000000,14.634259,
2.000000,13.496899,
3.000000,122.101044,
4.000000,176.119934,
5.000000,159.457596,
6.000000,156.837585,
7.000000,180.112411,
8.000000,179.619141,
9.000000,181.027267,
10.000000,185.909149,
11.000000,191.765121,
12.000000,194.263153,
The sequence is supposed to be looped, but somewhere along the way 180 degrees got added, then when looping from keyframe 12 back to keyframe 1, the bone makes a sudden 180 degree rotation in the wrong direction. The animators are looking into this, but this is only part of the problem and affects only a few joints and is easy to recognise both in the viewer and in the data.
Maybe this is the problem? Maybe there are other problems with the data that I can’t pick up
just by looking at the numbers? Maybe there’s a problem with the viewer?
I’ve been strugging exclusively with this for over a week now, and I think I’ve examined
every possible cause. Does anyone please have any suggestions?
Thanks
Kevin