1 / 12

OpenGL Transformation

This guide explores the transformation functions in OpenGL, covering three main matrix stacks: ModelView, Projection, and Texture. Learn to manipulate matrices with commands like glLoadIdentity, glTranslate, glRotate, and glScale to create hierarchical structures. Discover how to set up your viewing transformation using gluLookAt for camera positioning and various projection methods such as perspective and orthographic projections. We'll also delve into viewport transformations, ensuring a comprehensive understanding of how to manage 3D scenes in OpenGL.

jerica
Télécharger la présentation

OpenGL Transformation

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. OpenGL Transformation Jian-Liang Lin 2002

  2. Transformation -1

  3. Transformation -2 • There are three matrix stacks in OpenGL architecture • MODELVIEW, PROJECTION, TEXTURE • glMatrixMode( GLenum mode ); • mode: GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE • Current matrix mode is also a OpenGL state variable.

  4. Transformation -3 • Matrix Manipulation • glLoadIdentity(); • glLoadMatrix{f,d}( const TYPE* m ); • glMultMatrix{f,d}( const TYPE* m ); • glPushMatrix(); • glPopMatrix(); • Stack operation of matrix is very useful for constructing a hierarchical structures. • Ex: Render a car with four wheels.

  5. Transformation -4 • OpenGL built-in transformation: • glTranslate{f,d}( TYPE x, TYPE, y, TYPE z ); • Multiply a translation matrix into current matrix stack • glRotate{f,d}( TYPE angle, TYPE x, TYPE y, TYPE z ); • Multiply a rotation matrix about an arbitrary axis into current matrix stack • glScale{f,d}( TYPE x, TYPE y, TYPE z ); • Multiply a scaling matrix into current matrix stack

  6. Transformation -5 • Viewing transformation • Choose your viewing system • Center-orientation-up system • Apply gluLookAt Utility routine. • gluLookAt( cx, cy, cz, cx+ox, cy+oy, cz+oz, upx, upy, upz ); • ( cx, cy, cz ) is the center of the camera • ( ox, oy, oz ) is the orientation vector of the camera • ( upx, upy, upz ) is the up vector of the camera • Polar coordinate system • Combine translation and two rotation. • …

  7. Transformation -6 • Projection transformation: Perspective projection • glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far );

  8. Transformation -7 • gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far );

  9. Transformation -8 • Projection transformation: Orthogonal projection • glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far ); • gluOrtho2D( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top ); • A helper to create a 2D projection matrix

  10. Transformation -9 • Viewport transformation • glViewport( GLint x, GLint y, GLsizei w, GLsizei h ); • Initial viewport is as the same size as the window

  11. Transformation -10 • Note: • By default, the viewpoint as well as objects in the scene are originally situated at the origin, and is looking down the negative z-axis, and has the positive y-axis as straight up.

  12. Any Question? ?

More Related