6. 3D Perspective
Brock University
COSC 3P98 Computer Graphics
Instructor: Brian Ross
Viewing 3D

Main types of planar projections:

Parallel projection

Parallel projection: OpenGL

Perspective projection

- This example: eye is on Z axis, and we project onto X-Y plane
- (can do this on any arbitrary eye position and projection plane however)
Projection example
- Let eye be at (0, 0, 0), proj plane at (0, 0, -1), ie. d=-1, and eye looking down -Z axis
Point |
World coords |
Orthographic coords |
Perspective factor t |
Perspective coords |
A |
(2,1,-1) |
(2,1) |
1.0 |
(2,1) |
B |
(2,1,-10) |
(2,1) |
0.1 |
(0.2, 0.1) |
C |
(2,1,-100) |
(2,1) |
0.01 |
(0.02, 0.01) |
D |
(2,-5,-100) |
(2,-5) |
0.01 |
(0.02, -0.05) |
E |
(-50,-50,-100) |
(-50,-50) |
0.01 |
(-0.5, -0.5) |
- Vanishing point: Lim(z -> -inf) (d/z) = 0
- therefore: x' = x*t = x*0 = 0, y' = 0 --> vanishing point is (0,0)
Perspective: OpenGL


- 4 planes: left, right, top, bottom, near, far
- defines a pyramid with its top shaved off: "frustum"
Moving eye in OpenGL
2. gluLookAt(GLdouble eyeX, eyeY, eyeZ, centerX, centerY, centerZ,
upX, upY, upZ)
- eyeX, eyeY, eyeZ: eye coordinate (viewing position)
- centerX, centerY, centerZ: a point along line of sight
- upX, upY, upZ: direction of "up" (normal from bottom to top
of viewing volume)

- Important note: gluLookAt creates a transformation matrix which is
applied to the current matrix. As usual, it
compounds with previously made transformations. Hence, if you need to
do multiple glLookAt calls, you should undo earlier ones (push/pop matrix,
or glLoadIdentity and re-set projection via ortho or perspective).
Example OpenGL Program
- Click here.
- Note how cube's far corner is clipped within viewing volume...

References
- OpenGL Programming Guide, OpenGL ARB, Addison-Wesley 1993,
ISBN 0-201-63274-8. (chapter 3; see insight)
Back
to COSC 3P98 index
COSC 3P98 Computer Graphics
Brock University
Dept of Computer Science
Copyright © 2006 Brian J. Ross
(Except noted figures).
http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/3d_perspective/
Last updated: November 6, 2006