1 / 17

Instance Transformation One Common Sequence of Transforms

y. y. y. y. x. x. x. x. z. z. z. z. Instance Transformation One Common Sequence of Transforms. S. R. T. Model Coordinates. glLoadIdentity() glScalef() glRotatef() glTranslatef(). Current. Current. Stack. Stack. Transformation Matrices in OpenGL 1.x – 2.x.

asis
Download Presentation

Instance Transformation One Common Sequence of Transforms

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. y y y y x x x x z z z z Instance TransformationOne Common Sequence of Transforms S R T Model Coordinates

  2. glLoadIdentity() glScalef() glRotatef() glTranslatef() Current Current Stack Stack Transformation Matrices in OpenGL 1.x – 2.x Matrix Mode = GL_MODELVIEW 3D Model Vertices 2D 3D Vertices Modelview Projection

  3. Perspective Projection 3D Object Image (2D) Projection Plane COP

  4. Classical Viewing:Parallel Projection 3D Object Image DOP Projection Plane

  5. Canonical Perspective Transformation:Transformation of View Volume y y z = zfar z = -1 z = znear M x COP x z z z = 1 DOP Orthographic projection is applied as last step to project to plane z = 0.

  6. Current Current Stack Stack Projection Matrices in OpenGL glOrtho() glFrustum() gluPerspective() Matrix Mode = GL_PROJECTION 3D Model Vertices 2D To Viewport Transform 3D Vertices Modelview Projection

  7. y x Graphics Pipeline in OpenGL Model Coordinates Eye Coordinates Normalized Coordinates y Modelview Transform Projection Transform z = -1 z = 1 x z glScalef() glRotatef() glTranslatef() glFrustum() gluPerspective() Projected Normalized Coordinates Window Coordinates (1,1) Viewport Transform glViewport() (-1,-1)

  8. Graphics Pipeline Example (from a Midterm)

  9. Graphics Pipeline Example2 (from a Midterm)

  10. Hidden Surface RemovalZ - Buffer Algorithm 2 Projection Plane 1 z2 COP z1 Z1 < Z2 Therefore red pixel from object 2 does not replace green pixel from object 1 Without z buffering enabled, red object, drawn last, would be drawn over green object.

  11. Initializing and using Z-Buffer in GLUT/OpenGL Allocating the buffer: glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH); Enable depth testing: glEnable(GL_DEPTH_TEST);

  12. Positioning the Camera Initially, the camera is at (0,0,0) for perspective viewing looking in the -z direction. To move the camera away from modeled objects distance d along the the positive z axis: glTranslatef(0.0, 0.0, -d); What you are really doing is translating the modeled objects in the negative z direction. If you want to look at the model from the positive x direction at a distance d: glTranslatef(0.0, 0.0, -d); glRotatef(-90.0, 0.0, 1.0, 0.0);

  13. A More Intuitive ApproachOffered by glu: gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz); eyex, eyey, eyez specify the position of the eye point and are mapped to the origin. atx, aty, atz specify a point being looked at, that will be rendered in center of viewport. It is mapped to the -z axis. upx, upy, upz specify components of the camera up vector

  14. Bit n Bit n Bit 4 Bit 4 Bit 3 Bit 3 Bit 2 Bit 2 Bit 1 Bit 1 Double Buffering Frame Buffer 1(drawing) Display Graphics System Frame Buffer 2 (displaying)

  15. Bit n Bit n Bit 4 Bit 4 Bit 3 Bit 3 Bit 2 Bit 2 Bit 1 Bit 1 Double Buffering Frame Buffer 1(displaying) Display Graphics System Frame Buffer 2 (drawing)

  16. Double Buffering:Implementation in GLUT/OpenGL Allocation of two frame buffers: glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE); Swapping the buffers: display() { // Stuff being drawn into back buffer goes here glutSwapBuffers(); //makes back buffer the active buffer }

  17. Simple Animation in GLUTMethod 1: Use Idle Callback Function Idle Function No Event in Queue Make Changes To Model; Post Display Event Yes Call Function n Pop Display Event From Queue Call Function n Call Function n Call Function n Call Function n Draw Scene Call Display Callback

More Related