Recap
New Material
- Matrix representation of affine transformations:
- The Current Transformation Matrix (CTM)
- Associativity and non-commutativity of matrix multiplication
- matrix for scaling
- matrix for rotation
- matrix for translation and the need for homogeneous coordinates
- OpenGL matrices, points and vectors are 4D.
- pinhole cameras
- Pinhole camera:
- Pinhole camera with object and its projection:
- Pinhole camera showing similar triangles:
- Synthetic camera moves the image plane in front to elimate negatives:
- What is the height of the projected tree?
- Perspective: projections shrink with distance
- Example: With the standard camera and the image plane at z=-3, find
the projection of (7,8,-9).
- why doesn't the world look upside down?
- perspective matrices
- perspective division
- orthogonal projection
- gluPerspective, glOrtho, glFrustum
- placing the camera
- the VPN, VRP, VUP frame
- gluLookAt
Tutors
Some OpenGL wizards (not me) have built a tutor for playing with
these camera APIs. It is in:
$TWHOMEDIR/tutors/
and the program name is "projection." We'll play with this some in class,
but you're encouraged to play with it outside class as well.
Demos
All of these demos are in tw/demos/camera:
- Frustum.py shows what a
Frustum looks like. This one has a pretty wide FOVY.
- Perspective.py shows
the same wire cube using two different cameras.
- BarnViews.py shows the
barn from different viewpoints (VRP) and even with a random FOVY (use the
"G" callback).
- CityView.py shows the
effects of FOVY and near/far. Use + and - to adjust FOVY, and use N/N and
F/f to adjust near/far. Try viewing from the side (the X axis), too.
- Viewports.py shows the
same object with the same camera (a square frustum) rendered in three
different viewports.
- FrustumModes.py shows
the same object but with a camera where the frustum is determined by the
shape of the window and the desired presentation (l=letterbox, c=clipping
or d=distortion).
- Click.py shows the idea of
unprojection and how to do it.
Exercise
We'll work through the following together:
- Set up a camera to view the twSolidBarn from some position, say in
front.
- First, figure out the function calls we'll need and the arguments:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fovy, aspect_ratio, near, far);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);
- Copy the Barn demo
- Replace twCamera() with what we have above.
- Compile, cross fingers and run it.
Forced Perspective
We'll look at the DVD for LotR:The Fellowship of the Ring, where they
explain how forced perspective works and other camera tricks that they
used. (The segment takes about 10 minutes.)
twCamera
If we have time, we can talk about how the twCamera setup works.
Written by Scott D. Anderson
scott.anderson@acm.org

This work is licensed under a Creative Commons
License.