Jump to content
  • Advertisement

Archived

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

3do files' hierarchies

This topic is 5151 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

Hello, I've been writing a loader for the 3do file format (http://www.codealliance.ca/Docs/jediknight/jk_specs/3do.htm) and I've successfully read all the data into my app, but am having some trouble finishing the job with the frame hierarchy. For each node there are nine values for the rotation/position of the mesh: x, y, z, yaw, pitch, roll, pivotx, pivoty, pivotz. Does anyone know how to use these values to find the final position (or matrix) to move the mesh by? [edited by - ms291052 on April 11, 2004 7:09:50 PM]

Share this post


Link to post
Share on other sites
Advertisement


try something like this:

glTranslate3f(x,y,z);
glTranslate3f(pivx,pivy,pivz);
glRotatef(yaw,0,1,0);
glRotatef(pitch,1,0,0);
glRotatef(roll,0,0,1);
glTranslate3f(-pivx, -pivy, -pivz);

You may have to reorder the rotates (or all of it).

Share this post


Link to post
Share on other sites
Thank you for your reply! Unfortunatly, that code doesn''t work for me. I''ve found (through experimentation and trial and error) that the order is something like

glTranslate3f(pivotx, pivoty, pivotz);
glRotatef(yaw,0,1,0);
glRotatef(pitch,1,0,0);
glRotatef(roll,0,0,1);
glTranslate3f(x, y, z);


However, that looks a bit skewed for some reason. Here are some example pictures taken of my renditions of ky.3do.

glTranslate3f(pivotx, pivoty, pivotz);
glTranslate3f(x, y, z);



glTranslate3f(pivotx, pivoty, pivotz);
glRotatef(yaw,0,1,0);
glRotatef(pitch,1,0,0);
glRotatef(roll,0,0,1);
glTranslate3f(x, y, z);




And finally the two pictures of ky.3do rendered correctly (not with my app, obviously)

Share this post


Link to post
Share on other sites
Ok guys, I found a bit of code at some obscure place on the net. I'm just now having trouble converting this code from OpenGL to DirectX.

void Model::Draw()
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();

glTranslatef(x, y, z);
glRotatef(fYaw , 0, 0, 1);
glRotatef(fPitch, 1, 0, 0);
glRotatef(fRoll, 0, 1, 0);

glPushMatrix();
glTranslatef(pivotx, pivoty, pivotz);
//Draw here

glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}


My thinking is that I should just do this in DX


void Model::Draw()
{
D3DXMATRIX mRotation, mTranslation, mPivot, mWorld;
D3DXMatrixRotationYawPitchRoll(&mRotation, fYaw, fPitch, fRoll);
D3DXMatrixTranslation(&mTranslation, x, y, z);
D3DXMatrixTranslation(&mPivot, pivotx, pivoty, pivotz);
mWorld = mPivot * mRotation * mTranslation;
pd3dDevice->SetTransform(D3DTS_WORLD, &mWorld);
//Draw here

}


Can anyone please validate this conversion?

Thanks a bunch!
ms

[edited by - ms291052 on April 12, 2004 9:11:46 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!