Original Post
Heres my problem. I rotate the camera up and down, left and right using large angles many times, but when I return my camera back to my original angles the test entity is tilted or distorted.
The problem is I did not tilt the camera. I also notice that when I when I move the test entity to the center of my screen the rotation angles appear to be off. That is the rotation angles don''t return to my original values. Is there a way to do some kind of maintenace on the matrix to correct this proplem.
Anybody have a solution to this problem.
Here are some sample code of the camera setup:
void PlayerCamera(PR_REAL xm, PR_REAL ym, PR_REAL zm, PR_REAL pitch_angle ,
PR_REAL yaw_angle, PR_REAL roll_angle, PR_REAL frx, PR_REAL fry, PR_DWORD move_count)
{
PR_REAL txm, tym, tzm;
PR_REAL tcx, tcy, tcz;
PR_REAL tfrx, tfry;
PR_REAL vx1, vx2, vx3;
PR_REAL vy1, vy2, vy3;
PR_REAL vz1, vz2, vz3;
txm = xm * move_count;
tym = ym * move_count;
tzm = zm * move_count;
tcx = pitch_angle * move_count;
tcy = yaw_angle * move_count;
tcz = roll_angle * move_count;
tfrx = frx * move_count;
tfry = fry * move_count;
PR_RotateEntity(camera_pointer, tcx, tcy, tcz);
tvector[0] = txm;tvector[1] = 0;tvector[2] = 0;
PR_Transform(camera_pointer->orientation.rot_mat);
vx1 = tvector[0];vx2 = tvector[1];vx3 = tvector[2];
tvector[0] = 0;tvector[1] = tym;tvector[2] = 0;
PR_Transform(camera_pointer->orientation.rot_mat);
vy1 = tvector[0];vy2 = tvector[1];vy3 = tvector[2];
tvector[0] = 0;tvector[1] = 0;tvector[2] = tzm;
PR_Transform(camera_pointer->orientation.rot_mat);
vz1 = tvector[0];vz2 = tvector[1];vz3 = tvector[2];
// Used for the free camera mode
PR_MoveEntity(camera_pointer, vx1 + vy1 + vz1, vx2 + vy2 + vz2,
vx3 + vy3 + vz3);
tvector[0]=0;tvector[1]=0;tvector[2] = (PR_REAL) 10.0;
PR_RotateSegment(camera_pointer, 0, tfrx, tfry, 0);
PR_Transform(camera_pointer->segment_orientation->rot_mat);
PR_Transform(camera_pointer->orientation.rot_mat);
tvector[0] += camera_pointer->orientation.location.x;
tvector[1] += camera_pointer->orientation.location.y;
tvector[2] += camera_pointer->orientation.location.z;
PR_PositionCameraTarget (camera, tvector[0], tvector[1], tvector[2]);
// Set Camera Up Y vector only works when CAMFLAG_AIM_TARGET mode is enabled
tvector[0] = 0;
tvector[1] = 1;
tvector[2] = 0;
PR_Transform(camera_pointer->segment_orientation->rot_mat);
PR_Transform(camera_pointer->orientation.rot_mat);
camera->up.x=tvector[0];
camera->up.y=tvector[1];
camera->up.z=tvector[2];
PR_PositionCameraSource(camera, camera_pointer->orientation.location.x,
camera_pointer->orientation.location.y,camera_pointer->orientation.location.z);
//PR_CameraDirection (camera);
PR_SetActiveCamera(camera);
//TODO: Need to setup routine for third player person
//PR_TransformEntity (player); /* Transform the entity */
//PR_RenderEntity (player); /* Render the entity */
}
Doug