   Md3 Tags (rotation)
  Hi all,i have a problem using md3 models in my game. The model rendering works, but the linked models (upper and head) dont get the right rotation for the animations (Position works). They always have the "standard" rotation. here is the code i use to render one model:void RenderSkeleton(MD3Model *mod, LPDIRECT3DDEVICE9 device){int i;float pol;MD3Model *link;D3DVECTOR position, nextposition;D3DXMATRIX m, matrix, nextmatrix;D3DXVECTOR4 quat1, quat2;//static spMatrix4x4 oldmat = spMatrix4x4::GetIdentityMatrix();static D3DXMATRIX oldmat;D3DXMatrixIdentity(&oldmat);D3DMATRIX world;device->GetTransform(D3DTS_WORLD, &world);//ConvertToSPMatrix(world, oldmat);oldmat= world;// Render this modelmod->Render();// Render this model's linksfor (i=0; i < mod->Header.numTags; i++){link = mod->Links;if (link){pol = mod->pol;// interpolation factor// Get this frame's positionposition.x = mod->Tags[mod->Frame * mod->Header.numTags + i].position[0];position.y = mod->Tags[mod->Frame * mod->Header.numTags + i].position[1];position.z = mod->Tags[mod->Frame * mod->Header.numTags + i].position[2];// Get this frame's rotation matrix (in row major form)for (int row=0; row < 4; row++)for (int col=0; col < 4; col++)matrix.m[row][col] = mod->Tags[mod->Frame * mod->Header.numTags + i].rotation[col][row];// Get the next frame's positionnextposition.x = mod->Tags[mod->NextFrame * mod->Header.numTags + i].position[0];nextposition.y = mod->Tags[mod->NextFrame * mod->Header.numTags + i].position[1];nextposition.z = mod->Tags[mod->NextFrame * mod->Header.numTags + i].position[2];// Get the next frame's rotation matrix (in row major form)for (row=0; row < 4; row++)for (int col=0; col < 4; col++)nextmatrix.m[row][col] = mod->Tags[mod->NextFrame * mod->Header.numTags + i].rotation[col][row];// Convert the matrices to quaternionsQuatFromMatrix(matrix, quat1);QuatFromMatrix(nextmatrix, quat2);// Do a slerp between the quaternionsD3DXVECTOR4 res = QuatSlerp(quat1, quat2, pol);// Convert the interpolated quaternion into a matrixD3DXMATRIX fm;D3DXMatrixIdentity(&fm);MatrixFromQuat(res, fm);m = fm;// Interpolate the frame positions and store it in the matrixm.m[3][0] = SP_LERP(pol, position.x, nextposition.x);m.m[3][1] = SP_LERP(pol, position.y, nextposition.y);m.m[3][2] = SP_LERP(pol, position.z, nextposition.z);m.m[3][3] = 1.0f;D3DXMATRIX d3dmat;d3dmat =m * oldmat;// multiply the matrix by the previous transformation matrixdevice->SetTransform(D3DTS_WORLD, &d3dmat);oldmat = m;// store this link's matrix// Render the other linksRenderSkeleton(link, device);// clear the stored matrix//oldmat.SetIdentity();D3DXMatrixIdentity(&oldmat);}}}(thx to jyk)I had to search for the function QuatFromMatrix and MatrixFromQuat, so they could be wrong too.Can you see any mistakes here??? (A Link to a working DirectX9 Md3 Example/Tutorial would also be very useful)[Edited by - TSCrusader on February 9, 2006 9:52:14 AM]
Quote:(sorry, but i dont know how to make such a code window)The tags are [ source ][ /source ] (without the spaces).   ;  nobody here who knows a working dx9 md3 sample???and nobody who can find the mistake? :(   