Public Group

# matrix rotation ?

This topic is 3083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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 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.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633669
• Total Posts
3013255
×