Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
fryzoy
Sep 21, 2005
What.

FBz posted:

I've decided to dive back into XNA again and mess about with it again, but this time in 3D.

I have a spaceship (one of the models you are given with the SDK) and I have it moving around in 3D space quite well. You point it in any direction (up/down/left/right/back/fourth etc.) and it flies along that vector, I've implemented quat’s for proper rotations and all that jazz. What I'd like to do is add proper acceleration. At the moment it accelerates along the vector until it hits full speed, but when you turn it just flies off in that direction instantly, which doesn't really happen in the real world. What I'd like is smoother turning and acceleration, ie. It flies off in one direction then when you turn somewhere else and hit the thrusters again instead of insta-accelerating it gradually gets into its new vector. I have implemented something that half does this but it's totally wrong as it doesn't work 100% of the time. I've tried looking up how to do this but I am blinded by science and formulas and I am not sure how to implement it at all.

What I have so far is:
A vector in which the ship is currently moving (momentum I guess)
A Vector which the ship is pointing in
Current thrust level (could be zero, leaving the ship to 'float' on it's current vector)

I am guessing I need to go from the momentum vector to the new direction vector based on the amount of thrust, but I don't know how.

If someone can tell me how to implement acceleration or point me to a good tutorial (I've looked at loads but most are either 2D and I can't figure out how to translate that to 3D, or they just ramble on about something quite unhelpful) I'd be most grateful. I think I really need an example or it spelt out in English with little words that I can understand :)

As long as I am not totally misunderstanding you, you should be fine with adding the product of the direction vector (normalized) and thrust scalar to your momentum vector.
So let's say you have D, your direction vector, V, your momentum vector and a your accelleration force scalar, you'd then do D = D + V * a.

Adbot
ADBOT LOVES YOU

fryzoy
Sep 21, 2005
What.

TSDK posted:

Nope, D is the constant here and it's V you want to update. For simple newtonian mechanics using euler integration:

D - Ship's forward vector
V - Ship's current velocity
F - Thrust
m - Mass of ship
dt - Timestep

a = F/m
V' = V + D*a/dt

Oh yeah that was retarded; I mean that.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply