   Having trouble using joint animation data
  Finished writing my joint animation class and I'm sure I'm not handling the initial "joint" position and rotation correctly. My use of the key frames to produce the tweens seems to be working. As you would expect, my model is completely distorted.So I think my main problem is handling the initial position and rotation of the joint. For example, the below joint z rotation number (in radians). That 180 degrees. None of the joints are rotated that much so I'm sure there's something I don't understand about this data."Neck""Chest"21 -0.001573 0.431019 2.306767 -0.049801 0.000284 -3.141593Any help would be greatly appreciated.Below is the code of the node that handles translating the joint./*************************************************************************    desc:  Transform the joint** param: CXVertBuff * pXVertBuf - Directx virtex buffers* float time - Hi-res milisecond time that has passed************************************************************************/void CJointNode::Transform( CXVertBuff * pXVertBuf, float time ){// init the matrixmatrix.InitilizeMatrix();// generate the tween pos & rot from key framesGetTweenPosRot( time );// Do the tween rotation & positionmatrix.Rotate( tweenRot );matrix.Translate( tweenPos );// Do the joint rotation & positionmatrix.Rotate( pJointAnim->rot );matrix.Translate( pJointAnim->pos );// Merge in the previous nodes's matrix so that the joint gets// the movement of it's parent jointif( pPrevNode != NULL ){matrix.MergeMatrix( pPrevNode->matrix );}// Transform the joint and copy the data to DirectXpJoint->Transform( matrix, pXVertBuf );}// Transform/*************************************************************************    desc:  Get the tween rotation and translation**    param: float time - Hi-res milisecond time that has passed************************************************************************/void CJointNode::GetTweenPosRot( float time ){// find the time slot this belongs infor( int i = 0; i < pJointAnim->keyFrameCount - 1; i++ ){if( time > pJointAnim->pKeyFrame.time &&time < pJointAnim->pKeyFrame[i+1].time ){// Calculate the amount (0.0 - 1.0) to average between the two key framesfloat range = pJointAnim->pKeyFrame[i+1].time - pJointAnim->pKeyFrame.time;float amount = 1.0f - ((pJointAnim->pKeyFrame[i+1].time - time) / range);// Convert the positiontweenPos.x = ((1-amount) * pJointAnim->pKeyFrame.pos.x) +    (amount * pJointAnim->pKeyFrame[i+1].pos.x);tweenPos.y = ((1-amount) * pJointAnim->pKeyFrame.pos.y) +    (amount * pJointAnim->pKeyFrame[i+1].pos.y);tweenPos.z = ((1-amount) * pJointAnim->pKeyFrame.pos.z) +    (amount * pJointAnim->pKeyFrame[i+1].pos.z);// Convert the rotationtweenRot.x = ((1-amount) * pJointAnim->pKeyFrame.rot.x) +    (amount * pJointAnim->pKeyFrame[i+1].rot.x);tweenRot.y = ((1-amount) * pJointAnim->pKeyFrame.rot.y) +    (amount * pJointAnim->pKeyFrame[i+1].rot.y);tweenRot.z = ((1-amount) * pJointAnim->pKeyFrame.rot.z) +    (amount * pJointAnim->pKeyFrame[i+1].rot.z);break;}}}// GetTweenPosRotHere's my matrix class./*************************************************************************    FILE NAME:  matrix.cpp**    DESCRIPTION:4x4 Matrix math class************************************************************************/// Standard lib dependencies#include <math.h>#include <memory.h>// Physical component dependency#include "matrix.h"// Turn off the data type conversion warning (ie. int to float, float to int etc.)// We do this all the time in 3D. Don't need to be bugged by it all the time.#pragma warning(disable : 4244)/*************************************************************************    desc:  Constructer ************************************************************************/CMatrix::CMatrix(){const long double PI = 3.14159265358979323846;    // Setup the double for convertion of degrees to radians    c2r = (long double)PI / (long double)180;    InitilizeMatrix();}   // Constructor/*************************************************************************    desc:  Copy Constructer**    param: const CMatrix & obj - Matrix object************************************************************************/CMatrix::CMatrix( const CMatrix & obj ){*this = obj;}   // Constructor/************************************************************************ *    desc:  Reset the matrix to the identity matrix************************************************************************/void CMatrix::InitilizeMatrix(){    InitIdentityMatrix( matrix );}   // InitilizeMatrix/*************************************************************************    desc:  Initializes a specific matrix to the identity matrix**    param: float mat[16] - Matrix array************************************************************************/void CMatrix::InitIdentityMatrix( float mat[16] ){    // Initializes a specific matrix to the identity matrix:mat[0]  = 1;   mat[1] = 0;   mat[2]  = 0;   mat[3] = 0;    mat[4]  = 0;   mat[5] = 1;   mat[6]  = 0;   mat[7] = 0;    mat[8]  = 0;   mat[9] = 0;   mat[10] = 1;  mat[11] = 0;    mat[12] = 0;  mat[13] = 0;   mat[14] = 0;  mat[15] = 1;}   // InitIdentityMatrix/*************************************************************************    desc:  Copy Constructer**    param: const CMatrix & obj - Matrix object************************************************************************/void CMatrix::MergeMatrix( CMatrix & obj ){MergeMatrix( obj.GetMatrix() );}/*************************************************************************    desc:  Merge matrix into master matrix**    parm:  float newMatrix[16] - Matrix array************************************************************************/  void CMatrix::MergeMatrix( float newMatrix[16] ){    float temp[16];    for( int i = 0; i < 4; ++i )    {   for( int j = 0; j < 4; ++j )   {   temp[(i*4)+j] = (matrix[i*4] * newMatrix[j])  + (matrix[(i*4)+1] * newMatrix[4+j])  + (matrix[(i*4)+2] * newMatrix[8+j])  + (matrix[(i*4)+3] * newMatrix[12+j]);   }    }    // Copy temp to master Matrixmemcpy( matrix, temp, sizeof(temp) );}  // MergeMatrix/*************************************************************************    desc:  Merge source matrix into destination matrix.**    param: float Dest[16] - Destination Matric* float Source[16] - Source Matrix************************************************************************/void CMatrix::MergeMatrices( float dest[16], float source[16] ){    float temp[16];    for( int i = 0; i < 4; ++i )    {   for( int j = 0; j < 4; ++j )   {  temp[ (i*4)+j ] = ( source[ i*4 ] * dest[ j ] )  + ( source[ (i*4)+1 ] * dest[ 4+j ] )  + ( source[ (i*4)+2 ] * dest[ 8+j ] )  + ( source[ (i*4)+3 ] * dest[ 12+j ] );   }    }    // Copy Temp to Destmemcpy( dest, temp, sizeof(temp) );}   // MergeMatrices/*************************************************************************    desc:  Generate 3D rotation matrix.**    param: CRadian & point - rotation point************************************************************************/  void CMatrix::Rotate( CRadian & point ){float temp[ 16 ];float rMatrix[ 16 ];// init the rotation matrixInitIdentityMatrix( rMatrix );// Initialize Z rotation matrixif( point.z != 0.0f ){float cosZ( cos(point.z) );float sinZ( sin(point.z) );InitIdentityMatrix( temp );temp[0] = cosZ;temp[1] = sinZ;temp[4] = -sinZ;temp[5] = cosZ;// Merge matrix with rotation matrixMergeMatrices( rMatrix, temp );}// Initialize Y rotation matrixif( point.y != 0.0f ){float cosY( cos(point.y) );float sinY( sin(point.y) );InitIdentityMatrix( temp );temp[0]  = cosY;temp[2]  = -sinY;temp[8]  = sinY;temp[10] = cosY;// Merge matrix with rotation matrixMergeMatrices( rMatrix, temp );}// Initialize X rotation matrixif( point.x != 0.0f ){float cosX( cos(point.x) );float sinX( sin(point.x) );InitIdentityMatrix( temp );temp[5]  = cosX;temp[6]  = sinX;temp[9]  = -sinX;temp[10] = cosX;// Merge matrix with rotation matrixMergeMatrices( rMatrix, temp );}// Merg the rotation into the master matrixMergeMatrix( rMatrix );}   // Rotate/*************************************************************************    desc:  Generate 3D rotation matrix.**    param: CPoint & point - rotation point************************************************************************/  void CMatrix::Rotate( CPoint & point ){float temp[ 16 ];float rMatrix[ 16 ];// init the rotation matrixInitIdentityMatrix( rMatrix );// Initialize Z rotation matrixif( point.z != 0.0f ){float cosZ( cos(point.z * c2r) );float sinZ( sin(point.z * c2r) );InitIdentityMatrix( temp );temp[0] = cosZ;temp[1] = sinZ;temp[4] = -sinZ;temp[5] = cosZ;// Merge matrix with rotation matrixMergeMatrices( rMatrix, temp );}// Initialize Y rotation matrixif( point.y != 0.0f ){float cosY( cos(point.y * c2r) );float sinY( sin(point.y * c2r) );InitIdentityMatrix( temp );temp[0]  = cosY;temp[2]  = -sinY;temp[8]  = sinY;temp[10] = cosY;// Merge matrix with rotation matrixMergeMatrices( rMatrix, temp );}// Initialize X rotation matrixif( point.x != 0.0f ){float cosX( cos(point.x * c2r) );float sinX( sin(point.x * c2r) );InitIdentityMatrix( temp );temp[5]  = cosX;temp[6]  = sinX;temp[9]  = -sinX;temp[10] = cosX;// Merge matrix with rotation matrixMergeMatrices( rMatrix, temp );}// Merg the rotation into the master matrixMergeMatrix( rMatrix );}   // Rotate/*************************************************************************    desc:  Create 3D translation matrix**    param: CPoint & point - translation point************************************************************************/void CMatrix::Translate( CPoint & point ){    float temp[ 16 ];    // Initialize translation matrix    InitIdentityMatrix( temp );    temp[12] = point.x;    temp[13] = point.y;    temp[14] = point.z;    // Merge matrix with master matrix:    MergeMatrix( temp );}   // Translate/*************************************************************************    desc:  Function designed to transform a vertex using* the master matrix**    param: CPoint & dest - destination point* CPoint & source - source point************************************************************************/void CMatrix::Transform( CPoint & dest, CPoint & source ){    // Transform vertex by master matrix:    dest.x = ( source.x * matrix[ 0 ] ) + ( source.y * matrix[ 4 ] ) + ( source.z * matrix[ 8 ] ) + matrix[ 12 ];    dest.y = ( source.x * matrix[ 1 ] ) + ( source.y * matrix[ 5 ] ) + ( source.z * matrix[ 9 ] ) + matrix[ 13 ];    dest.z = ( source.x * matrix[ 2 ] ) + ( source.y * matrix[ 6 ] ) + ( source.z * matrix[ 10 ] ) + matrix[ 14 ];}   // Transform/*************************************************************************    desc:  Function designed to transform a normal. Normals don't have* a position, only direction so we only use the rotation* portion of the matrix.**    param: CTransNormal & dest - destination point* CNormal & source - source point************************************************************************/void CMatrix::Transform( CNormal & dest, CNormal & source ){    // Transform vertex by master matrix:    dest.x = ( source.x * matrix[ 0 ]) + ( source.y * matrix[ 4 ]) + ( source.z * matrix[ 8 ]);    dest.y = ( source.x * matrix[ 1 ]) + ( source.y * matrix[ 5 ]) + ( source.z * matrix[ 9 ]);    dest.z = ( source.x * matrix[ 2 ]) + ( source.y * matrix[ 6 ]) + ( source.z * matrix[ 10 ]);}   // Transform/*************************************************************************    desc: Function designed to merge scaling matrix with master matrix.**    NOTE: You can scale on all 3 axises but I can't think of reason*you would want to do that. Plus allowing scaling on all 3*axises would introduce unneeded complexity into the bounding*sphere checks for collision and such.**    NOTE: To scale down, value needs to be inbetween 0.0 to 1.0.*Scale up is any value greater then 1.0**    param:  float scale - scale value************************************************************************/   void CMatrix::Scale( float scale ){    float temp[ 16 ];    // Initialize translation matrix    InitIdentityMatrix( temp );    // Initialize scaling matrix:    temp[0]  = scale;    temp[5]  = scale;    temp[10] = scale;    // Merge matrix with master matrix:    MergeMatrix( temp );}   // Scale/*************************************************************************    desc:  Inverses this matrix. Assumes that the last column is [0 0 0 1]**    ret: bool - true on success************************************************************************/bool CMatrix::Inverse(){const float EPSILON_E5((float)(1E-5));    float det =  ( matrix[0] * ( matrix[5] * matrix[10] - matrix[6] * matrix[9] ) -    matrix[1] * ( matrix[4] * matrix[10] - matrix[6] * matrix[8] ) +    matrix[2] * ( matrix[4] * matrix[9]  - matrix[5] * matrix[8] ) );    // test determinate to see if it's 0    if( fabs(det) < EPSILON_E5 )    {   return false;    }    float det_inv  = 1.0f / det;    float tmp[ 16 ];    // Initialize translation matrix    InitIdentityMatrix( tmp );    tmp[0]  =  det_inv * ( matrix[5] * matrix[10] - matrix[6] * matrix[9] );    tmp[1]  = -det_inv * ( matrix[1] * matrix[10] - matrix[2] * matrix[9] );    tmp[2]  =  det_inv * ( matrix[1] * matrix[6] - matrix[2] * matrix[5] );    tmp[3]  = 0.0f; // always 0   tmp[4]  = -det_inv * ( matrix[4] * matrix[10] - matrix[6] * matrix[8] );    tmp[5]  =  det_inv * ( matrix[0] * matrix[10] - matrix[2] * matrix[8] );    tmp[6]  = -det_inv * ( matrix[0] * matrix[6] - matrix[2] * matrix[4] );    tmp[7]  = 0.0f; // always 0   tmp[8]  =  det_inv * ( matrix[4] * matrix[9] - matrix[5] * matrix[8] );    tmp[9]  = -det_inv * ( matrix[0] * matrix[9] - matrix[1] * matrix[8] );    tmp[10] =  det_inv * ( matrix[0] * matrix[5] - matrix[1] * matrix[4] );    tmp[11] = 0.0f; // always 0   tmp[12] = -( matrix[12] * tmp[0] + matrix[13] * tmp[4] + matrix[14] * tmp[8]  );    tmp[13] = -( matrix[12] * tmp[1] + matrix[13] * tmp[5] + matrix[14] * tmp[9]  );    tmp[14] = -( matrix[12] * tmp[2] + matrix[13] * tmp[6] + matrix[14] * tmp[10] );    tmp[15] = 1.0f; // always 0    // Copy Temp to Destmemcpy( matrix, tmp, sizeof(tmp) );return true;}/*************************************************************************    desc:  Initializes a specific matrix to the identity matrix**    ret: float * - Pointer to matrix array************************************************************************/float * CMatrix::GetMatrix(){return matrix;}Below is the joint animation data. Not sure why some of the joint rotations use pi (-3.141593). Nothing rotates 180 degrees.Bones: 19"Pelvis"""21 0.100000 4.662936 -3.870470 0.000000 -0.000000 0.00000081.000000 0.000000 0.000000 0.0000004.000000 0.000000 3.000000 -0.2000007.000000 0.000000 0.000000 0.00000010.000000 0.000000 -1.583335 0.25000013.000000 0.000000 -2.450002 -0.15000116.000000 0.000000 -0.983335 0.21666619.000000 0.000000 -0.600002 -0.00000022.000000 0.000000 0.000000 0.00000081.000000 -0.244346 0.000000 0.0000004.000000 -0.000000 0.000000 0.0000007.000000 0.139626 -0.000000 0.00000010.000000 -0.296706 0.000000 0.00000013.000000 -0.471239 0.000000 0.00000016.000000 -0.087267 0.000000 0.00000019.000000 -0.226893 0.000000 0.00000022.000000 -0.244346 0.000000 0.000000"Waist""Pelvis"21 0.000548 -0.458333 3.291667 0.077983 0.000323 0.00000071.000000 -0.000000 -0.000009 0.0000247.000000 -0.000000 -0.000052 0.00018710.000000 -0.000000 -0.000091 0.00059813.000000 -0.000000 -0.000090 0.00062516.000000 -0.000000 -0.000093 0.00063419.000000 -0.000000 -0.000092 0.00063022.000000 -0.000000 -0.000009 0.00002471.000000 -0.000000 -0.000000 -0.0000007.000000 -0.052362 -0.000002 -0.00001710.000000 0.296725 -0.000007 0.00009513.000000 0.610887 -0.000044 0.00019016.000000 0.453808 -0.000022 0.00014419.000000 0.226915 -0.000003 0.00007322.000000 0.000000 0.000000 -0.000000"Chest""Waist"21 0.000000 0.000000 2.674795 0.000000 -0.000000 0.00000021.000000 0.000000 0.000000 0.00000022.000000 0.000000 0.000000 0.00000021.000000 0.000000 -0.000000 0.00000022.000000 0.000000 -0.000000 0.000000"Neck""Chest"21 -0.001573 0.431019 2.306767 -0.049801 0.000284 -3.14159351.000000 -0.000000 0.000009 -0.0000024.000000 0.000000 -0.002904 0.0052797.000000 0.000000 -0.004649 0.00844816.000000 0.000000 -0.002066 0.00376522.000000 -0.000000 0.000009 -0.00000251.000000 -0.157080 -0.000004 0.0000064.000000 0.043762 0.000001 -0.0000027.000000 0.070070 0.000002 -0.00000316.000000 0.195579 0.000006 -0.00000722.000000 -0.157080 -0.000004 0.000006"Head""Neck"5 0.000000 0.000000 1.638288 0.000000 -0.000000 0.00000047.000000 0.000000 -0.000001 -0.00000513.000000 0.000000 -0.000000 -0.00000516.000000 -0.000000 0.000253 -0.00047322.000000 0.000000 -0.000001 -0.00000547.000000 0.122173 0.000004 -0.00000413.000000 0.335103 0.000011 -0.00001116.000000 0.328107 0.000011 -0.00001022.000000 0.122173 0.000004 -0.000004"lShoulder""Chest"21 1.733080 -1.116157 0.087780 -1.492878 0.076178 -3.14159371.000000 0.000000 -0.000000 0.0000694.000000 0.000008 -0.000002 0.0000317.000000 -0.000067 0.000603 0.02001310.000000 -0.000067 0.000603 0.01998213.000000 -0.021410 -0.317143 -0.43969616.000000 -0.036649 -0.544168 -0.77016922.000000 0.000000 -0.000000 0.00006971.000000 -0.104416 0.007864 -0.0010324.000000 0.533762 0.117788 0.0029727.000000 -0.307429 0.127220 0.00417610.000000 -0.655854 0.184786 -0.01878113.000000 -0.652897 0.227469 -0.00602016.000000 -0.649698 0.207679 0.04478222.000000 -0.104416 0.007864 -0.001032"lArm""lShoulder"21 0.000000 0.000000 2.899996 0.000000 -0.000000 0.00000091.000000 -0.000035 -0.000031 0.0038804.000000 -0.000031 -0.000005 0.0035627.000000 0.070490 0.898337 -0.40905410.000000 0.117463 0.002064 -0.95789513.000000 -0.000717 -0.006183 0.03509216.000000 -0.000724 -0.006251 0.03555017.000000 0.180326 0.438033 -1.14951819.000000 0.012803 0.154907 -0.18488022.000000 -0.000035 -0.000031 0.00388091.000000 0.505157 -0.037397 -0.0065874.000000 0.261315 -0.019779 -0.0010357.000000 0.226502 -0.017170 -0.00059910.000000 -0.315041 0.023184 -0.00556913.000000 -0.785774 0.051805 -0.02639316.000000 -0.402188 0.029178 -0.00836917.000000 -0.131375 0.009875 -0.00142919.000000 0.410063 -0.030699 -0.00390922.000000 0.505157 -0.037397 -0.006587"rShoulder""Chest"21 -1.366833 -1.149462 0.089377 -1.492053 0.163967 -3.14159371.000000 -0.000035 0.000006 0.0000534.000000 -0.000028 0.000005 0.0000487.000000 -0.000191 0.000652 0.02061110.000000 -0.000199 0.000655 0.02060113.000000 -0.046098 -0.314526 -0.43901916.000000 -0.078865 -0.539722 -0.76951822.000000 -0.000035 0.000006 0.00005371.000000 -0.103335 0.016906 -0.0022214.000000 0.711009 -0.245890 -0.0675217.000000 -0.238382 -0.048512 -0.02220310.000000 -0.671505 -0.006279 -0.04290113.000000 -0.678512 -0.074544 -0.05962916.000000 -0.672630 -0.064637 -0.10525122.000000 -0.103335 0.016906 -0.002221"rArm""rShoulder"21 0.000000 0.000000 2.866838 0.000000 -0.000000 0.00000091.000000 -0.000054 -0.000013 0.0038234.000000 -0.000058 -0.000016 0.0035367.000000 0.151523 0.888251 -0.40904410.000000 -0.068207 0.024737 -0.96257913.000000 -0.001454 -0.005760 0.03473716.000000 -0.001469 -0.005817 0.03519017.000000 -0.050340 0.465132 -1.15215419.000000 0.027590 0.153465 -0.18436822.000000 -0.000054 -0.000013 0.00382391.000000 0.500503 -0.080454 -0.0139304.000000 0.258631 -0.042525 -0.0021427.000000 0.327956 -0.049622 -0.01277510.000000 -0.312014 0.049853 -0.01193013.000000 -0.693552 0.112799 -0.05666316.000000 -0.398508 0.062756 -0.01792217.000000 -0.130007 0.021227 -0.00307019.000000 0.406121 -0.066031 -0.00823422.000000 0.500503 -0.080454 -0.013930"lHip""Pelvis"21 1.662874 -1.099802 -0.173913 -2.083778 0.002482 -3.14159381.000000 0.000000 -0.000013 0.0000434.000000 0.000000 -0.000026 0.0000667.000000 -0.000674 0.401431 -1.26618710.000000 -0.000674 0.401437 -1.26621413.000000 -0.000215 -0.153897 0.09634716.000000 -0.000215 -0.153907 0.09635919.000000 -0.000215 -0.153909 0.09636122.000000 0.000000 -0.000013 0.00004381.000000 -0.471245 0.001114 0.0003174.000000 -0.820323 0.001969 0.0002037.000000 -0.069838 0.000154 0.00008010.000000 0.560362 -0.137317 -0.03111213.000000 0.855541 -0.140717 -0.00752316.000000 0.770626 -0.112385 -0.05211119.000000 0.000003 -0.000000 -0.00000022.000000 -0.471245 0.001114 0.000317"lLeg""lHip"21 0.000000 0.000000 4.606722 0.000000 -0.000000 0.00000081.000000 0.000015 -0.004254 0.0190644.000000 0.000021 -0.004416 0.0261907.000000 -0.001548 -0.235781 -0.83716010.000000 -0.001925 -0.506644 -0.66480013.000000 -0.001929 -0.506711 -0.66485016.000000 -0.001913 -0.507113 -0.65512419.000000 -0.001914 -0.506878 -0.65664022.000000 0.000015 -0.004254 0.01906481.000000 -0.402268 0.000944 0.0003044.000000 -0.891792 0.002136 0.0001447.000000 0.163562 -0.000336 -0.00022710.000000 0.041697 -0.000089 -0.00005313.000000 -0.501508 -0.020467 -0.02579416.000000 -0.709552 0.001702 0.00027219.000000 -0.011420 0.000025 0.00001422.000000 -0.402268 0.000944 0.000304"rHip""Pelvis"21 -1.470460 -1.133135 -0.173913 2.083592 0.014273 0.00000081.000000 0.000000 0.000016 0.0000464.000000 0.000000 0.000032 0.0000757.000000 -0.003877 -0.401218 -1.26624310.000000 -0.003878 -0.401210 -1.26624213.000000 -0.001239 0.153889 0.09642316.000000 -0.001239 0.153901 0.09643819.000000 -0.001239 0.153901 0.09643822.000000 0.000000 0.000016 0.00004681.000000 0.471194 0.006409 -0.0018244.000000 0.663175 0.009141 -0.0016757.000000 -0.087234 -0.001057 0.00065710.000000 -0.559034 -0.124855 0.03185813.000000 -0.855130 -0.146484 0.01536316.000000 -0.875185 -0.112378 0.07179919.000000 -0.000005 -0.000000 0.00000022.000000 0.471194 0.006409 -0.001824"rLeg""rHip"21 0.000000 0.000000 4.606917 0.000000 -0.000000 0.00000081.000000 0.000079 0.004196 0.0192824.000000 0.000128 0.004345 0.0264077.000000 -0.010432 0.389604 -0.79885710.000000 -0.010926 0.505459 -0.66407813.000000 -0.010928 0.505477 -0.66422216.000000 -0.010869 0.505933 -0.65489419.000000 -0.010876 0.505916 -0.65660922.000000 0.000079 0.004196 0.01928281.000000 0.402227 0.005428 -0.0017494.000000 0.891705 0.012283 -0.0008237.000000 -0.163563 -0.001932 0.00130610.000000 -0.041709 -0.000513 0.00030313.000000 0.207358 -0.035896 0.06243116.000000 0.709441 0.009791 -0.00156119.000000 0.011380 0.000142 -0.00007922.000000 0.402227 0.005428 -0.001749"Tail1""Pelvis"21 0.000000 0.871377 -2.449275 2.974860 0.000878 -3.14159381.000000 0.000000 0.000000 0.0000004.000000 0.000000 0.000000 0.0000007.000000 0.000000 0.000000 0.00000010.000000 0.000000 0.000000 0.00000013.000000 0.000000 0.000000 0.00000016.000000 0.000000 0.000000 0.00000019.000000 0.000000 0.000000 0.00000022.000000 0.000000 0.000000 0.00000081.000000 0.000000 -0.000000 0.0000004.000000 0.000000 -0.000000 0.0000007.000000 0.000000 -0.000000 0.00000010.000000 0.000000 -0.000000 0.00000013.000000 0.000000 -0.000000 0.00000016.000000 0.000000 -0.000000 0.00000019.000000 0.000000 -0.000000 0.00000022.000000 0.000000 -0.000000 0.000000"Tail2""Tail1"21 0.000000 0.000000 2.537915 -0.184060 0.000435 0.00000081.000000 0.000000 0.000000 0.0000004.000000 -0.000000 -0.000000 0.0000007.000000 -0.000000 -0.000000 0.00000010.000000 0.000000 -0.000004 -0.00000313.000000 -0.000000 -0.000000 0.00000016.000000 0.000000 0.000000 -0.00000019.000000 -0.000000 0.000006 0.00000722.000000 0.000000 0.000000 0.00000081.000000 0.000000 -0.000000 0.0000004.000000 -0.069772 -0.213270 0.6329647.000000 -0.244388 -0.429127 1.02829110.000000 -0.001979 -0.014917 0.27886413.000000 0.025133 -0.074121 -0.65969416.000000 -0.121896 0.222537 -0.99641419.000000 -0.016673 0.061774 -0.52027922.000000 0.000000 -0.000000 0.000000"Tail3""Tail2"21 0.000000 0.000000 3.313231 0.850089 0.001684 -3.14159381.000000 -0.000000 0.000003 0.0000004.000000 -0.000000 0.000003 0.0000007.000000 -0.000000 0.000003 0.00000010.000000 -0.000000 0.000003 0.00000013.000000 -0.000000 0.000003 0.00000016.000000 -0.000000 0.000003 0.00000019.000000 -0.000000 0.000003 0.00000022.000000 0.000000 0.000000 0.00000081.000000 0.000087 -0.016273 -0.0063114.000000 0.000087 -0.016273 -0.0063117.000000 0.000087 -0.016273 -0.00631110.000000 0.000087 -0.016273 -0.00631113.000000 0.000087 -0.016273 -0.00631116.000000 0.000087 -0.016273 -0.00631119.000000 0.000087 -0.016273 -0.00631122.000000 0.000000 -0.000000 0.000000"Tail4""Tail3"21 0.000000 0.000000 3.060097 -1.051098 0.002417 -3.14159381.000000 -0.000024 0.000032 -0.0000664.000000 -0.000027 0.000031 -0.0000617.000000 -0.000021 0.000038 -0.00006810.000000 -0.000026 0.000032 -0.00006713.000000 -0.000024 0.000032 -0.00006616.000000 -0.000024 0.000032 -0.00006719.000000 -0.000027 0.000045 -0.00009222.000000 0.000000 0.000000 0.00000081.000000 -0.001440 -0.011392 -0.0471594.000000 0.082838 -0.081172 0.0358247.000000 0.394359 -0.178008 0.06858910.000000 0.041584 -0.076108 0.10728813.000000 0.194918 0.075499 -0.29416016.000000 0.395319 0.186393 -0.22340319.000000 0.110709 0.096637 -0.23095322.000000 0.000000 -0.000000 0.000000"Tail5""Tail4"21 0.000000 0.000000 3.154895 0.479137 0.001960 -3.14159381.000000 0.007820 -0.010447 -0.0032694.000000 0.007820 -0.010447 -0.0032697.000000 0.007820 -0.010447 -0.00326910.000000 0.007820 -0.010447 -0.00326913.000000 0.007820 -0.010447 -0.00326916.000000 0.007820 -0.010447 -0.00326919.000000 0.007820 -0.010447 -0.00326922.000000 0.000000 0.000000 0.00000081.000000 0.018745 0.015647 -0.1716234.000000 0.018745 0.015647 -0.1716237.000000 0.018745 0.015647 -0.17162310.000000 0.018745 0.015647 -0.17162313.000000 0.018745 0.015647 -0.17162316.000000 0.018745 0.015647 -0.17162319.000000 0.018745 0.015647 -0.17162322.000000 0.000000 -0.000000 0.000000"Tail6""Tail5"21 0.000000 0.000000 4.565081 0.000000 -0.000000 0.00000081.000000 0.000000 0.000000 0.0000004.000000 0.000000 0.000000 0.0000007.000000 0.000000 0.000000 0.00000010.000000 0.000000 0.000000 0.00000013.000000 0.000000 0.000000 0.00000016.000000 0.000000 0.000000 0.00000019.000000 0.000000 0.000000 0.00000022.000000 0.000000 0.000000 0.00000081.000000 0.000000 -0.000000 0.0000004.000000 0.000000 -0.000000 0.0000007.000000 0.000000 -0.000000 0.00000010.000000 0.000000 -0.000000 0.00000013.000000 0.000000 -0.000000 0.00000016.000000 0.000000 -0.000000 0.00000019.000000 0.000000 -0.000000 0.00000022.000000 0.000000 -0.000000 0.000000
