Local/World transformations and openGL equivalents

Started by
4 comments, last by ThunderSoul 16 years, 10 months ago
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...
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.
That's tough... How, then, would I rotate 2 spheres, say 1 clockwise and the other counterclockwise, independant of each other?
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.

Previously "Krohm"

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 valueD3DXMATRIX matRotateY;    // a matrix to store the rotation for each triangleD3DXMatrixRotationY(&matRotateY, index);    // the rotation matrixd3ddev->SetTransform(D3DTS_WORLD, &(matRotateY));    // set the world transform// Draw first sphere...static float index2 = 0.0f; index2-=0.03f;    // an ever-decreasing float valueD3DXMATRIX matMove;D3DXMatrixTranslation(&matMove, 10.0f, 0.0f, 0.0f); // x, y, z float valuesD3DXMatrixRotationY(&matRotateY, index2);     // the rotation matrixd3ddev->SetTransform(D3DTS_WORLD, &(matRotateY*matMove));    // set the world transform (rotates then moves the object)// Draw second sphere...
Thank you, you guys help a lot ^_^

This topic is closed to new replies.

Advertisement