Archived

This topic is now archived and is closed to further replies.

Simple question for you gurus!

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

I have an airplane in world space. How to represent its orientation? How to rotate it around its axes? Iam using directx8. I have seen many examples where there is a class representing an 3d object. They also have methods like rotate, but this methods allways apply to world axes! I need it to rotate around its own axes! bye and thanx ivan bolèina

Share this post


Link to post
Share on other sites
I''ve been watching the questions for a long time, and you are the lucky today.
You must define vectors representing the axis of your object in their class. You also must make functions that converts the rotation on the objects axis onto rotation on the world axis.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes, but how?

Since this is used in most games, I hope there is a common well known way of doing this. Any ideas?

bye,ivan

Share this post


Link to post
Share on other sites

1-Rotate it by it''s rotation values.
2-Rotate it by world-space values.
3-Translate to it''s position in world-space.

To represent all of these..

struct POSROT {
D3DVECTOR pos; // Position, World-Space
D3DVECTOR srot; // Rotation, Self-Space
D3DVECTOR wrot; // Rotation, World-Space
// Simple, but sometimes difficult to use for physics.
}

or

struct OBJPOS {
D3DVECTOR center; // Position, World-Space
D3DVECTOR up; // 1 unit "up" from position
D3DVECTOR fw; // 1 unit "forward" from position
// Use those last two for an "OrientToAxes" function.
}

Using either of those, you can get what you need.

Share this post


Link to post
Share on other sites
I think you might be a bit confused on the axis. A world transformation always orients an object around it''s own axis in regards to rotation.
Using D3DXMatrixRotationYawPitchRoll is perfect for defining rotational values, which using D3DXMatrixTranslation will work for translation values. Make sure to construct the world transformation matrix in this order: scale * X rotation * Y rotation * Z rotation * translation (or Scale * rotation * translation).

Jim Adams

Share this post


Link to post
Share on other sites