Exemplos da aula de 3d
// Primeiro exemplo:
size(400,400,P3D);
background(128);
smooth();
pushMatrix(); // Armazena a posição do eixo
translate(width/2,height/2);
rotate(PI/4);
stroke(255,0,0);
line(0,0,400,0); // Eixo x
stroke(0,255,0); // Verde
line(0,0,0,400);
stroke(0,0,255);
rect(-10,-10,20,20);
//rotateX(PI/4);
//rect(-100,100, 200, 200);
popMatrix(); // Volta
rect(-10,-10,20,20);
// Segundo exemplo:
import processing.opengl.*;
void setup() {
size(400,400,OPENGL);
//noStroke();
}
void draw() {
background(128);
translate(width/2,height/2);
// Map é uma regra de 3!
rotateX( map(mouseY,0,height,0,2*PI) );
rotateY( map(mouseX,0,width,0,2*PI) );
//rect(-100,-100,200,200);
//box(50, 100, 30);
sphereDetail(100);
sphere(100);
}
Comentários