Hi all,

I'm writing a 3D space game. I have Vector3 to represent the position, velocity and angular velocity, and a Quaternion to represent the orientation of the spaceship.

Now I want to rotate the ship when I press the directional button, say turn it left when press left arrow key and turn it up when press the up arrow key. I have Vector3 to represent the force, torque etc.

I also have a method named addForceAtPoint(Vector3 force, Vector3 position) so that I can add a force at particular point, say add it on the right wing to turn it left. The position can be converted to the global coordinate no problem, but it's the force that bothers me. Say I call this:
Code:
//add a force on the z direction(initially the ship is moving in the positive z direction)
// at the point (30,0,0) - a point that is relative to the body, not in the global
// coordinate, it will be converted in the body of the method.

addForceAtPoint(Vector3(0,0,50), Vector3(30,0,0));
Now I can use the same point over and over again because it can be converted to the global coordinate every time, but I can't do the same to the force as it can't always be in the z direction. The force should always be in the direction of the spaceship. That's what I don't know how to do.

If any of you kind souls ever encountered this problem or have experience on 3D rotation problem, I will much appreciate it if you can share a solution.

Many thanks!