functions. Within those two functions are several calls to
, which in 3D space, takes 3 arguments: an x, y, and z.
The code below will draw a four-sided pyramid made up of four triangles, all connected to one point (the
).
void setup() {
size(100, 100, P3D);
}
void draw() {
background(100);
lights();
stroke(0);
fill(255);
translate(width/2, height/2, 0);
rotateX(map(mouseY, 0, height, 0, PI/2));
scale(map(mouseX, 0, width, 10, 40));
beginShape();
//bottom triangle
vertex(-1, -1, -1);
vertex( 1, -1, -1);
//apex
vertex( 0, 0, 1);
//right triangle
vertex( 1, -1, -1);
vertex( 1, 1, -1);
//apex
vertex( 0, 0, 1);
//top triangle
vertex( 1, 1, -1);
vertex(-1, 1, -1);
//apex
vertex( 0, 0, 1);
//left triangle
vertex(-1, 1, -1);
vertex(-1, -1, -1);
//apex
vertex( 0, 0, 1);
endShape();
}
stops recording them.