-
Notifications
You must be signed in to change notification settings - Fork 9
/
BenMorrow.pde
186 lines (160 loc) · 3.42 KB
/
BenMorrow.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
class Sandbox extends SCPattern
{
int c=0;
int prevC=0;
int huerange=255;
int pointrange= model.points.size();
int striprange= model.strips.size();
int facerange= model.faces.size();
int cuberange = model.cubes.size();
int towerrange = model.towers.size();
int counter=0;
Sandbox(GLucose glucose) {
super(glucose);
println("points "+pointrange);
println("strips "+striprange);
println("faces "+facerange);
println("cubes "+cuberange);
println("towers "+towerrange);
}
public void run(int deltaMs) {
if(counter % 10 ==0)
{
doDraw(c,0);
c = (c + 1) % towerrange;
long col = color(Math.round(Math.random()*255),255,255) ;
doDraw(c,col);
}
counter++;
}
public void doDraw(int c,long col)
{
Tower t= model.towers.get((int) c);
for(Point p : t.points)
{
colors[p.index] = (int) col;
}
}
};
class GranimTestPattern extends GranimPattern
{
GranimTestPattern(GLucose glucose)
{
super(glucose);
addGraphic("myReds",new RedsGraphic(100));
int[] dots = {0,128,0,128,0,128,0,128,0,128,0,128};
addGraphic("myOtherColors",new ColorDotsGraphic(dots));
getGraphicByName("myOtherColors").position=100;
}
int counter=0;
public void run(int deltaMs)
{
clearALL();
super.run(deltaMs);
if(counter % 3 ==0)
{
Graphic reds = getGraphicByName("myReds");
Graphic others = getGraphicByName("myOtherColors");
reds.position = reds.position + 1 % 19000;
others.position = others.position + 10 % 19000;
}
}
public void clearALL()
{
for(int i = 0; i < colors.length; i++)
{
colors[i] = 0;
}
}
}
class GranimTestPattern2 extends GranimPattern
{
GranimTestPattern2(GLucose glucose)
{
super(glucose);
/*for(int i = 0;i < 100; i++)
{
Graphic g = addGraphic("myReds_"+i,new RedsGraphic(Math.round(Math.random() * 100)));
}*/
Graphic g = addGraphic("myRandoms",new RandomsGranim(50));
g.position = 200;
}
int counter=0;
float count=0;
public void run(int deltaMs)
{
clearALL();
super.run(deltaMs);
Graphic randomsGraphic = getGraphicByName("myRandoms");
randomsGraphic.position = Math.round(sin(count)*1000)+5000;
count+= 0.005;
}
public void clearALL()
{
for(Point p : model.points)
{
colors[p.index] = 0;
}
}
};
class DriveableCrossSections extends CrossSections
{
BasicParameter xd;
BasicParameter yd;
BasicParameter zd;
BasicParameter mode;
DriveableCrossSections(GLucose glucose) {
super(glucose);
}
public void addParams()
{
mode = new BasicParameter("Mode", 0.0);
xd = new BasicParameter("XD", 0.0);
yd = new BasicParameter("YD", 0.0);
zd = new BasicParameter("ZD", 0.0);
addParameter(mode);
addParameter(xd);
addParameter(yd);
addParameter(zd);
super.addParams();
}
public void onParameterChanged(LXParameter p) {
if(p == mode)
{
if(interactive())
{
copyValuesToKnobs();
}else{
copyKnobsToValues();
}
}
}
void copyValuesToKnobs()
{
xd.setValue(x.getValue()/200);
yd.setValue(y.getValue()/115);
zd.setValue(z.getValue()/100);
}
void copyKnobsToValues()
{
x.setValue(xd.getValue()*200);
y.setValue(yd.getValue()*115);
z.setValue(zd.getValue()*100);
}
boolean interactive()
{
return Math.round(mode.getValuef())>0.5;
}
public void updateXYZVals()
{
if(interactive())
{
xv = xd.getValuef()*200;
yv = yd.getValuef()*115;
zv = zd.getValuef()*100;
}else{
super.updateXYZVals();
copyValuesToKnobs();
}
}
}