| 1 | class XYZPixel extends SCPattern |
| 2 | { |
| 3 | float xm = model.xMin; |
| 4 | float ym = model.yMin; |
| 5 | float zm = model.zMin; |
| 6 | |
| 7 | float cubeWidth = 35; |
| 8 | float xm2 = model.xMin+cubeWidth; |
| 9 | float ym2 = model.yMin+cubeWidth; |
| 10 | float zm2 = model.zMin+cubeWidth; |
| 11 | |
| 12 | XYZPixel(GLucose glucose) { |
| 13 | super(glucose); |
| 14 | //myP = new LXPoint(20,20,20); |
| 15 | } |
| 16 | |
| 17 | void run(double deltaMs) |
| 18 | { |
| 19 | for(LXPoint p : model.points) |
| 20 | { |
| 21 | if(p.x > xm && p.x<= xm2 && p.y > ym && p.y<= xm2 && p.z<= zm2 && p.z > zm) |
| 22 | { |
| 23 | colors[p.index] = lx.hsb(lx.getBaseHue()+100, 100, 100); |
| 24 | |
| 25 | }else{ |
| 26 | colors[p.index] = 0; |
| 27 | } |
| 28 | } |
| 29 | float minIS=min(model.xMax,model.yMax,model.zMax); |
| 30 | xm = (xm + 1 ) % minIS; |
| 31 | ym = (ym + 1 ) % minIS; |
| 32 | zm = (zm + 1 ) % minIS; |
| 33 | |
| 34 | xm2 = xm + cubeWidth; |
| 35 | ym2 = ym2 + cubeWidth; |
| 36 | zm2 = zm2 + cubeWidth; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | class MultipleCubes extends SCPattern |
| 41 | { |
| 42 | float xm = model.xMin; |
| 43 | float ym = model.yMin+10; |
| 44 | float zm = model.zMin+5; |
| 45 | |
| 46 | float xma = model.xMin; |
| 47 | float xmb = model.xMin; |
| 48 | |
| 49 | float cubeWidth = 35; |
| 50 | |
| 51 | float minIS; |
| 52 | |
| 53 | MultipleCubes(GLucose glucose) { |
| 54 | super(glucose); |
| 55 | minIS = 200; |
| 56 | } |
| 57 | |
| 58 | void drawVirtualCube(float bottomX, float bottomY, float bottomZ, float side, int cubeColor) |
| 59 | { |
| 60 | for(LXPoint p : model.points) |
| 61 | { |
| 62 | if(p.x > bottomX && p.x<= bottomX+side && p.y > bottomY && p.y<= bottomY + side && p.z > bottomZ && p.z<= bottomZ+side) |
| 63 | { |
| 64 | colors[p.index] = cubeColor; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | void clear() |
| 70 | { |
| 71 | for(int i=0;i<colors.length;i++) |
| 72 | { |
| 73 | colors[i]=0; |
| 74 | } |
| 75 | } |
| 76 | float side = 29.0; |
| 77 | int col; |
| 78 | int hueDo; |
| 79 | void run(double deltaMs) |
| 80 | { |
| 81 | boolean up = false; |
| 82 | clear(); |
| 83 | for(int i = 0;i < model.yMax / side; i++) |
| 84 | { |
| 85 | //println(Math.abs(minIS - xm - 30*(i % 3) - xm + 30*(i % 3))); |
| 86 | if(i % 2 ==0) |
| 87 | { |
| 88 | xm = xma; |
| 89 | }else{ |
| 90 | xm = xmb; |
| 91 | } |
| 92 | if(Math.abs(minIS - xm - 30*(i % 3) - xm + 30*(i % 3)) < side * 1.5) |
| 93 | { |
| 94 | hueDo = (hueDo+1) % 255; |
| 95 | up = true; |
| 96 | } |
| 97 | col = lx.hsb(lx.getBaseHue() + hueDo,100,100); |
| 98 | drawVirtualCube(minIS-xm- 30*(i % 3), ym+i*side, zm, side, col); |
| 99 | drawVirtualCube(xm + 30*(i % 3), ym+i*side, zm, side, col); |
| 100 | } |
| 101 | |
| 102 | xma = (xma + 7 ) % minIS; |
| 103 | xmb = (xmb + 3) % minIS; |
| 104 | //ym = (ym + 1 ) % minIS; |
| 105 | //zm = (zm + 1 ) % minIS; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | class TowerParams extends SCPattern |
| 110 | { |
| 111 | BasicParameter hueoff = new BasicParameter("Hueoff", 0.0); |
| 112 | BasicParameter hueSpan = new BasicParameter("HueRange", 0.0); |
| 113 | BasicParameter t1 = new BasicParameter("T1", 0.0); |
| 114 | BasicParameter t2 = new BasicParameter("T2", 0.0); |
| 115 | BasicParameter t3 = new BasicParameter("T3", 0.0); |
| 116 | BasicParameter t4 = new BasicParameter("T4", 0.0); |
| 117 | BasicParameter t5 = new BasicParameter("T5", 0.0); |
| 118 | BasicParameter t6 = new BasicParameter("T6", 0.0); |
| 119 | BasicParameter t7 = new BasicParameter("T7", 0.0); |
| 120 | BasicParameter t8 = new BasicParameter("T8", 0.0); |
| 121 | BasicParameter t9 = new BasicParameter("T9", 0.0); |
| 122 | BasicParameter t10 = new BasicParameter("T10", 0.0); |
| 123 | BasicParameter t11 = new BasicParameter("T11", 0.0); |
| 124 | BasicParameter t12 = new BasicParameter("T12", 0.0); |
| 125 | BasicParameter t13 = new BasicParameter("T13", 0.0); |
| 126 | BasicParameter t14 = new BasicParameter("T14", 0.0); |
| 127 | BasicParameter t15 = new BasicParameter("T15", 0.0); |
| 128 | BasicParameter t16 = new BasicParameter("T16", 0.0); |
| 129 | |
| 130 | ArrayList<BasicParameter> towerParams; |
| 131 | int towerSize; |
| 132 | int colorSpan; |
| 133 | TowerParams(GLucose glucose) { |
| 134 | super(glucose); |
| 135 | |
| 136 | towerParams = new ArrayList<BasicParameter>(); |
| 137 | addParameter(hueoff); |
| 138 | addParameter(hueSpan); |
| 139 | towerParams.add(t1); |
| 140 | towerParams.add(t2); |
| 141 | towerParams.add(t3); |
| 142 | towerParams.add(t4); |
| 143 | towerParams.add(t5); |
| 144 | towerParams.add(t6); |
| 145 | towerParams.add(t7); |
| 146 | towerParams.add(t8); |
| 147 | towerParams.add(t9); |
| 148 | towerParams.add(t10); |
| 149 | towerParams.add(t11); |
| 150 | towerParams.add(t12); |
| 151 | towerParams.add(t13); |
| 152 | towerParams.add(t14); |
| 153 | towerParams.add(t15); |
| 154 | towerParams.add(t16); |
| 155 | for(BasicParameter p : towerParams) |
| 156 | { |
| 157 | addParameter(p); |
| 158 | } |
| 159 | towerSize = model.towers.size(); |
| 160 | colorSpan = 255 / towerSize; |
| 161 | } |
| 162 | |
| 163 | void run(double deltaMs) |
| 164 | { |
| 165 | clearALL(); |
| 166 | Tower t; |
| 167 | for(int i=0; i<towerSize ;i++) |
| 168 | { |
| 169 | t= model.towers.get(i); |
| 170 | for(LXPoint p : t.points) |
| 171 | { |
| 172 | if(p.y<towerParams.get(i).getValuef()*200) |
| 173 | { |
| 174 | colors[p.index]=lx.hsb(255 * hueoff.getValuef()+colorSpan * hueSpan.getValuef() * i, 255, 255); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | } |
| 180 | |
| 181 | public void clearALL() |
| 182 | { |
| 183 | for(LXPoint p : model.points) |
| 184 | { |
| 185 | colors[p.index] = 0; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | } |
| 190 | class Sandbox extends SCPattern |
| 191 | { |
| 192 | int c=0; |
| 193 | int prevC=0; |
| 194 | int huerange=255; |
| 195 | int pointrange= model.points.size(); |
| 196 | int striprange= model.strips.size(); |
| 197 | int facerange= model.faces.size(); |
| 198 | int cuberange = model.cubes.size(); |
| 199 | int towerrange = model.towers.size(); |
| 200 | int counter=0; |
| 201 | |
| 202 | Sandbox(GLucose glucose) { |
| 203 | super(glucose); |
| 204 | println("points "+pointrange); |
| 205 | println("strips "+striprange); |
| 206 | println("faces "+facerange); |
| 207 | println("cubes "+cuberange); |
| 208 | println("towers "+towerrange); |
| 209 | } |
| 210 | |
| 211 | public void run(double deltaMs) { |
| 212 | |
| 213 | |
| 214 | if(counter % 10 ==0) |
| 215 | { |
| 216 | doDraw(c,0); |
| 217 | c = (c + 1) % towerrange; |
| 218 | long col = lx.hsb(Math.round(Math.random()*255),255,255) ; |
| 219 | doDraw(c,col); |
| 220 | } |
| 221 | counter++; |
| 222 | |
| 223 | } |
| 224 | |
| 225 | public void doDraw(int c,long col) |
| 226 | { |
| 227 | Tower t= model.towers.get((int) c); |
| 228 | for(LXPoint p : t.points) |
| 229 | { |
| 230 | colors[p.index] = (int) col; |
| 231 | } |
| 232 | } |
| 233 | }; |
| 234 | |
| 235 | class GranimTestPattern extends GranimPattern |
| 236 | { |
| 237 | GranimTestPattern(GLucose glucose) |
| 238 | { |
| 239 | super(glucose); |
| 240 | addGraphic("myReds",new RedsGraphic(100)); |
| 241 | int[] dots = {0,128,0,128,0,128,0,128,0,128,0,128}; |
| 242 | addGraphic("myOtherColors",new ColorDotsGraphic(dots)); |
| 243 | |
| 244 | getGraphicByName("myOtherColors").position=100; |
| 245 | } |
| 246 | int counter=0; |
| 247 | public void run(double deltaMs) |
| 248 | { |
| 249 | clearALL(); |
| 250 | super.run(deltaMs); |
| 251 | |
| 252 | if(counter % 3 ==0) |
| 253 | { |
| 254 | Graphic reds = getGraphicByName("myReds"); |
| 255 | Graphic others = getGraphicByName("myOtherColors"); |
| 256 | reds.position = reds.position + 1 % 19000; |
| 257 | others.position = others.position + 10 % 19000; |
| 258 | } |
| 259 | } |
| 260 | public void clearALL() |
| 261 | { |
| 262 | for(int i = 0; i < colors.length; i++) |
| 263 | { |
| 264 | colors[i] = 0; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | |
| 269 | } |
| 270 | |
| 271 | class GranimTestPattern2 extends GranimPattern |
| 272 | { |
| 273 | GranimTestPattern2(GLucose glucose) |
| 274 | { |
| 275 | super(glucose); |
| 276 | /*for(int i = 0;i < 100; i++) |
| 277 | { |
| 278 | Graphic g = addGraphic("myReds_"+i,new RedsGraphic(Math.round(Math.random() * 100))); |
| 279 | |
| 280 | }*/ |
| 281 | Graphic g = addGraphic("myRandoms",new RandomsGranim(50)); |
| 282 | g.position = 200; |
| 283 | |
| 284 | } |
| 285 | int counter=0; |
| 286 | float count=0; |
| 287 | public void run(double deltaMs) |
| 288 | { |
| 289 | clearALL(); |
| 290 | super.run(deltaMs); |
| 291 | Graphic randomsGraphic = getGraphicByName("myRandoms"); |
| 292 | randomsGraphic.position = Math.round(sin(count)*1000)+5000; |
| 293 | count+= 0.005; |
| 294 | } |
| 295 | public void clearALL() |
| 296 | { |
| 297 | for(LXPoint p : model.points) |
| 298 | { |
| 299 | colors[p.index] = 0; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | |
| 304 | }; |
| 305 | |
| 306 | class DriveableCrossSections extends CrossSections |
| 307 | { |
| 308 | BasicParameter xd; |
| 309 | BasicParameter yd; |
| 310 | BasicParameter zd; |
| 311 | BasicParameter mode; |
| 312 | |
| 313 | DriveableCrossSections(GLucose glucose) { |
| 314 | super(glucose); |
| 315 | } |
| 316 | |
| 317 | public void addParams() |
| 318 | { |
| 319 | mode = new BasicParameter("Mode", 0.0); |
| 320 | xd = new BasicParameter("XD", 0.0); |
| 321 | yd = new BasicParameter("YD", 0.0); |
| 322 | zd = new BasicParameter("ZD", 0.0); |
| 323 | addParameter(mode); |
| 324 | addParameter(xd); |
| 325 | addParameter(yd); |
| 326 | addParameter(zd); |
| 327 | |
| 328 | super.addParams(); |
| 329 | } |
| 330 | |
| 331 | public void onParameterChanged(LXParameter p) { |
| 332 | if(p == mode) |
| 333 | { |
| 334 | if(interactive()) |
| 335 | { |
| 336 | copyValuesToKnobs(); |
| 337 | }else{ |
| 338 | copyKnobsToValues(); |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | void copyValuesToKnobs() |
| 344 | { |
| 345 | xd.setValue(x.getValue()/200); |
| 346 | yd.setValue(y.getValue()/115); |
| 347 | zd.setValue(z.getValue()/100); |
| 348 | } |
| 349 | |
| 350 | void copyKnobsToValues() |
| 351 | { |
| 352 | x.setValue(xd.getValue()*200); |
| 353 | y.setValue(yd.getValue()*115); |
| 354 | z.setValue(zd.getValue()*100); |
| 355 | } |
| 356 | |
| 357 | boolean interactive() |
| 358 | { |
| 359 | return Math.round(mode.getValuef())>0.5; |
| 360 | } |
| 361 | |
| 362 | public void updateXYZVals() |
| 363 | { |
| 364 | if(interactive()) |
| 365 | { |
| 366 | xv = xd.getValuef()*200; |
| 367 | yv = yd.getValuef()*115; |
| 368 | zv = zd.getValuef()*100; |
| 369 | }else{ |
| 370 | super.updateXYZVals(); |
| 371 | copyValuesToKnobs(); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | } |