1 / 26

3D Graphics Programming Geometric Transformations

3D Graphics Programming Geometric Transformations. Ming-Te Chi Department of Computer Science,  National Chengchi University. Outline. Geometric Transformations(CH4). Transformation Terminology. Viewing Modeling Modelview Projection Viewport. Eye coordinates. +y. +y. +x. +x. +z.

cid
Download Presentation

3D Graphics Programming Geometric Transformations

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. 3D Graphics Programming Geometric Transformations • Ming-Te Chi • Department of Computer Science,  • National Chengchi University

  2. Outline • Geometric Transformations(CH4)

  3. Transformation Terminology • Viewing • Modeling • Modelview • Projection • Viewport

  4. Eye coordinates +y +y +x +x +z

  5. Transformations • Translation • Rotation • Scaling

  6. Rotation/Translation +y +y +y +y +y +y +x +x +x +x +x +x

  7. The Modelview Duality +y +y +x +x +z +z

  8. Projection

  9. Matrix

  10. Transformation functions • glTranslatef(x, y, z); • glRotatef(angle, x, y, z); • glScalef(x, y, z); • glLoadIdentity();

  11. Per Vertex Poly. Frag FB Raster CPU DL Texture Pixel v e r t e x Modelview Matrix Projection Matrix Perspective Division Viewport Transform Modelview Projection Modelview l l l TransformationPipeline • other calculations here • material è color • shade model (flat) • polygon rendering mode • polygon culling • clipping normalized device eye object clip window

  12. glutWireCube(10.0f);

  13. The Matrix Stacks glPushMatrix glPopMatrix Matrix Stack glGet(GL_MAX_MODELVIEW_STACK_DEPTH)

  14. Atom example // First Electron Orbit // Save viewing transformation glPushMatrix(); // Rotate by angle of revolution glRotatef(fElect1, 0.0f, 1.0f, 0.0f); // Translate out from origin to orbit distance glTranslatef(90.0f, 0.0f, 0.0f); // Draw the electron glutSolidSphere(6.0f, 15, 15); // Restore the viewing transformation glPopMatrix();

  15. // Second Electron Orbit glPushMatrix(); glRotatef(45.0f, 0.0f, 0.0f, 1.0f); glRotatef(fElect1, 0.0f, 1.0f, 0.0f); glTranslatef(-70.0f, 0.0f, 0.0f); glutSolidSphere(6.0f, 15, 15); glPopMatrix();

  16. Projections • Orthograhpic Projections • Perspective Projections

  17. Orthograhpic Projections // Reset coordinate system glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Establish clipping volume (left, right, bottom, top, near, far) if (w <= h) glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange*2.0f, nRange*2.0f); else glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange*2.0f, nRange*2.0f);

  18. Perspective Projections // Reset coordinate system glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Produce the perspective projection gluPerspective(60.0f, fAspect, 1.0, 400.0);

  19. Advance Matrix Manipulation • Glfloat matrix[16];

  20. Load a Matrix • glLoadMatrixf(GLfloat *m); • glLoadTransposeMatrixf(Glfloat *m);

  21. Adding Transformations Together • glMultMatrixf(Glfloat *m);

  22. Cameras and Actors

  23. An Actor Frame Class GLFrame { protected: M3Dvector3f vLocation; M3Dvector3f vUp; M3Dvector3f vForward; };

  24. Euler Angles Class GLFrame { protected: M3Dvector3f vPosition; Glfloat fRoll; Glfloat fPitch; Glfloat fYaw; };

  25. Camera Management gluLookat( GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ);

  26. Rendering Loop Save Identity Matrix Apply camera transformation Draw stuff the doesn’t move Draw moving stuff (Actors) Save camera transform Apply actor transform Draw actor geometry Restore camera transform Restore identity Matrix

More Related