? View Matrix: 1st person to 3rd person ?

For sake of completeness, my linux system use Nvidia proprietary driver (87.76) for a Geforce 6800.

For my completeness sake, I would like to provide the JOGL (Java) source code…I can’t believe I didn’t attach it before…

since I can’t actually attach files to posts, I’ll have to direct you to this site to get the files:
TestFPS_Camera.zip

Here is the link to the JOGL runtime demo again…can’t edit my last post so had to create this new one:

Demo FPS

Left mouse down to rotate view
middle mouse button to zoom
right mouse button to pan
up/down/left/right arrows to move into/around the scene

Basically the controls are much like you see in the fly through of most first person shooter games.

‘O’ key switches from “Standard mode” to “Orbiting Mode”
Standard mode is like a FPS mode. Orbiting mode you will orbit the object in the center.

Slight correction to the matRotate() method in the Camera.java class. Zip file link above has been updated and here is the correction


  private double[] matRotate( double mat[], double angle, Vector3d axis ) {
    double s = Math.sin(angle * Math.PI / 180.0);
    double c = Math.cos(angle * Math.PI / 180.0);

    axis.normalize();

    // ERROR: mat[0] = c + (1 - c) * axis.x;
    mat[0] = c + (1 - c) * Math.pow(axis.x, 2);
    mat[1] = (1 - c) * axis.x * axis.y + s * axis.z;
    mat[2] = (1 - c) * axis.x * axis.z - s * axis.y;
    mat[3] = 0.0;

    mat[4] = (1 - c) * axis.y * axis.x - s * axis.z;
    mat[5] = c + (1 - c) * Math.pow(axis.y, 2);
    mat[6] = (1 - c) * axis.y * axis.z + s * axis.x;
    mat[7] = 0.0;

    mat[8] = (1 - c) * axis.z * axis.x + s * axis.y;
    // ERROR: mat[9] = (1 - c) * axis.z * axis.z - s * axis.x;
    mat[9] = (1 - c) * axis.y * axis.z - s * axis.x;
    mat[10] = c + (1 - c) * Math.pow(axis.z, 2);
    mat[11] = 0.0;

    mat[12] = 0.0;
    mat[13] = 0.0;
    mat[14] = 0.0;
    mat[15] = 1.0;

    return mat;
  }