Академический Документы
Профессиональный Документы
Культура Документы
OpenGL Transformations
glTranslatef(0.0,1.0,32.5); glTranslatei(3,1,88); glRotatef(90.0,1.0,0.0,0.0); // rotate about x axis by 90 degrees glRotatei glScalef(5.0,2.0,-1.0); // performs stretch, shrink, reflect
Our intention is to first rotate the quad, then scale it, then translate it. Why reverse order? Because every time OpenGL sees a command, it will post-multiply the current matrix by the transformation.
current matrix
m_array
m_array2
glLoadIdentity(); // sets the current matrix glMultMatrixf(m_array); // adjusts the current matrix glMultMatrixf(m_array2); // adjusts the current matrix glBegin(GL_QUADS); glVertex3f(1.0,0.0,0.0);
current matrix
Room A
Room B
Room C
Room D
Room E
Room F
Building 1
Building 2
Building 3
Campus
Transform Building A to desired location on campus Transform Room A to desired location wrt. Building A Model Room A
Another Example
float M[16] = { 1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 2.0,5.0,1.0,1.0 }; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(1.0,0.0,0.0); glMultMatrixf(M);
1 2 3
What is the matrix at the top of the OpenGL matrix stack at point 1? At point 2? At point 3? What is the effective model view transformation that the geometry at point 2 is subjected to?
20 10 0 0 10 20 30 40 50 60