{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture04-1

# Opengl preserves a similar matrix to describe the

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tand (The why in the future) why Note OpenGL preserves a similar matrix to describe the Note camera type and this is called the PROJECTION_MATRIX PROJECTION_MATRIX Introduction to OpenGL What’s hard about this assignment? • Managing the MODELVIEW stack • We’ll use: – glLoadIdentity(); – glTranslatef(GLfloat x, y, z); – glRotatef(GLfloat degrees, x, y, z); – glScalef (GLfloat x, y, z); – glPushMatrix(), glPopMatrix(); Modeling Transformations glTranslate (x, y, z) • Post-multiplies the current matrix by a matrix that moves Post-multiplies the object by the given x-, y-, and z-values the glRotate (theta, x, y, z) • Post-multiplies the current matrix by a matrix that rotates Post-multiplies the object in a counterclockwise direction about the ray from the origin through the point (x, y, z) from Modeling Transformations glScale (x, y, z) • Post-multiplies the current matrix by a matrix that stretches, Post-multiplies shrinks, or reflects an object along the axes shrinks, Modeling Transformations It is important that you understand the order in which It OpenGL concatenates matrices OpenGL glMatrixMode (MODELVIEW); glLoadIdentity(); glMultMatrix(N); glMultMatrix(M); glMultMatrix(L); glBegin(POINTS); glVertex3f(v); glEnd(); Modelview matrix successively contains: I(dentity), N, NM, NML The transformed vertex is: NMLv = N(M(Lv)) Manipulating Matrix Stacks Observation: Certain model transformations are shared Observation: among many models among We want to avoid continuously reloading the same We sequence of transformations sequence glPushMatrix ( ) • push all matrices in current stack down one level and copy topmost push matrix of stack matrix glPopMatrix ( ) • pop the top matrix off the stack Matrix Manipulation - Example Drawing a car with wheels and lugnuts draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( ); glPopMatrix ( ); } Matrix Manipulation – Example Matrix Grand, fixed coordinate...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online