• Advertisement
Sign in to follow this  

world transformations & rotation matrices

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

howdy, so i've created a little scene w/ directX 9.0c & c# i have two objects on the screen, two triangles, and i've been reading about rotation and i see from the beginner examples that they apply a rotation Matrix to the device.Transform.World -however, this makes both objects in my scene rotate...and, as exciting as that is, i want to get just 1 of those triangles rotating -so i started thinking, haha yup, actually thinking, and searching for more examples of rotation and i found a c++ example that mentioned the following during a rotation matrix implementation
Quote:
// Set the world matrix // By doing this we apply our rotated matrix to anything we render until // we set the world matrix to something different g3D->setWorldMatrix(&matrix);
-how would you "set the world matrix to something different" ? -would the (best?)way to get 1 triangle to rotate and not the other be to make a copy of 1 of the triangles vertices, apply a rotation matrix to that triangle's vertices, and render the new transformed triangle and perform no rotation to the Transform.World ???

Share this post


Link to post
Share on other sites
Advertisement
Create a second matrix (or reuse the first one) and set it to Identity, D3DXMatrixIdentity() in C++, not sure what it's called in C# (check the DX documentation). Then world transform to the identity before drawing the triangle you don't want rotated.

Share this post


Link to post
Share on other sites
When you set up a world matrix for rendering, you don't set it once and for all. If you have 300 shapes to render, you're free to set up 300 different world matrices. I'm not sure of the syntax of C#, so I'll use pseudocode, sort of:

MATRIX MatrixA;
SetUpMatrixA();
g3D->SetWorldMatrix(&MatrixA);
DrawStuff();

MATRIX MatrixB;
SetUpMatrixB();
g3D->SetWorldMatrix(&MatrixB);
DrawMoreStuff();
DrawEvenMoreStuff();

MATRIX MatrixC;
...

Share this post


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

  • Advertisement