1 / 28

computer graphics

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 .

keenan
Télécharger la présentation

computer graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. computer graphics TA: Nouf Al-Harbi nouf200@hotmail.com

  2. Computer graphicslab 6

  3. Lab 4 objectives • By the end of this lab you will be able to : • Dealing with projection transformations • Manipulating the Matrix Stacks

  4. Draw a snowman

  5. Part 1 projection transformations

  6. Projection Transformations • two general classes of projection transformations: • perspective . • orthographic (parallel).

  7. Projection Transformations perspective orthographic

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. 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 :

  13. Part 2 Manipulating the Matrix Stacks

  14. 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().

  15. 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.

  16. Example ..

  17. What’s the difference between …. glPushMatrix/glPopMatrix And glLoadIdentity..?

  18. Tracing ..

  19. Tracing ..

  20. Tracing ..

  21. Tracing ..

  22. Tracing ..

  23. Tracing ..

  24. Tracing ..

  25. Tracing ..

  26. Tracing ..

  27. Practical Application .. • Draw a snowman • Use this code to draw a circle

  28. 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

More Related