Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 4 Geometric Transformations: The Pipeline Vivian by Richard S. Wright Jr.

Similar presentations


Presentation on theme: "CHAPTER 4 Geometric Transformations: The Pipeline Vivian by Richard S. Wright Jr."— Presentation transcript:

1

2 CHAPTER 4 Geometric Transformations: The Pipeline Vivian by Richard S. Wright Jr.

3

4 Transformation Terminology Viewing Modeling Modelview Projection Viewport

5 +x +y +z Eye Coordinates -x -y -x -y

6 Viewing Transformations +x +y +z -x -y (0,0,0)

7 Translation Rotation Scaling Modeling Transformations

8 +y +x +y +x +y +x +y +x +y +x +y +x rotation/translation and translation/rotation. θ θ

9 +x +y +z +x +y +z The Modelview Duality

10 Projection Transformations OrthographicPerspective

11 The Matrix: Mathematical Currency for 3D Graphics What is matrix?

12 The Transformation Pipeline 11 vertexvertex Modelview Matrix Projection Matrix Perspective Division Viewport Transform Modelview Projection object eye clip normalized device window other calculations here –material  color –shade model (flat) –polygon rendering mode –polygon culling –clipping

13

14 glTranslatef(x, y, z); glRotatef(angle, x, y, z); glScalef(x, y, z); glLoadIdentity(); The Modelview Matrix

15 Transformation functions - Translate glTranslatef(x, y, z); Ex: glTranslatef(0.0f, 10.0f, 0.0f);

16 Transformation functions - Rotate glRotatef(angle, x, y, z); Ex: glRotatef(45.0f, 1.0f, 1.0f, 1.0f);

17 Transformation functions - Scale glScalef(x, y, z); Ex: glScalef(2.0f, 1.0f, 2.0f);

18 Transformation functions - The Identity Matrix glLoadIdentity();

19 Matrix Stack glPushMatrixglPopMatrix glGet(GL_MAX_MODELVIEW_STACK_DEPTH) The Matrix Stacks

20 A Nuclear 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();

21 A Nuclear Example(cont.) // 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(); // Third Electron Orbit glPushMatrix(); glRotatef(360.0f, -45.0f, 0.0f, 0.0f, 1.0f); glRotatef(fElect1, 0.0f, 1.0f, 0.0f); glTranslatef(0.0f, 0.0f, 60.0f); glutSolidSphere(6.0f, 15, 15); glPopMatrix();

22 Using Projections Orthographic Projections Perspective Projections

23 Frustum nearfar Perspective viewing volume w h

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

25 Advanced Matrix Manipulation GLfloat matrix[16]; // Nice OpenGL friendly matrix Translation/location

26 Loading a Matrix glLoadMatrixf(GLfloat m); void glLoadTransposeMatrixf(Glfloat* m); // Load an identity matrix GLfloat m[] = { 1.0f, 0.0f, 0.0f, 0.0f, // X Column 0.0f, 1.0f, 0.0f, 0.0f, // Y Column 0.0f, 0.0f, 1.0f, 0.0f, // Z Column 0.0f, 0.0f, 0.0f, 1.0f }; // Translation glMatrixMode(GL_MODELVIEW); glLoadMatrixf(m);


Download ppt "CHAPTER 4 Geometric Transformations: The Pipeline Vivian by Richard S. Wright Jr."

Similar presentations


Ads by Google