void afficherBras() { const GLfloat cylhauteur = 2.0; const GLfloat sphererayon = 0.25; // toutes les modifications ici ... // ajouter une ou des transformations afin de tracer un cylindre de rayon "sphererayon" et de hauteur "cylhauteur" // Cylindre vertical glPushMatrix(); glScalef(sphererayon, sphererayon, cylhauteur); afficherCylindre(); glPopMatrix(); // Sphère no 1 glPushMatrix(); glTranslatef(0.0, 0.0, cylhauteur); glTranslatef(0, 0, 0.4*sphererayon); // Décalage pour que tout soit moins coincé glScalef(sphererayon, sphererayon, sphererayon); afficherSphere(); glPopMatrix(); // Cylindre horizontal no 1 glPushMatrix(); glTranslatef(0.0, 0.0, cylhauteur + 0.4*sphererayon); glRotatef(phiBras, 0, 0, 1); glRotatef(90, 0, 1, 0); glScalef(sphererayon, sphererayon, cylhauteur); afficherCylindre(); glPopMatrix(); // Sphère no 2 glPushMatrix(); glRotatef(phiBras, 0, 0, 1); glTranslatef(cylhauteur, 0.0, cylhauteur); glTranslatef(0.4*sphererayon, 0, 0.4*sphererayon); // Décalage pour que tout soit moins coincé glScalef(sphererayon, sphererayon, sphererayon); afficherSphere(); glPopMatrix(); // Cylindre horizontal no 2 glPushMatrix(); glRotatef(phiBras, 0, 0, 1); glTranslatef(cylhauteur + 0.8*sphererayon, 0, cylhauteur + 0.4*sphererayon); glRotatef(thetaBras, 0, 0, 1); glRotatef(90, 0, 1, 0); glScalef(sphererayon, sphererayon, cylhauteur); afficherCylindre(); glPopMatrix(); // Sphère no 3 glPushMatrix(); glRotatef(phiBras, 0, 0, 1); glTranslatef(cylhauteur, 0.0, 0.0); glTranslatef(0.8*sphererayon, 0, 0.0); // Décalage pour que tout soit moins coincé glRotatef(thetaBras, 0, 0, 1); glTranslatef(cylhauteur, 0.0, cylhauteur); glTranslatef(0.4*sphererayon, 0, 0.4*sphererayon); // Décalage pour que tout soit moins coincé glScalef(sphererayon, sphererayon, sphererayon); afficherSphere(); glPopMatrix(); // afficher la théière au bout du bras glPushMatrix(); glRotatef(phiBras, 0, 0, 1); glTranslatef(cylhauteur, 0.0, 0.0); glTranslatef(0.8*sphererayon, 0, 0.0); glRotatef(thetaBras, 0, 0, 1); glTranslatef(cylhauteur, 0.0, cylhauteur); glTranslatef(0.4*sphererayon, 0, 0.0); // Décalage pour que tout soit moins coincé glScalef(sphererayon, sphererayon, sphererayon); glRotatef(90, 1, 0, 0); afficherTheiere(); glPopMatrix(); }
void afficherBras() { const GLfloat cylLongueur = 2.0; const GLfloat sphereRayon = 0.25; // toutes les modifications ici ... verifierAngles(); // ajouter une ou des transformations afin de tracer un cylindre de rayon "sphereRayon" et de hauteur "cylLongueur" matrModel.PushMatrix(); matrModel.Scale(sphereRayon,sphereRayon,cylLongueur); progBase.assignerUniformMatrix4fv( "matrModel", matrModel ); afficherCylindre(); matrModel.PopMatrix(); // se déplacer un peu matrModel.Translate( 0.0, 0.0, 2.0 + sphereRayon/2); //1ere Sphere // ajouter une ou des transformations afin de tracer une sphère de rayon "sphereRayon" matrModel.PushMatrix(); matrModel.Scale(sphereRayon,sphereRayon,sphereRayon); progBase.assignerUniformMatrix4fv( "matrModel", matrModel ); afficherSphere(); matrModel.PopMatrix(); matrModel.Rotate(angleEpaule , 0.0, 0.0, 1.0); matrModel.Rotate(angleElevation , 0.0, 1.0, 0.0); // se déplacer un peu (à modifier) matrModel.Translate( 2.0+sphereRayon/2, 0.0, 0.0 ); matrModel.Rotate( 90, 1.0, 0.0, 0.0 ); matrModel.Rotate(-90 , 0.0, 1.0, 0.0); //2eme cylindre matrModel.PushMatrix(); matrModel.Scale(sphereRayon,sphereRayon,cylLongueur); progBase.assignerUniformMatrix4fv( "matrModel", matrModel ); afficherCylindre(); matrModel.PopMatrix(); matrModel.Rotate(angleCoude , 0.0, 1.0, 0.0); matrModel.Translate(0.0, 0.0, -sphereRayon/2 ); //2eme sphere matrModel.PushMatrix(); matrModel.Scale(sphereRayon,sphereRayon,sphereRayon); progBase.assignerUniformMatrix4fv( "matrModel", matrModel ); afficherSphere(); matrModel.PopMatrix(); //3eme cylindre matrModel.Rotate(-90, 0.0, 1.0, 0.0); matrModel.Translate(0.0,0.0,sphereRayon/2); matrModel.PushMatrix(); matrModel.Scale(sphereRayon,sphereRayon,cylLongueur); progBase.assignerUniformMatrix4fv( "matrModel", matrModel ); afficherCylindre(); matrModel.PopMatrix(); //3eme sphere matrModel.Translate(0.0,0.0,cylLongueur); matrModel.PushMatrix(); matrModel.Scale(sphereRayon,sphereRayon,sphereRayon); progBase.assignerUniformMatrix4fv( "matrModel", matrModel ); afficherSphere(); matrModel.PopMatrix(); matrModel.Rotate(anglePoignet , 1.0, 0.0, 0.0); //Théière matrModel.Scale(sphereRayon*1.25,sphereRayon*1.25,sphereRayon*1.25); matrModel.Translate(0.0,-1.5,3); matrModel.Rotate(-90, 0.0, 1.0, 0.0); matrModel.Rotate(-90, 1.0, 0.0, 0.0); progBase.assignerUniformMatrix4fv( "matrModel", matrModel ); afficherTheiere(); }