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...
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...