Hey guys, just curious, I am trying to make a "space flight" code, and having a small glitch. When I roll say 45 degrees, then tilt 45 degrees, the pan and tilt don't reflect the roll they stay static at 0 roll, so the camera moves at a diagonal. If I roll 90 degrees, the pan becomes tilt and the tilt becomes pan basically. I could write a complex formula to accomodate for this, but there has got to be a simpler way, anybody know a way to "reset" the roll axis to 0 after rolling so that pan and tilt reflect the roll?

Code:
action Shuttle()
{


// if the entity has a non standard size, make sure that the bounding box does not drag along the floor
if ((my.eflags&FAT) && (my.eflags&NARROW)) // when FAT+NARROW are both set
my.min_z *= 0.5;

var speed_down = 0; // downward speed by gravity
var anim_percent = 0; // animation percentage
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex

while (1)
{


my.pan += 1*(key_a-key_d)*time_step; //Yaw Using A and D
my.tilt += 1*(key_w-key_s)*time_step; //Pitch Using W and S
my.roll += 3*(key_q-key_e)*time_step; //Roll Using Q and E
// Forward and Reverse based on R and F

var dist_ahead = 5*(key_r-key_f)*time_step;
dist_ahead = sign(dist_ahead)*(abs(dist_ahead)); // adapt the speed on slopes
c_move(me,vector(dist_ahead,0,0),vector(0,0,0),IGNORE_PASSABLE | GLIDE); // move the player

vec_set(camera1.x,my.x); // move the camera together with the player entity
vec_set(camera1.z,my.z);
vec_set(camera1.pan,my.pan);
vec_set(camera2.x,my.x); // Right Window
vec_set(camera2.z,my.z);
camera2.pan=my.pan-90;
camera2.roll = camera1.tilt; //The tilt and roll are intentionally switched to give the illusion of
camera2.tilt = -1*my.roll; //it being a window (when the front of the ship lifts, the side view
//should roll instead of tilt)

wait(1);
}

Last edited by Sekse; 06/05/11 18:50.