Modelview Transform

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.

Screenshot%202014-09-04%2012.54.26.png

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

Screenshot%202014-09-04%2012.54.33.png

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:

  1. View Transform (for 2D:)
    1. gl.glScaled(1.0 / cameraScale, …);
    2. gl.glRotated(-cameraAngle, 0, 0, 1);
  2. gl.glTranslated(-camX, -camY, 0);
  3. Model Transform
  4. 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.

Screenshot%202014-09-04%2012.54.42.png

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

Screenshot%202014-09-04%2012.54.45.png

  • 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.