350 likes | 601 Views
Lecture 7. Geometrical Transformations: 2D transformations 3D transformations Matrix representation OpenGL functions. Rendering Pipeline. Rendering Pipeline. Rendering Pipeline. Rendering Pipeline. Basic 2D Transformations. Basic 2D Transformations. Basic 2D Transformations.
E N D
Lecture 7 Geometrical Transformations: 2D transformations 3D transformations Matrix representation OpenGL functions
2x2 matrices • Only rotation, scaling, and shear can be represented in 2x2 matrix form. • These are linear transformations.
OpenGL Matrix Stacks OpenGL works with stacks of 4x4 matrices: glMatrixMode(enum mode); mode: GL_MODELVIEWGL_PROJECTIONGL_TEXTURE Specifies whether the modelview, projection or texture matrix will be modified.
OpenGL Matrix Stacks glLoadIdentity(void); Clears the currently modifiable matrix for future transformation instructions. Typically we call this instruction before specifying modeling, viewing or projection transformations.
OpenGL Matrix Stacks Manipulating stacks: the OpenGL calls to push, pop, or multiply top of stack glLoadMatrix(void); glMultMatrix(void); glPushMatrix(void); the topmost matrix is copied glPopMatrix(void); the topmost matrix is destroyed All vertices of the object are multiplied by the matrix.
OpenGL Matrix Stacks Manipulating stacks: the OpenGL calls to push, pop, or multiply top of stack glLoadMatrix(const type *m); glMultMatrix(const type *m); m1 m5 m9 m13 m2 m6 m10 m14 m3 m7 m11 m15 m4 m8 m12 m16
OpenGL Matrix Stacks Manipulating stacks: the OpenGL calls to push, pop, or multiply top of stack glPushMatrix(void); the topmost matrix is copied glPopMatrix(void); the topmost matrix is destroyed All vertices of the object are multiplied by the matrix.
OpenGL Transformations glTranslate(TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a translation matrix. glRotate(TYPE angle, TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a rotation matrix. glScale(TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a scaling matrix.
Summary • Types of transformations: • linear • affine • projective • Representation of transformations: • 3x3 and 4x4 matrices • homogeneous coordinates • Compositions of transformations • OpenGL Matrix Instructions