Contents
- 3D
- P3D
- Peasy Cam
- 3D Objects
- PVector
- Declaration
- Functions
- Practice
3D
P3D
void setup(){
size(500,500,P3D);
stroke(255);
strokeWeight(10);
}
void draw(){
background(0);
point(width/2-50,height/2-50,-50);
point(width/2-50,height/2+50,-50);
point(width/2-50,height/2+50,50);
point(width/2-50,height/2-50,50);
point(width/2+50,height/2-50,-50);
point(width/2+50,height/2+50,-50);
point(width/2+50,height/2+50,50);
point(width/2+50,height/2-50,50);
}
Peasy Cam
import peasy.*;
PeasyCam cam;
void setup() {
size(500,500,P3D);
strokeWeight(10);
stroke(255);
cam = new PeasyCam(this, 100);
cam.setMinimumDistance(50);
cam.setMaximumDistance(500);
}
void draw(){
background(0);
point(-50,-50,-50);
point(-50,+50,-50);
point(-50,+50,50);
point(-50,-50,50);
point(+50,-50,-50);
point(+50,+50,-50);
point(+50,+50,50);
point(+50,-50,50);
}
3D Objects
- pushMatrix();
- popMatrix();
- translate(<x>,<y>,<z>);
- rotateX(<rad>);
- Box(<w>,<h>,<d>);
- Sphere(<r>);
import peasy.*;
PeasyCam cam;
void setup() {
size(500,500,P3D);
stroke(255);
noFill();
cam = new PeasyCam(this, 200);
cam.setMinimumDistance(100);
cam.setMaximumDistance(400);
}
void draw(){
background(0);
pushMatrix();
translate(50,0,0);
box(20,30,40);
translate(-100,0,0);
sphere(30);
popMatrix();
}
PVector
Declaration
<PVector name> = new PVector(<x>,<y>,<z>);
PVector p;
p = new PVector(10,20);
ellipse(p.x, p.y, 10, 10);
Functions