Computergrafik
OpenGL Transformations Beispiel
← GL Transformationen | ● | GL Kamera →
Beispiel für ein rotiertes und transliertes Dreieck, dessen Geometrie in lokalen Objektkoordinaten gegeben ist:
glLoadIdentity();
glTranslated(0.0,0.0,-10.0); // translation along z-axis
glRotated(45, 0.0,1.0,0.0); // rotation about y-axis
glBegin(GL_TRIANGLES);
glVertex3d(0.0,0.0,0.0);
glVertex3d(-1.0,1.0,0.0);
glVertex3d(1.0,1.0,0.0);
glEnd();
glTranslated(0.0,0.0,-10.0); // translation along z-axis
glRotated(45, 0.0,1.0,0.0); // rotation about y-axis
glBegin(GL_TRIANGLES);
glVertex3d(0.0,0.0,0.0);
glVertex3d(-1.0,1.0,0.0);
glVertex3d(1.0,1.0,0.0);
glEnd();
Hinweis: Perspektive nicht vergessen!
← GL Transformationen | ● | GL Kamera →