Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Funkymunky

MD3

This topic is 5273 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
I''m not sure if that code is right, but I know what you could check it against. Look at the MD3Viewer at this site. It uses DX8, I think.

Share this post


Link to post
Share on other sites
Ok, so now what i''m wondering is what''s the best way to handle doing all these rotations? Do I want to save the world matrix, then change it for each piece that I have to rotate to draw? Or do I want to pre-rotate the vertices mathematically and store them how I want them?

Anyone at all farmiliar with MD3s?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!