-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathOrthographic.pde
More file actions
40 lines (34 loc) · 883 Bytes
/
Orthographic.pde
File metadata and controls
40 lines (34 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Perspective vs. Ortho
*
* Move the mouse left to right to change the "far"
* parameter for the perspective() and ortho() functions.
* This parameter sets the maximum distance from the
* origin away from the viewer and will clip the geometry.
* Click a mouse button to switch between the perspective and
* orthographic projections.
*/
boolean showPerspective = false;
void setup() {
size(600, 360, P3D);
noFill();
fill(255);
noStroke();
}
void draw() {
lights();
background(0);
float far = map(mouseX, 0, width, 120, 400);
if (showPerspective == true) {
perspective(PI/3.0, float(width)/float(height), 10, far);
} else {
ortho(-width/2.0, width/2.0, -height/2.0, height/2.0, 10, far);
}
translate(width/2, height/2, 0);
rotateX(-PI/6);
rotateY(PI/3);
box(180);
}
void mousePressed() {
showPerspective = !showPerspective;
}