Tom Kelliher, CS 320
Mar. 31, 2003
Pong due now!
Read Chapter 5.
Linear algebra basis for computer graphics transformations.
Movement through a room.
Are our viewing volume coordinates relative or absolute?
Consider:
glOrtho(-10.0, 10.0, -5.0, 5.0, -2.0, 2.0);mean?
glFrustum
: same parameters as glOrtho
. What's a
frustum? Truncated pyramid.
gluPerspective
: fovy, aspect ratio, zNear, and zFar.
View specification:
gluLookAt()
in cubeview.c
:
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Update viewer position in modelview matrix */ glLoadIdentity(); gluLookAt(viewer[0],viewer[1],viewer[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); /* rotate cube */ glRotatef(theta[0], 1.0, 0.0, 0.0); glRotatef(theta[1], 0.0, 1.0, 0.0); glRotatef(theta[2], 0.0, 0.0, 1.0); colorcube(); glutSwapBuffers(); }Note order of matrix multiplications: view, then model transformations.
Problems with viewer movement in cubeview:
Consider this model: