Jump to content
  • Advertisement
Sign in to follow this  
BkoChan

Free moving objects, my head hurts :(

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

Hi, I'm fairly new to game programing and I'm having trouble understanding something. I made a simple program which shows our solar system, with planets orbiting the sun. This wasn't too difficult, since each planet has a fixed point of rotation (the sun). Well now I'm trying to create a space ship which can be flown around the planets, I don't want the camera to move with the ship. The ship must be able move in a straight line forwards or backwards (ie. no need for strafing) and turn to face any direction. I guess to achieve this I need to figure out the new coordinates of the ship after every time it has moved (so that it doesn't end up pivoting around the same point) but I haven't the first idea where to start with this. Ive been Googling it for ages now :( Could someone throw me a bone??

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Zahlman
Euler integration.


And linear motion. More specifically in pseudo-code (I split up velocity into a vector component and a scalar component for simplicity):


// current position and orientation of ship in global frame
vec3 origin, heading;
// current speed of ship in units/seconds
float speed;
// time passed between two consecutive frames of animation in seconds
float dt;

origin += heading * speed * dt;
// re-orient heading vector (and potentially normalize), alter speed, etc.
SteerShip();
// render ship at its new origin, looking at its new heading
RenderShip();
// and loop


EDIT: The link at the top is just me googling for linear motion. The term is correct, but there most certainly are sources that explain these equations better.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!