cubecenter for cubecurl
[SugarCubes.git] / AlexGreen.pde
index 74033956cfc4ea3151e51dcca36935f853a8a833..f63fb493ec9c1558d2838b67fc97a3942d3a5e40 100755 (executable)
@@ -171,6 +171,79 @@ final Sphery[] spherys;
         
   }
 
+class CubeCurl extends SCPattern{
+float CH, CW;
+private SinLFO curl = new SinLFO(0, Cube.EDGE_HEIGHT, 5000 ); 
+
+private SinLFO bg = new SinLFO(180, 220, 3000);
+
+CubeCurl(GLucose glucose){
+super(glucose);
+addModulator(curl).trigger();
+addModulator(bg).trigger();
+ this.CH = Cube.EDGE_HEIGHT;
+ this.CW = Cube.EDGE_WIDTH;
+final float diag = sqrt(CH*CH + CW*CW + CW*CW);
+ArrayList<PVector> centerlist = new ArrayList<PVector>();
+
+for (int i = 0; i < model.cubes.size(); i++){
+  centerlist.add(centerofcube(i));
+   } 
+
+}
+//there is definitely a better way of doing this!
+PVector centerofcube(int i) { 
+Cube c = model.cubes.get(i);
+PVector cubeorigin = new PVector(c.x, c.y, c.z);
+PVector cubecenter = new PVector(c.x+ CW/2, c.y + CH/2, c.z + CW/2);
+PVector cubeangle = new PVector(c.rx, c.ry, c.rz);
+cubeangle.normalize();
+println( cubeangle.x + cubeangle.y + cubeangle.z);
+PVector cubecenterf = new PVector(cubecenter.x + tan(c.rx)*CW/2, cubecenter.y + tan(c.ry)*CH/2, cubecenter.z + tan(c.rz)*CW/2);
+
+return cubecenterf;
+}
+
+
+void run(double deltaMs){
+for (int i =0; i < model.cubes.size(); i++)  {
+Cube c = model.cubes.get(i);
+float cfloor = c.y;
+
+if (i%3 == 0){
+
+for (Point p : c.points ){
+ // colors[p.index]=color(0,0,0);
+  //float dif = (p.y - c.y);
+  //colors[p.index] = color( bg.getValuef() , 80 , dif < curl.getValuef() ? 80 : 0, ADD);
+   }
+ }
+
+else if (i%3 == 1) {
+  
+ for (Point p: c.points){
+   colors[p.index]=color(0,0,0);
+  float dif = (p.y - c.y);
+  // colors[p.index] = 
+  // color(bg.getValuef(),
+  //   map(curl.getValuef(), 0, Cube.EDGE_HEIGHT, 20, 100), 
+  //   100 - 10*abs(dif - curl.getValuef()), ADD );
+     }
+    }
+else if (i%3 == 2){
+   for (Point p: c.points) {
+    
+
+
+   }
+
+
+}
+
+   }
+  }
+ }
+
  class HueTestHSB extends SCPattern{
   BasicParameter HueT = new BasicParameter("Hue", .5);
   BasicParameter SatT = new BasicParameter("Sat", .5);