Trying to setup up my view matrix to my spaceship problem (eye,at,up)

Started by
0 comments, last by Zakwayda 19 years ago
Hi i'm trying to setup my view matrix to my 3d space ship. eg the eye point, at and up vectors. My spaceship has its own x-axis, y-axis and z-axis, that rotate with the ship, so if the ship rotates on it's y-axis, the ship's x and z axises will rotate aswell. eg Red =xAxis, Green=yAxis and Blue = zAxis, The axis in the middle of the screen is the world x,y,z at origin, and the triangular object with the axis is the ship, at which it's axises are currently pointing. With the blue zaxis line pointing to the front of the ship. and green yAxis pointing up for the ship. The axises origin is at the ship's midpoint(of its vertices). When I view my ship from afar and roll, pitch and yaw on its midpoint, it moves as it should. But when I try and set the view to be as the first person of the ship ie: eye = shipMidPoint; at = shipZAxis; //as zAxis always points in front of the ship up = shipYAxis; // as yAxis always points up for the ship I get weird problems and rolling, yawing and pitching. eg: pitching - xaxis When it hits about 180 degrees, the screen flips, which shouldn't happen because I have set the ship's yAxis as the up vector. yawing It seems to rotate to the side then the screen rolls like 45 degrees left and right while rotating sideways rolling it rolls about 45 degrees and then rolls back and fourth, rocking similar to the rolling in the yaw. Any ideas on what is happening? I know my rotating code is fine, because Ive tested it by looking at the ship from third person view, i just can't figure out why its acting so strange. Although this is my first attempt at first-person view or a spaceship sim at that. Thanks
Advertisement
One quick thought. If you're using a function such as gluLookAt(), then:

at = shipZAxis;

Should probably be:

at = eye + shipZAxis;

This topic is closed to new replies.

Advertisement