bonjour.
Peut on décaler un axe de rotation.Dans le programme suivant j'aimerais mettre l'axe de rotation sur la gauche et non au centre.
float a; void setup(){ size(500,500,P3D); a=0; } void draw(){ background(200); translate(100,150); rotateX(1); fill(50); box(40,40,200); translate(140,50); fill(100); rotate(a); box(200,10,150); if(a<PI/2) { a=a+0.01; } }
Hors ligne
Pour cela, il faut décaler ta figure avant ta rotation. Utilise plutôt la camera pour visualiser dans un angle différent que de faire pivoter la scène.
float a; int largeurPorte, epaisseurPorte, gond; void setup() { size(500, 500, P3D); largeurPorte = 200; epaisseurPorte = 10; gond = 5; a=0; } void draw() { background(200); camera(width / 2, height, 200.0, width/2.0, height/2.0, 0, 0, 1, 0); // Poteau translate(150, height / 2, 0); fill(50); box(40, 40, 200); // Gonds translate(20 + gond, 0, 0); pushMatrix(); translate(0, 0, -50); sphere(gond); popMatrix(); pushMatrix(); translate(0, 0, 50); sphere(gond); popMatrix(); // Porte fill(100); rotate(a); translate(largeurPorte / 2 + gond, 0, 0); box(largeurPorte, epaisseurPorte, 150); if (a<PI/2) { a=a+0.01; } }
Dernière modification par Mushussu (2014-03-23 06:24:46)
Hors ligne
Bonjour.
Merci pour le programme c'est super ;je ne connaissait pas la camera; cela m'a l'air très bien.
Merci.
Hors ligne