Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

matrix rotation ?

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

the code below will rotate an object in its local space , ie. it will rotate relitive to it present rotations, like a plane..

but how do i rotate relitive to world space , please




D3DXVECTOR3 rotLocal;

D3DXMatrixRotationX(&x, (rotLocal.x * 0.0174532925));
D3DXMatrixRotationY(&y, (rotLocal.y * 0.0174532925));
D3DXMatrixRotationZ(&z, (rotLocal.z * 0.0174532925));

D3DXMATRIX matrix = x * y * z;

Share this post


Link to post
Share on other sites
Advertisement
The code below isn't using any particular space. All you have done is construct a rotation matrix. If you set this as your world transform (with device->SetTransform()) and then draw your model, your models vertices will be transformed from local space to world space.

Share this post


Link to post
Share on other sites
with the code above i can control an mesh like a plane

if i use D3DXMatrixRotationX(&x, (rotLocal.x * 0.0174532925));

then the plane will tilt back or forward like a real plane .



but how do i do it so it rotates forwards relitive to the screen not the objetc/mesh

Share this post


Link to post
Share on other sites
Could you describe a little more clearly how you want the plane to rotate? "rel[a]tive to the screen" isn't quite descriptive enough.

Expending on what Dave mentioned, how the rotation is applied will depend on how you construct your world matrix - the order of the matrices involved.

E.g. (this applies to DirectX. OpenGL order is the reverse):

world = translate_plane * rotate_plane;

will rotate the plane locally, then translate it to some location.

world = rotate_plane * translate_plane;

will translate the plane to some location, then rotate it with respect to the translated position.

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!