Archived

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

Dean Johnson

Problems with making my Ship fly correctly

Recommended Posts

First let me explain what I am working on. I have a 3d engine that uses frames. Each frame has a position represented by (float x, float y, float z), a velocity represented by (float x, float y, float z), also the yaw, pitch and roll of the frame all represented by floats. The frames do translate down to the other frames. Now my question. How should I set my velocity when I don’t know the amount to add to each of the X, Y, and Z floats? If I have not added and Yaw, Pitch or Roll then just setting the Z velocity works. But how do I calculate the velocity when I change the Yaw Pitch and Roll. Thanks

Share this post


Link to post
Share on other sites
sorry,
I read the book "Zen to Direct3d programming". In the book it uses frames to move objects around your world. You can add frames to other frames and so on. My problem is when I try to both move and rotate my ship in its frame. I can get it to Yaw, Pitch and roll correctly but I don’t know what to set my velocity to get it to move. So I tried to make another frame to handle the movement but then the two frames get off and the farther away the ship moves the more drastic the reaction to the yaw, pitch and roll. So how should I set the velocity? If there is no yaw pitch or roll then the velocity can just be in the z direction but how do I calculate X, Y and Z velocity when the ship has been rotated on its axes. I am guessing I could use the yaw pitch and roll to calculate the ship orientation but I just don’t know how to do that.
Thanks again

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you have access to the matrix used for rendering then it''s easy-peasy to extract (normalised) vectors for the direction the ship is facing (as well as an "upwards" and a "perpendicular" vector).
If the ship is facing along its own z-axis then the facing vector will be the third column (or row, depends on the handedness of your coord system) of the rotation matrix. The up and perps are the other rows/columns.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The model rotation matrix you build from the Euler (pr: "Oiler" angles can be thought of as 3 row or column matrices. If the model "points" in the direction of the z-axis, then the third row of the matrix (or column, I don''t know D3D handedness; it will be one or the other and the opposite of the OGL way - which I''m also not familiar with!) will be the transformed z-axis after the rotation. Which is the way your ship is pointing. If the y-axis points "up" through the model, the 2nd row (or column) will be that transformed by the rotation. The first row or column will be the perp direction.

Hope that helped more...

Share this post


Link to post
Share on other sites