The modelview transform is how local objects get mapped onto the camera’s view, or global coords. They can be considered separately, but in openGL the matrix mode is GL_MODELVIEW.

# Model Transform

The transformations describing the mapping of an object’s local coordinate system onto the world coordinate system.

# View Transform

The transformations describing the mapping of the world coordinate system onto the camera’s local coordinate system.

And it turns out that working out the inverse of the matrix, is really super easy:

# Camera

The camera doesn’t move, the world moves around it. Hence transforming the camera does the inverse to our world view - translate left = translate right, etc.

For a camera:

- View Transform (for 2D:)
- gl.glScaled(1.0 / cameraScale, …);
- gl.glRotated(-cameraAngle, 0, 0, 1);

- gl.glTranslated(-camX, -camY, 0);
- Model Transform
- Drawing

These all require knowledge of the camera’s position in world’s coords - e.g. we first do a model transform for the camera, and then using those coords do a model+view transform for each other object.

We can use gluLookAt to easily set the view transform based on the camera position, the position we’re looking at and the up vector.

i and j and k are the standard components of a transformation matrix as seen above

- i (or x axis) is up cross k (perpendicular to the 2 currently fixed vectors)
- j (or y axis) is k cross i (so perpendicular to the other 2 axes)
- k (or z axis) is the vector from Camera to Eye.