Original Post
I am working on an MD3 loader in DirectX.
Right now it loads all the data and animates it. The problem is the orientation of the different parts. I can get the lower, upper , and head parts attached by adding their positions (located in the tags) The problem comes when I try to apply the rotations stored in the tags.
If Im correct, when I find a link to draw I have to pass it the corresponding tag so i can apply the rotations within?
I have
tempv.position = RotatePbM(v.position, tag);
// (tag was passed by previous node)
tempv.position += pos;
// this just translates
tempv.position = RotateP(v.position, 0.0f, -(PI/2.0f), 0.0f);
// this rotates it to be up and down cuz of how MD3s are stored
D3DXVECTOR3 RotateP(D3DXVECTOR3 v, float r, float p, float y)
{
D3DXMATRIX R, Rx, Ry, Rz;
D3DXVECTOR3 NewV;
D3DXMatrixRotationZ(&Rz, r);
D3DXMatrixRotationX(&Rx, p);
D3DXMatrixRotationY(&Ry, y);
R = Rz * Rx * Ry;
NewV.x = (v.x*R._11)+(v.y*R._21)+(v.z*R._31);
NewV.y = (v.x*R._12)+(v.y*R._22)+(v.z*R._32);
NewV.z = (v.x*R._13)+(v.y*R._23)+(v.z*R._33);
return NewV;
}
D3DXVECTOR3 RotatePbM(D3DXVECTOR3 v, MD3Tag *tag)
{
D3DXVECTOR3 NewV;
NewV.x = (v.x*tag->rotation[0][0])+(v.y*tag->rotation[0][1])+(v.z*tag->rotation[0][2]);
NewV.y = (v.x*tag->rotation[1][0])+(v.y*tag->rotation[1][1])+(v.z*tag->rotation[1][2]);
NewV.z = (v.x*tag->rotation[2][0])+(v.y*tag->rotation[2][1])+(v.z*tag->rotation[2][2]);
return NewV;
}
Are those functions right, and is the order of operations performed on the vector correct?