#### Archived

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

# Problems with making my Ship fly correctly

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

## 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 on other sites
don''t use Yaw, Pitch and Roll ... just use the velocity as a vector and rotate it. that''s the way i should have do.

##### Share on other sites
Could someone still help me

##### Share on other sites
I guess people just don''t understand what you mean, try to rephrase your question

##### 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 on other sites
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 on other sites
All right I can get the matrix of the Ship but I don’t quite understand what all you are saying. Sorry but could you explain a little more? Also I am using the D3Dmatrix.
Thanks

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

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633735
• Total Posts
3013596
×