Download
introduction to opengl transformations n.
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to OpenGL Transformations PowerPoint Presentation
Download Presentation
Introduction to OpenGL Transformations

Introduction to OpenGL Transformations

128 Vues Download Presentation
Télécharger la présentation

Introduction to OpenGL Transformations

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Introduction to OpenGL Transformations

  2. How does OpenGL View the Scene? • Since viewing transformation is applied after modeling transformation, you should define viewing transformation first in the modelview matrix • Viewing transformation sets up the camera position and orientation and maps coordinates from the world coordinate system to the viewing coordinate system. • The camera is located at the origin of the viewing coordinate system and faces the –z direction.

  3. How does OpenGL View the Scene?

  4. How does OpenGL View the Scene?

  5. Intuitive Camera Specification • How to specify a camera gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz). • (eyex, eyey, eyez): Coordinates of the camera (eye) location in the world coordinate system • (centerx, centery, centerz ): the look-at point, which should appear in the center of the camera image, specifies the viewing direction • (upx, upy, upz): an up-vector specifies the camera orientation by defining a world space vector that should be oriented upwards in the final image. • This intuitive specification allows us to specify an arbitrary camera path by changing only the eye point and leaving the look-at and up vectors untouched. • Or we could pan the camera from object to object by leaving the eye-point and up-vector fixed and changing only the look-at point.

  6. Example • void display() { glClear(GL_COLOR_BUFFER); glColor3f(0.0f, 1.0f, 0.0f); glLoadIdentity(); gluLookAt(0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); … others transform … glBegin(GL_TRIANGLES); glVertex3f(2.0f, 0.0f, 0.0f); glVertex3f(0.0f, 2.0f, 0.0f); glVertex3f(0.0f, 0.0f, 2.0f); glEnd(); glFlush(); } Xiaoyu Zhang, CSUSM

  7. Parallel (Orthographic) Projection • Set the viewing volume and matrix • glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(left, right, bottom, top, near, far); Xiaoyu Zhang, CSUSM