I'm working on a space game where the player controls a spaceship, and I'm having some difficulty getting the math right.
What I'd like is a spaceship starting at the origin of the world with up in the positive Y, and forward into the screen, and the ability to move the ship forward, backward, left/right (strafe), turn to the right and left (rotation on the Y axis), and nose up and down (rotation on the X axis).
All this is working, at least to start. However, I'm having difficulty, suppose I start my game, and turn the ship to the left by 45 degrees so I'm still on the Z plane have neither angle up nor down, and simply am pointing off between negative Z (away from the screen), and negative X. Suppose the ship is given some forward acceleration, and then stopped say 50 units away from the origin.
Note: Up to this point, I have this working, the following is where it gets tricky.
Now suppose the ship is put nose down 45 degrees, and another 45 degrees to the left, so I'm facing directly in the negative X with my nose now pointing in the half-way between negative Y and negative X. Now, suppose I give the ship some velocity in the forward direction... Where should it end up?
So put another way, given a ship at an arbitrary 3D point, (x, y, z), a heading/direction, a velocity and a time(delta), how do I find the point where the ship should end up? Also, how should the heading/direction be stored?
Along the same lines, currently, when a user presses keys for rotating the ship on one of the axes, I increment a value, and rotate the ship on the corresponding axis. This works, and looks right, but I'm having trouble keeping track of where "heading/direction" is. How should this be recorded? Should I have three vectors for each axis or something?
I would greatly appreciate some detailed explanation or discussion of this. I've browsed and found some useful vector/matrix math stuff that's been helpful, but not quite enough to get me where I'm going. Any insight you could provide is welcome. Thanks in advance.