Hierarchical Skeletal Animation

Rodéric

a.k.a. Ingenu
Moderator
Veteran
I'm trying to get my MDL viewer to work, but somehow I fail :(
I parse MDL ASCII files, MDL is the file format of NeverWinter Nights models, official viewers and models (in ASCII MDL) available @ www.neverwinternights.com

I suppose that the orientation is in the following order : X Y Z W and is a quaternion.

For testing purposes I only use KeyFrames values and don't interpolate between them.

Here's pseudo code:


CP : Current Position /vector3f
TP : Total Position /quaternion
CO : Current Orientation /vector3f
TO : Total Orientation /quaternion
CP and CO set to an animation KeyFrame value.

update(){
//recurcive function call on the ROOT bone
//updates the bone matrix
if ( parent == NULL)
{ //this is the root bone
TP = CP;
TO = CO;
} else {
//Children Bone
TP = parent.TP + CP;
TO = parent.TO * CO; //quaternion mult, order matter
}
matrix.toIdentity();
matrix.setRotations( TO );
matrix.setPosition( TP );

for (int i=0; i<childrenCount(); ++i)
children.update();
}


Somehow the rendering is wrong... :(

Any help, tutorial, doc, papers, code, pseudo code... is VERY welcome.
Ask for any additionnal information, screenshots...
 
This is more curiosity than anything, but was is going wrong exactly. Can you in any way describe how it's coming out versus how it should come out.
 
I use the 'creadyr' animation first keyframe and try to display it but it's wrong :(

I can put the model in a somehow 'rest' state, but I'm not sure it's right.

http://membres.lycos.fr/ingenu/MDL/
You can see 4 models loaded and displayed in 'rest' state.
Although it looks right, every Orientation quaternion is @ 0 0 0 0.

So I'm not sure it's right.
You can see the Batrest and bat KF0 (don't remember exact name) are produce by the code above, but still the second is weird while the rest looks ok.

I think it's related somehow with the base position, since the bones only have position noted in the 'base'...

anyway I'm off to bed it's late, I'm tired and depressed.
 
I don't know the file format, and exactly what CP and CO means, so I may be off here. But it seems as your just accumulating relative translations and rotations separately. If the format is anywhere like what I would have done, then you're missing some rotation of the translations.

If I guessed right about the meanings of your translations/rotations, then you should replace the line:
Code:
TP = parent.TP + CP;
with
Code:
TP = parent.TP + rotate(CP,TO);
Or something like that. You should get the idea there at least.

I looked at your images and noticed that the bat looks scaled in the second frame. Since I can't see any scaling parameters, I think that you might have done an error in the quaternion math. Like assuming that they are normalized when they aren't.
 
my bad I was wrong decodign the format :(

I found it weird to write
Code:
orientation 0.0 0.0 0.0  0.0

note the two spaces before the last value
That's not a Quaternion it's an Angle-Axis

Now that I changed my plugin to convert those angle axis to quaternion it works
(except it's jerky but I'll correct that)
 
Back
Top