Jump to content
  • Advertisement
Sign in to follow this  
TFS_Waldo

C# MDX :: Rotating a Triangle on User Input?

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

Hey, everyone. I've been learning more about Managed DX using C#. Now, I have set up the world, view, and projection matrices. And I drew a simple colored triangle. Everything works well. Now, I would like to get user input from arrow keys, and rotate the triangle. I have 3 float values (x, y, z of course =P). I use the "Form1_OnKeyDown" function to get user input for arrow keys, and update x, y, and z. Now, how do I rotate the triangle? I know I have to use matrices, but how/what do I call in order to rotate the triangle/scene by x, y, and z? Thanks in advance, Matt U. BTW, this is VS .NET 2005. =)

Share this post


Link to post
Share on other sites
Advertisement
Well, if you want to just rotate the triangle around X, Y, or Z axis, then you just need to write:

device.Transform.World = Matrix.Rotation*(angle);

Where the * represents any of the three axis (X, Y, or Z) and the angle is a float value specifying how much you want to rotate.

If you want to rotate around an axis that's not X, Y or Z, you'll be using:

device.Transform.World = Matrix.RotationAxis(axisVector, angle);

Where axisVector is a Vector3 object that specifies the axis of rotation and angle is the same as before.

Hope that helps get you started.

-AJ

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.

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

Sign me up!