Jump to content
  • Advertisement

Archived

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

Dotren

rotation and translation while keeping position?

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

Ok, I''ve got my 3D spaceship rotating according to keyboard input on everything except roll. What I''d like to be able to do is have the + and - control thrust and have my ship move along forward or backward depending on thrust. The problem is I''d also like to somehow keep track of the object''s position in X, Y, and Z. Anyone know of any good tutorials that may help out with this? Thanks, Dotren

Share this post


Link to post
Share on other sites
Advertisement
Just store the x,y,z coordinates?

Simply:


struct MyShip
{
float v[3]; // the x,y,z coordinates as an array
float dir[3]; // normalized ''forward'' vector

int shield;
...
etc.

};

void TestControls()
{
if( pressed(''+'') )
{
v[0] = v[0] + dir[0];
v[1] = v[1] + dir[1];
v[2] = v[2] + dir[2];
}

}

etc.

Share this post


Link to post
Share on other sites
Well the problem I''m running into is how do I know which coordinate axis to add too and how much. If my rotation is about 20 degrees from 0, for example, on the X, Y plane only I''d be adding more to X than I would be Y since the line would be traveling horizontally faster than it would be rising. I can determine that I have to add to both X and Y but how do I get the values to add?

Dotren

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!