» codelab : http://codelab.fr/accueil » Forum : Processing : http://codelab.fr/processing » axe rotation : http://codelab.fr/4894 Ceci est la version imprimable d'un sujet du forum, pour retourner à la version complète : axe rotation |
fabrice54 — 2014-03-23 05:36:04 |
bonjour. Code (P5) :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; } } |
Mushussu — 2014-03-23 06:22:21 |
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; } } |
fabrice54 — 2014-03-23 07:05:51 |
Bonjour. |