-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathobjects_3d.pde
104 lines (86 loc) · 2.12 KB
/
objects_3d.pde
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
class Object {
float far = -10000;
float close = 2000;
float x, y, z;
float rotX, rotY, rotZ;
float sumRotX, sumRotY, sumRotZ;
//float scale = 20;
Object() {
x = random(0, width);
y = random(0, height);
z = random(far, close);
rotX = random(0, 1);
rotY = random(0, 1);
rotZ = random(0, 1);
}
void display(float bass, float mid, float treble, float bandVal, float total, boolean eCube, boolean eSphere) {
color displayColor = color(bass/3, mid/3, treble/3, 10+bandVal*5);
fill(displayColor);
color strokeColor = color(255, 150-(20*bandVal));
stroke(strokeColor);
pushMatrix();
translate(x, y, z);
//show sphere
if(eSphere){
noStroke();
lights();
sphere(20);
}
//show Cube
else if(eCube){
strokeWeight(1 + (total/1000));
sumRotX += bandVal*(rotX/1000);
sumRotY += bandVal*(rotY/1000);
sumRotZ += bandVal*(rotZ/1000);
rotateX(sumRotX);
rotateY(sumRotY);
rotateZ(sumRotZ);
box(100 + bandVal);
}
popMatrix();
z+= 1+bandVal*0.2+total*total/10000;
if (z >= close) {
x = random(0, width);
y = random(0, height);
z = far;
}
if(keyPressed){
if(key == '8'){
//going up
y+= (1+bandVal*0.2+total*total/22500);
if (y >= height) {
x = random(0, width);
y = 0;
z = random(far, close);
}
}
if(key == '2'){
//going down
y-= (1+bandVal*0.2+total*total/22500);
if (y <= 0) {
x = random(0, width);
y = height;
z = random(far, close);
}
}
if(key == '6'){
//going right
x-= (1+bandVal*0.2+total*total/22500);
if (x <= 0) {
x = width;
y = random(0, height);
z = random(far, close);
}
}
//going left
if(key == '4'){
x+= (1+bandVal*0.2+total*total/22500);
if (x >= width) {
x = 0;
y = random(0, height);
z = random(far, close);
}
}
}
}
}