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;
matrix rotation ?
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.
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
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
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement