Curandero

04-15-2004, 02:18 PM

I'm having a problem, and as a newbie, have fled to the forums. :)

I'm learning OpenGL by writing a game: 3D asteroids clone. So, anyway, I need to apply the ship rotation matrix to an accelleration vector because the thruster has to be oriented properly.

I've tried a lot of things. Most recently, I did a glGet for the matrix and tried to do the transformation manually.

Since the thrust is only in Z, I thought I could just do a manual matrix multiplication pretty easily, but it doesn't seem to work. It seems more irratic as the number of transformations on the shipRotMatrix grow.

I hope I've explained this well enough. Any advice will be appreciated.

Thanks,

Matt

/* shipRotMatrix is the from glGet with only the ship's rotations applied.

*/

/* Use orientation to fire thruster */

if (thrusterOn)

{

acc_vector[0] = THRUSTER_STRENGTH * shipRotMatrix[2];

acc_vector[1] = THRUSTER_STRENGTH * shipRotMatrix[6];

acc_vector[2] = THRUSTER_STRENGTH * shipRotMatrix[10];

}

velX += acc_vector[0];

velY += acc_vector[1];

velZ += acc_vector[2];

tranX += velX;

tranY += velY;

tranZ += velZ;

}

I'm learning OpenGL by writing a game: 3D asteroids clone. So, anyway, I need to apply the ship rotation matrix to an accelleration vector because the thruster has to be oriented properly.

I've tried a lot of things. Most recently, I did a glGet for the matrix and tried to do the transformation manually.

Since the thrust is only in Z, I thought I could just do a manual matrix multiplication pretty easily, but it doesn't seem to work. It seems more irratic as the number of transformations on the shipRotMatrix grow.

I hope I've explained this well enough. Any advice will be appreciated.

Thanks,

Matt

/* shipRotMatrix is the from glGet with only the ship's rotations applied.

*/

/* Use orientation to fire thruster */

if (thrusterOn)

{

acc_vector[0] = THRUSTER_STRENGTH * shipRotMatrix[2];

acc_vector[1] = THRUSTER_STRENGTH * shipRotMatrix[6];

acc_vector[2] = THRUSTER_STRENGTH * shipRotMatrix[10];

}

velX += acc_vector[0];

velY += acc_vector[1];

velZ += acc_vector[2];

tranX += velX;

tranY += velY;

tranZ += velZ;

}