CSCE 441 Lecture 13
Jump to navigation
Jump to search
« previous | Wednesday, February 12, 2014 | next »
3D Transformations as Matrices
Rotation
Mirror Image
Orthogonal Projection
Perspective Projection
Perspective transformations are not Affine!
Rational expressions require modification:
homogeneous coordinates
In affine transformations, our matrix equation was
Now we use
Where and represent the stuff in the denominator of the transformation equation
3D Location is
Note this equation still works for Affine transformations (where we divide by 1)
Hierarchical Animation
Multiple transformations at each joint of a skeleton.
For example, to move a point on the hand, we have to move the wrist (), elbow (), and shoulder ().
In general,
Transformations in OpenGL
4 types:
- View
- Model (put things in the scene)
- Projection (takes 3D objects and projects onto a 2D surface)
- Viewport
Commands:
glTranslatef(x,y,z)
glScalef(x,y,z)
glRotatef(theta, vx, vy, vz)
glLoadIdentity(void)
: replaces current matrix with identity matrix (i.e. removes current transformations)glPushMatrix(void)
andglPopMatrix(void)
: copies current matrix to new context and removes current matrix (respectively)
Order matters!
glTranslatef(0,1,3) = M[1]
glRotatef(45,0,1,0) = M[2]
glScalef(1,1,2) = M[3]
OpenGL combines model and view matrix:
- push matrix
- specify viewer using inverse of view transformation (negative translation/rotation and in opposite order):
- push matrix
- position objects with transformations in opposite order of what you would expect
- pop matrix
- repeat last 3 steps for each object in scene
- pop matrix
Special Matrix Commands
glMatrixMode(GL_MODELVIEW)
andglMatrixMode(GL_PROJECTION)
gluLookAt(ex,ey,ez, cx,cy,cz, ux,uy,uz)
: set position of eye, direction of thing to look at, and the "up direction"gluPerspective(fov, aspect, near, far)
glOrtho(left, right, bottom, top, near far)
specify orthogonal projectionglViewport(x,y,w,h)