PDA

View Full Version : Moving forward



Blain
01-23-2009, 05:54 PM
Say i have 3 vectors (Left, Up and In)representing a rotation matrix that is my spaceship orientation. And a vector (Pos) that represents position in 3d space.

How do i adjust the position vector to move the spaceship forward along the local z vector?

I tried this code but it doesn't work properly:

//Move ship
Vector v(In.x, In.y, In.z);
v.Scale(flight_speed);
Pos += v;

zeoverlord
01-23-2009, 06:35 PM
On a first glance it looks ok, what doesn't work? how does it act improperly?

Blain
01-23-2009, 07:08 PM
The ship just seems to move toward the origin. It doesn't fly forward.

James A.
01-23-2009, 07:27 PM
Maybe you could try drawing 3 GL_LINES from Pos to Left, Up, and In (in red green and blue) to make sure that In actually faces the direction you expect it to.

If you have already done this, then some more of your source might be helpful.

Blain
01-23-2009, 08:25 PM
I solved it. That method does work, after i extract the "In" vector from the matrix i put it in, it works.

/me scratches his head. lol