Quote:so I'm sure there's something I don't understand about this data.What is the source of your data? It's difficult to help you understand it if the method you use to get it isn't known.;Quote:Original post by BuckeyeWhat is the source of your data? It's difficult to help you understand it if the method you use to get it isn't known.Oops, good point. MilkShape is the modeler. The data is the bone animation part from the ASCII exporter.Image of model in MilkShape;  First, I'm not familiar with the ms3d format in particular.However, the ms3d format may be a right-hand coordinate system. DirectX uses a left-hand coordinate system. That may be the problem.Does the mesh display correctly without animation (time=0)? Get that displaying correctly first before applying the animation.With respect to the 180 degree rotation: those are local transformations. Are you sure that any particular joint's base rotation isn't  180 degrees with respect to its parent joint?   ;Quote:Original post by BuckeyeDirectX uses a left-hand coordinate system. That may be the problem.This is true. I'm using the ASCII exported data from MilkShape because it's a bit easier to read. I've written my own MilkShape plug-in that exports the data as xml. My plugin converts the data from MilkShape to the left-hand system and for the joint and key frame positions, I flip the Z.Quote:Original post by BuckeyeDoes the mesh display correctly without animation (time=0)?Yes, that was one of the first things I tried when trouble shooting the problem. If I don't use any of the animation data, it displays correctly.Quote:Original post by BuckeyeWith respect to the 180 degree rotation: those are local transformations. Are you sure that any particular joint's base rotation isn't  180 degrees with respect to its parent joint?I see that in other models as well. I would assume you have had to rotate the joint 180 on for your first frame of animation. Since the joints are added after after the model is created, the first frame of information is just slightly different then the meshes default position.One thing to note is if you look at the data, the "joint" position offsets appear to be accumulative. From the Pelvis to the head, the numbers work. If you add them up as you go from joint to joint, it produces the correct joint offset. The shoulders, hip and tail1 also work if added up. As you add up the other values, they are way off and the Z's are the wrong signsBelow is console output of the joint values being added up from joint to joint. The Z values of the lArm, rArm, lLeg, rLeg and from Tail2 on are incorrect. Also, if you've seen the screen shot and look at the Y positions below for the tail, there's no reason why the below Y's should all be the same. So much doesn't make sense.Pelvis: 0.100000, 4.662936, 3.870470Waist: 0.100548, 4.204603, 0.578803Chest: 0.100548, 4.204603, -2.095992Neck: 0.098975, 4.635622, -4.402759Head: 0.098975, 4.635622, -6.041047lShoulder: 1.833628, 3.088446, -2.183772lArm: 1.833628, 3.088446, -5.083768rShoulder: -1.266285, 3.055141, -2.185369rArm: -1.266285, 3.055141, -5.052207lHip: 1.762874, 3.563134, 4.044383lLeg: 1.762874, 3.563134, -0.562339rHip: -1.370460, 3.529801, 4.044383rLeg: -1.370460, 3.529801, -0.562534Tail1: 0.100000, 5.534313, 6.319745Tail2: 0.100000, 5.534313, 3.781830Tail3: 0.100000, 5.534313, 0.468599Tail4: 0.100000, 5.534313, -2.591498Tail5: 0.100000, 5.534313, -5.746393Tail6: 0.100000, 5.534313, -10.311474I've exported the model as an x file and ran it in an x player and the character animates just fine. So all I can assume is that I don't know what to do with these initial joint positions and rotations.[Edited by - howie_007 on January 25, 2010 2:08:11 PM];Quote:I've written my own MilkShape plug-in that exports the data as xml.I'm not trying to be difficult, but your post reads "I export numbers I don't like. What's wrong?" If you know a joint rotation of 180 is incorrect, isn't that a problem with your export plugin?Quote:My plugin converts the data from MilkShape to the left-hand system and for the joint and key frame positions, I flip the Z.Do you change the rotations also? Just changing the translations won't be sufficient. See EDIT below.Also, if you can export in x-file text format, you can open the x-file in an ASCII editor and compare vertex positions, transformations, etc., with the data you export/import yourself.EDIT: by the way, just flipping the z-coord (and changing the vertex winding order if you want to maintain the "standard" DirectX culling) is fine for static meshes, as you've seen when you display the mesh without animation.However, a bit of googling implies that converting 3D rotations from right-hand to left-hand is non-trivial.[Edited by - Buckeye on January 25, 2010 2:12:39 PM];Quote:Original post by BuckeyeI'm not trying to be difficult, but your post reads "I export numbers I don't like. What's wrong?" If you know a joint rotation of 180 is incorrect, isn't that a problem with your export plugin?no, I see the same data in the ASCII export which is a plug-in provided by MilkShape. It's real easy to write a plug-in for MilkShape. MilkShape provides an easy way to get the data and you can format it anyway you want. Quote:Original post by BuckeyeDo you change the rotations also? Just changing the translations won't be sufficient. See EDIT below.no... I spend some time last night googling the subject but didn't find anything. Looks like I'll have to keep looking. Quote:Original post by BuckeyeAlso, if you can export in x-file text format, you can open the x-file in an ASCII editor and compare vertex positions, transformations, etc., with the data you export/import yourself.We must think alike. I already did that but the joint offsets are stored in the x file as a 4x4 matrix. The key frames seem straight forward.   ;Quote:I spend some time last night googling the subject but didn't find anythingI tried googling for "right-hand left-hand rotation conversion" and got over a million hits. [WINK]   ;  I did find one example of converting the rotations but the math goes right over my head. I'll keep looking.I received an answer to my question in a different forum. Now this is making more sense.Oh, the joint orientations.Yes, they are as you describe.Non-zero joint orientations are a lot more difficult to work with than zeroed ones. Every time, or maybe just most times, when you insert or modify the skeleton, you end up with a lot of odd rotations. Sometimes, instead of a +180 X 0Y 0Z you might see 0X, +180Y and +180Z, which is the same position, but more prone to gimbal lock.You might consider using the Zero Joints plug-in in the tools menu. It will trash the animation you currently have, but it will adjust the skeleton positions to be the at the same place, but with orientations of zero. Some game engines do not even work with non-zeroed joints.But the biggest reason is maintainability. If you are using a model with zeroed rotations and decide to add a weapon slot, for instance, MilkShape will reorient other joints and your already done animations will be all wrong unless you revise the skeleton, which could be a lot of typing into a MS-Ascii file. Using zeroed rotations, you could rezero the joints and you'd be back in business right away.[Edited by - howie_007 on January 25, 2010 8:48:25 PM]