Advertisement

from rotation to translation..

Started by September 12, 2001 10:08 AM
3 comments, last by Rapsey 23 years, 5 months ago
ok so im making a 3d space fighter type game. Rotating the camera with the object isnt a problem, but how do you set it so that the ship starts moving relative to the rotation? If its pointing upwards it goes up if down it goes down...? the rotation part is simple i just use a rotation vector that stores the angles by wich the camera and the ship are turned. When the player pushes some button the appropriate angle of an axis(x,y,z) is incremented/decremented.
Don''t rotate the object independently of its direction. It should go where it''s pointed, which is most easily accomplished by maintaining a direction vector which is rotated along with the object''s polygons (using the same matrix).
Advertisement
yeah but how do you maintain a direction vector? if you rotate the object by a number of radians you have to increment/decrement the apropriate x,y and z value, how do you calculate that value?

Edited by - Rapsey on September 12, 2001 11:36:46 AM

There''s a couple of ways to maintain a direction vector.

One is to get your high school trigonometry book out and compute the vector using sin and cos.

One way is to do all of your vector math in polar coordinates.

The sneaky way is to rotate some ''direction'' object along with your ship model. You could, for example, point a surface normal along the ship''s direction vector, then see where it''s pointing after you rotate the ship. The same sort of thing will work by setting up a point or a small triangle that you don''t render and read back it''s coordinates. ''Course, this may or may not work depending on your engine design.
a realistic way to model ship movement only needs two actual types of rotation: roll(z rotation) and pitch (perceived x rotation in relation to the plane of the ship).

in this scheme, the roll is your actual z rotation angle(assuming 0,0,1 is the forward vector), and does not affect your direction vector. the pitching action changes the x and y rotation based on the value of the roll angle. the x rotation is scaled by cos(roll) and the y rotation is scaled by sin(roll)

Get off my lawn!

This topic is closed to new replies.

Advertisement