280 likes | 441 Views
computer graphics. TA: Nouf Al-Harbi nouf200@hotmail.com . Computer graphics lab 6. Lab 4 objectives. By the end of this lab you will be able to : Dealing with projection transformations Manipulating the Matrix Stacks. Draw a snowman. Part 1 .
E N D
computer graphics TA: Nouf Al-Harbi nouf200@hotmail.com
Lab 4 objectives • By the end of this lab you will be able to : • Dealing with projection transformations • Manipulating the Matrix Stacks
Part 1 projection transformations
Projection Transformations • two general classes of projection transformations: • perspective . • orthographic (parallel).
Projection Transformations perspective orthographic
1. Perspective Projection • The most characteristic of perspective projection is foreshortening: • the farther an object is from the camera, the smaller it appears in the final image. • perspective projections create more realistic looking scenes.
1. Perspective Projection • 1. glFrustum: • 2. gluPerspective: • fovspecifies, in degrees, the angle in the y direction that is visible to the user • aspect is the aspect ratio of the scene, which is divided by the height. • This will determine the field of view in the x direction.
Orthographic Projection • With Orthographic ,or parallel, projection the viewing volume is a box • Unlike perspective projection, the size of the viewing volume doesn't change from one end to the other, so distance from the camera doesn't affect how large an object appears.
Orthographic Projection : glOrtho • left and right: • specify the x-coordinate clipping planes • bottom and top: • specify the y-coordinate clipping planes • near and far: • specify the distance to the z-coordinate clipping planes. • Together these coordinates provide a box shaped viewing volume.
Orthographic Projection : gluOrtho2D • Since orthographic projections are commonly used in 2D scenes • the Utility Library provides an additional routine to set them up for scenes that doesn’t using the z-coordinate. • gluOrtho2D :
Part 2 Manipulating the Matrix Stacks
Manipulating the Matrix Stacks • The matrices we've been creating, loading, and multiplying is actually the topmost member of a stack. • A stack of matrices is useful for constructing hierarchical models • in which complicated objects are constructed from simpler ones. • The current stack is determined by glMatrixMode().
stack operations: • glPushMatrix(void); • Pushes all matrices in the current stack down one level. • The topmost matrix is copied, so its contents are duplicated in both the top and second-from-the top matrix. • If too many matrices are pushed, an error is generated. • glPopMatrix(void); • Pops the top matrix off the stack, destroying the contents of the popped matrix. • the second-from-the-top matrix becomes the top matrix. • If the stack contains a single matrix, calling glPopMatrix() generates an error.
What’s the difference between …. glPushMatrix/glPopMatrix And glLoadIdentity..?
Practical Application .. • Draw a snowman • Use this code to draw a circle
REFERENCES: Materials of this lab are prepared using: Lighthouse3d: http://www.lighthouse3d.com/opengl/glut/index.php?1 Computer Graphics Lab -1st semester – 2010-2011 by : Ins. Ruwaida Al-harbi & Ins. Nouf Al-harbi