Simplest possible 16 param animation for dan's input devices
[SugarCubes.git] / BenMorrow.pde
1 class TowerParams extends SCPattern
2 {
3 BasicParameter t1 = new BasicParameter("T1", 0.0);
4 BasicParameter t2 = new BasicParameter("T2", 0.0);
5 BasicParameter t3 = new BasicParameter("T3", 0.0);
6 BasicParameter t4 = new BasicParameter("T4", 0.0);
7 BasicParameter t5 = new BasicParameter("T5", 0.0);
8 BasicParameter t6 = new BasicParameter("T6", 0.0);
9 BasicParameter t7 = new BasicParameter("T7", 0.0);
10 BasicParameter t8 = new BasicParameter("T8", 0.0);
11 BasicParameter t9 = new BasicParameter("T9", 0.0);
12 BasicParameter t10 = new BasicParameter("T10", 0.0);
13 BasicParameter t11 = new BasicParameter("T11", 0.0);
14 BasicParameter t12 = new BasicParameter("T12", 0.0);
15 BasicParameter t13 = new BasicParameter("T13", 0.0);
16 BasicParameter t14 = new BasicParameter("T14", 0.0);
17 BasicParameter t15 = new BasicParameter("T15", 0.0);
18 BasicParameter t16 = new BasicParameter("T16", 0.0);
19
20 ArrayList<BasicParameter> towerParams;
21 int towerSize;
22 TowerParams(GLucose glucose) {
23 super(glucose);
24
25 towerParams = new ArrayList<BasicParameter>();
26 towerParams.add(t1);
27 towerParams.add(t2);
28 towerParams.add(t3);
29 towerParams.add(t4);
30 towerParams.add(t5);
31 towerParams.add(t6);
32 towerParams.add(t7);
33 towerParams.add(t8);
34 towerParams.add(t9);
35 towerParams.add(t10);
36 towerParams.add(t11);
37 towerParams.add(t12);
38 towerParams.add(t13);
39 towerParams.add(t14);
40 towerParams.add(t15);
41 towerParams.add(t16);
42 for(BasicParameter p : towerParams)
43 {
44 addParameter(p);
45 }
46 towerSize = model.towers.size();
47 println("towers "+towerSize);
48 }
49
50 void run(int deltaMs)
51 {
52 clearALL();
53 Tower t;
54 for(int i=0; i<towerSize ;i++)
55 {
56 t= model.towers.get(i);
57 for(Point p : t.points)
58 {
59 if(p.y<towerParams.get(i).getValuef()*200)
60 {
61 colors[p.index]=color(70*i,255,255);
62 }
63 }
64 }
65
66 }
67
68 public void clearALL()
69 {
70 for(Point p : model.points)
71 {
72 colors[p.index] = 0;
73 }
74 }
75
76 }
77 class Sandbox extends SCPattern
78 {
79 int c=0;
80 int prevC=0;
81 int huerange=255;
82 int pointrange= model.points.size();
83 int striprange= model.strips.size();
84 int facerange= model.faces.size();
85 int cuberange = model.cubes.size();
86 int towerrange = model.towers.size();
87 int counter=0;
88
89 Sandbox(GLucose glucose) {
90 super(glucose);
91 println("points "+pointrange);
92 println("strips "+striprange);
93 println("faces "+facerange);
94 println("cubes "+cuberange);
95 println("towers "+towerrange);
96 }
97
98 public void run(int deltaMs) {
99
100
101 if(counter % 10 ==0)
102 {
103 doDraw(c,0);
104 c = (c + 1) % towerrange;
105 long col = color(Math.round(Math.random()*255),255,255) ;
106 doDraw(c,col);
107 }
108 counter++;
109
110 }
111
112 public void doDraw(int c,long col)
113 {
114 Tower t= model.towers.get((int) c);
115 for(Point p : t.points)
116 {
117 colors[p.index] = (int) col;
118 }
119 }
120 };
121
122 class GranimTestPattern extends GranimPattern
123 {
124 GranimTestPattern(GLucose glucose)
125 {
126 super(glucose);
127 addGraphic("myReds",new RedsGraphic(100));
128 int[] dots = {0,128,0,128,0,128,0,128,0,128,0,128};
129 addGraphic("myOtherColors",new ColorDotsGraphic(dots));
130
131 getGraphicByName("myOtherColors").position=100;
132 }
133 int counter=0;
134 public void run(int deltaMs)
135 {
136 clearALL();
137 super.run(deltaMs);
138
139 if(counter % 3 ==0)
140 {
141 Graphic reds = getGraphicByName("myReds");
142 Graphic others = getGraphicByName("myOtherColors");
143 reds.position = reds.position + 1 % 19000;
144 others.position = others.position + 10 % 19000;
145 }
146 }
147 public void clearALL()
148 {
149 for(int i = 0; i < colors.length; i++)
150 {
151 colors[i] = 0;
152 }
153 }
154
155
156 }
157
158 class GranimTestPattern2 extends GranimPattern
159 {
160 GranimTestPattern2(GLucose glucose)
161 {
162 super(glucose);
163 /*for(int i = 0;i < 100; i++)
164 {
165 Graphic g = addGraphic("myReds_"+i,new RedsGraphic(Math.round(Math.random() * 100)));
166
167 }*/
168 Graphic g = addGraphic("myRandoms",new RandomsGranim(50));
169 g.position = 200;
170
171 }
172 int counter=0;
173 float count=0;
174 public void run(int deltaMs)
175 {
176 clearALL();
177 super.run(deltaMs);
178 Graphic randomsGraphic = getGraphicByName("myRandoms");
179 randomsGraphic.position = Math.round(sin(count)*1000)+5000;
180 count+= 0.005;
181 }
182 public void clearALL()
183 {
184 for(Point p : model.points)
185 {
186 colors[p.index] = 0;
187 }
188 }
189
190
191 };
192
193 class DriveableCrossSections extends CrossSections
194 {
195 BasicParameter xd;
196 BasicParameter yd;
197 BasicParameter zd;
198 BasicParameter mode;
199
200 DriveableCrossSections(GLucose glucose) {
201 super(glucose);
202 }
203
204 public void addParams()
205 {
206 mode = new BasicParameter("Mode", 0.0);
207 xd = new BasicParameter("XD", 0.0);
208 yd = new BasicParameter("YD", 0.0);
209 zd = new BasicParameter("ZD", 0.0);
210 addParameter(mode);
211 addParameter(xd);
212 addParameter(yd);
213 addParameter(zd);
214
215 super.addParams();
216 }
217
218 public void onParameterChanged(LXParameter p) {
219 if(p == mode)
220 {
221 if(interactive())
222 {
223 copyValuesToKnobs();
224 }else{
225 copyKnobsToValues();
226 }
227 }
228 }
229
230 void copyValuesToKnobs()
231 {
232 xd.setValue(x.getValue()/200);
233 yd.setValue(y.getValue()/115);
234 zd.setValue(z.getValue()/100);
235 }
236
237 void copyKnobsToValues()
238 {
239 x.setValue(xd.getValue()*200);
240 y.setValue(yd.getValue()*115);
241 z.setValue(zd.getValue()*100);
242 }
243
244 boolean interactive()
245 {
246 return Math.round(mode.getValuef())>0.5;
247 }
248
249 public void updateXYZVals()
250 {
251 if(interactive())
252 {
253 xv = xd.getValuef()*200;
254 yv = yd.getValuef()*115;
255 zv = zd.getValuef()*100;
256 }else{
257 super.updateXYZVals();
258 copyValuesToKnobs();
259 }
260 }
261
262 }