1 / 17

Introduction of OpenGL - 3D Graphic and Animation

Introduction of OpenGL - 3D Graphic and Animation. Luke Yulu Chen. 3D Graphic. Projections – Getting 3D to 2D. Two Projections. Orthographic Projection Perspective Projection. Orthographic. Perspective. Orthographic Projections. Command

dysis
Download Presentation

Introduction of OpenGL - 3D Graphic and Animation

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. Introduction of OpenGL- 3D Graphic and Animation Luke Yulu Chen

  2. 3D Graphic • Projections – Getting 3D to 2D

  3. Two Projections • Orthographic Projection • Perspective Projection Orthographic Perspective

  4. Orthographic Projections • Command • glOrtho ( double left, double right, double bottom, double top, double near, double far);

  5. Perspective Projection • Command • gluPerspective ( double angle, double aspect, double near, double far);

  6. Draw a 3D Model • Object Composition Polygon 3D Model

  7. Object Composition • Use Transformation • glPushMatrix ( ); • glPopMatrix ( ); • Save the current transformation state and then restore it after some objects have been placed

  8. Wheele 4 Wheele 3 Wheele 2 Wheele 1 The Car Body The Matrix Stack • Ex. Draw a car use transformation • The car body and four wheeles Transformation state Wheele 4

  9. Hidden Surface Hidden Surface Removal • Enable Depth Testing • glEnable (GL_DEPTH_TEST);

  10. Light and Surface Normal • A Normal Vector V3 = V1 X V2 Normal Vector P3 V2 P1 V1 P2

  11. Draw Quadrics (1) • Rendering Spheres, Cylinders, and Disks • 1. Declare a quadrics pointer • GLUquadricObj *qobj; • 2. Create a quadrics object • qobj = gluNewQuadric ( );

  12. Draw Quadrics (2) • Rendering Spheres, Cylinders, and Disks • 3. Specify the rendering attributes for the quadrics object • gluDrawStyle (qobj, GLU_FILL); • gluQuadricOrientation (qobj, GLU_OUTSIDE); • gluQuadricNormals (qobj, GLU_SMOOTH);

  13. Draw Quadrics (3) • Rendering Spheres, Cylinders, and Disks • 4. Draw quadrics object • gluSphere (qobj, radius, slices, stacks); • gluCylinder (qobj, baseRadius, topRadius, height, slices, stacks); • gluDisk (qobj, innerRadius, outerRadius, slices, rings);

  14. Draw Quadrics (4) • Rendering Spheres, Cylinders, and Disks • Slices and stacks Cylinder slices = 6 stacks = 6 Cylinder slices = 30 stacks = 30

  15. Draw Quadrics (5) • Rendering Spheres, Cylinders, and Disks • 5. When you’re completely finished with drawing, destory this object • gluDeleteQuadric ( );

  16. Animation • A Rotating Square Frame 0 Frame 1 Frame 2 Frame 3

  17. Animation with OpenGL and GLUT • Motion = Redraw + Swap • Double Buffering • One is displayed while the other is being drawing. When the drawing of a frame is complete, the two buffers are swapped • glutSwapBuffers ( );

More Related