Jump to content
  • Advertisement
Sign in to follow this  
ThunderSoul

OpenGL Local/World transformations and openGL equivalents

This topic is 4121 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 have another question based on DirectX. In openGL, I can local transform an object based on its axes, or I can world transform an object based on the world axes. How would I go about doing so in DirectX? Also, what is the equivalent of glPushMatrix() and glPopMatrix() in DirectX? Thank you...

Share this post


Link to post
Share on other sites
Advertisement
Well I've been using Direct X for a while now and I'm 95% sure there simply isn't one. I ended up making my own. Wasn't so bad a process.

Share this post


Link to post
Share on other sites
That's tough... How, then, would I rotate 2 spheres, say 1 clockwise and the other counterclockwise, independant of each other?

Share this post


Link to post
Share on other sites
You must manage the matrices yourself. Roll your own matrix stack or use D3DX MatrixStack, then you'll have just the same push-pop-like semantics.

Share this post


Link to post
Share on other sites
Quote:
Original post by ThunderSoul
That's tough... How, then, would I rotate 2 spheres, say 1 clockwise and the other counterclockwise, independant of each other?

Something like this would work for two objects rotating opposite directions.

static float index = 0.0f; index+=0.03f; // an ever-increasing float value
D3DXMATRIX matRotateY; // a matrix to store the rotation for each triangle
D3DXMatrixRotationY(&matRotateY, index); // the rotation matrix
d3ddev->SetTransform(D3DTS_WORLD, &(matRotateY)); // set the world transform
// Draw first sphere
...
static float index2 = 0.0f; index2-=0.03f; // an ever-decreasing float value
D3DXMATRIX matMove;
D3DXMatrixTranslation(&matMove, 10.0f, 0.0f, 0.0f); // x, y, z float values
D3DXMatrixRotationY(&matRotateY, index2); // the rotation matrix
d3ddev->SetTransform(D3DTS_WORLD, &(matRotateY*matMove)); // set the world transform (rotates then moves the object)
// Draw second sphere
...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!