MikeS

08-20-2000, 11:20 PM

I am writing a flight simulator which has the ship viewed in 3rd person 10 units form the camera.Both are looking down the Z axis.

When the camera is rotated around the Y axis I caculate the ships XYZ coords with the folowing equation.

sY = (float)(-sin(DEGTORAD(camry)))*10;

sX = (float)(-sin(DEGTORAD(camrx)))*10;

sZ = (float)(-cos(DEGTORAD(camrx)))*10;

shipz = sZ - camz;

shipx = sX - camx;

shipy = sY - camy;

When the camera is rotated around the X axis I caculate the ships XYZ coords with the folowing equation.

sY = (float)(-sin(DEGTORAD(camry)))*10;

sX = (float)(-sin(DEGTORAD(camrx)))*10;

sZ = (float)(cos(DEGTORAD(camry)))*10;

shipz = sZ - camz;

shipx = sX - camx;

shipy = sY - camy;

The problem I having is how do I get the two equations to work together, as they both calculate different sZ values for the plane.

Thanks for any help.

When the camera is rotated around the Y axis I caculate the ships XYZ coords with the folowing equation.

sY = (float)(-sin(DEGTORAD(camry)))*10;

sX = (float)(-sin(DEGTORAD(camrx)))*10;

sZ = (float)(-cos(DEGTORAD(camrx)))*10;

shipz = sZ - camz;

shipx = sX - camx;

shipy = sY - camy;

When the camera is rotated around the X axis I caculate the ships XYZ coords with the folowing equation.

sY = (float)(-sin(DEGTORAD(camry)))*10;

sX = (float)(-sin(DEGTORAD(camrx)))*10;

sZ = (float)(cos(DEGTORAD(camry)))*10;

shipz = sZ - camz;

shipx = sX - camx;

shipy = sY - camy;

The problem I having is how do I get the two equations to work together, as they both calculate different sZ values for the plane.

Thanks for any help.