3d no Processing
void setup() {
size(400, 400, P3D);
}
void draw() {
background(0);
translate(200, 200, 0);
rotateY(map(mouseX, 0, width, -PI, PI));
box(200);
}
void setup() {
size(400, 400, P3D);
}
void draw() {
background(0);
translate(200, 200, 0);
rotateY(map(mouseX, 0, width, -PI, PI));
box(200);
}
void setup() {
size(400, 400, P3D);
}
void draw() {
background(0);
translate(200, 200, 0);
rotateX(map(mouseY, 0, width, -PI, PI));
sphere(100);
sphereDetail(mouseX);
}
size(100, 100, P3D);
background(0);
noStroke();
ambientLight(50, 255, 102);
translate(32, 50, 0);
rotateY(PI/5);
box(40);
translate(60, 0, 0);
sphere(30);
size(100, 100, P3D);
background(0);
noStroke();
ambientLight(50, 255, 102);
translate(32, 50, 0);
rotateY(PI/5);
box(40);
translate(60, 0, 0);
sphere(30);
Não vem de uma direção específica
O objeto é iluminado igualmente em todos os lados
void setup() {
size(400, 400, P3D);
noStroke();
}
void draw() {
background(0);
ambientLight(128, 128, 128);
directionalLight(0,255,0, -1, 0,0);
translate(width/2, height/2, 0);
rotateY(map(mouseX, 0, width, 0, 2*PI));
rotateX(map(mouseY, 0, height, 0, 2*PI));
box(100);
}
void setup() {
size(400, 400, P3D);
noStroke();
}
void draw() {
background(0);
ambientLight(128, 128, 128);
directionalLight(0,255,0, -1, 0,0);
translate(width/2, height/2, 0);
rotateY(map(mouseX, 0, width, 0, 2*PI));
rotateX(map(mouseY, 0, height, 0, 2*PI));
box(100);
}
Luz que vem de uma direção
Sem localização específica
Luz paralela
Mais forte nas áreas quadradas
Mais fraco nas angulações
O sol
void setup() {
size(400,400,P3D);
noStroke();
}
void draw() {
background(0);
ambientLight(128,128,128);
pointLight(255,0,0,mouseX, mouseY, 0);
directionalLight(0,255,0,-1,0,0);
translate(100,height/2);
sphere(70);
translate(200,0);
sphere(70);
}
void setup() {
size(400,400,P3D);
noStroke();
}
void draw() {
background(0);
ambientLight(128,128,128);
pointLight(255,0,0,mouseX, mouseY, 0);
directionalLight(0,255,0,-1,0,0);
translate(100,height/2);
sphere(70);
translate(200,0);
sphere(70);
}
Proveniente de um ponto
Com localização específica
Espalha a partir do ponto
void setup() {
size(400,400,P3D);
noStroke();
}
void draw() {
background(0);
ambientLight(128,128,128);
spotLight(255,0,0,mouseX, mouseY, 300, 0,0,-1, PI/12, 2);
//pointLight(255,0,0,mouseX, mouseY, 300);
directionalLight(0,255,0,-1,0,0);
translate(width/2,height/2);
sphereDetail(100);
sphere(100);
}
void setup() {
size(400,400,P3D);
noStroke();
}
void draw() {
background(0);
ambientLight(128,128,128);
spotLight(255,0,0,mouseX, mouseY, 300, 0,0,-1, PI/12, 2);
//pointLight(255,0,0,mouseX, mouseY, 300);
directionalLight(0,255,0,-1,0,0);
translate(width/2,height/2);
sphereDetail(100);
sphere(100);
}
Proveniente de um ponto
Com localização específica
Gera um cone de luz a partir do ponto
Texturas estão associadas a vértices
Vértices são consumidos em figuras de diferentes tipos
size(100, 100, P3D); noStroke(); PImage a = loadImage("arch.jpg"); beginShape(); texture(a); vertex(10, 20, 0, 0); vertex(80, 5, 100, 0); vertex(95, 90, 100, 100); vertex(40, 95, 0, 100); endShape();
Coordenadas de mapeamento de textura podem ser normalizadas
PImage textura, textura2;
void setup () {
size(300,300,P3D);
textura = loadImage("eu.jpg");
textura2 = loadImage("textura.jpg");
}
void draw() {
background(0);
translate(width/2,height/2);
rotateX(map(mouseY,0,height,0, 2*PI));
rotateY(map(mouseX,0,height,0, 2*PI));
textureMode(NORMALIZED);
beginShape(QUADS);
texture(textura);
vertex(0,0,0,0,0);
vertex(100,0,0,1,0);
vertex(100,100,0,1,1);
vertex(0,100,0,0,1);
endShape();
beginShape(QUADS);
texture(textura2);
vertex(0,0,0,0,0);
vertex(100,0,0,1,0);
vertex(100,0,100,1,1);
vertex(0,0,100,0, 1);
endShape();
}
import saito.objtools.*;
import saito.objloader.*;
m.drawMode(POLYGON);
m.draw();
// Modelo lamp.obj extraido de: http://people.sc.fsu.edu/~burkardt/data/obj/obj.html
import processing.opengl.*;
import saito.objtools.*;
import saito.objloader.*;
OBJModel m;
void setup() {
size(300,300,OPENGL);
m = new OBJModel(this,"lamp.obj");
smooth();
}
void draw() {
background(255);
lights();
noStroke();
translate(width/2,height/2);
rotateY(map(mouseX,0,width,0,2*PI));
rotateX(map(mouseY,0,height,0,2*PI));
scale(15);
m.drawMode(POLYGON);
m.draw();
}