Computergrafik
OpenGL Matrix Stack Beispiel
← GL Objekt Hierachie | ● | GL →
Realisation von $V*M*T_n$ mittels Push & Pop auf dem Matrix Stack:
V*M -> body Push *T1 -> wheel 1 Pop Push *T2 -> wheel 2 Pop Push *T3 -> wheel 3 Pop Push *T4 -> wheel 4 Pop
In OpenGL:
glLoadIdentity();
gluLookAt(0.0,5.0,0.0, 0.0,0.0,-10.0, 0.0,1.0,0.0); // V
glTranslated(0.0,0.0,-10.0); // M
glVertex(...); // body
glPushMatrix();
glTranslated(-1.0,0.0,-2.0); // T1
glVertex(...); // wheel
glPopMatrix();
glPushMatrix();
glTranslated(1.0,0.0,-2.0); // T2
glVertex(...); // wheel
glPopMatrix();
glPushMatrix();
glTranslated(-1.0,0.0,2.0); // T3
glVertex(...); // wheel
glPopMatrix();
glPushMatrix();
glTranslated(1.0,0.0,2.0); // T4
glVertex(...); // wheel
glPopMatrix();
gluLookAt(0.0,5.0,0.0, 0.0,0.0,-10.0, 0.0,1.0,0.0); // V
glTranslated(0.0,0.0,-10.0); // M
glVertex(...); // body
glPushMatrix();
glTranslated(-1.0,0.0,-2.0); // T1
glVertex(...); // wheel
glPopMatrix();
glPushMatrix();
glTranslated(1.0,0.0,-2.0); // T2
glVertex(...); // wheel
glPopMatrix();
glPushMatrix();
glTranslated(-1.0,0.0,2.0); // T3
glVertex(...); // wheel
glPopMatrix();
glPushMatrix();
glTranslated(1.0,0.0,2.0); // T4
glVertex(...); // wheel
glPopMatrix();
Siehe auch unter Szenengraphen!
← GL Objekt Hierachie | ● | GL →