Simple question for you gurus!

Started by
3 comments, last by ibolcina 22 years, 2 months ago
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
Advertisement
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.

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

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.
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
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

This topic is closed to new replies.

Advertisement