Merge branch 'master' of https://github.com/sugarcubes/SugarCubes
authorLeighton Wallace <lwallace@gmail.com>
Sun, 24 Nov 2013 02:13:40 +0000 (18:13 -0800)
committerLeighton Wallace <lwallace@gmail.com>
Sun, 24 Nov 2013 02:13:40 +0000 (18:13 -0800)
Conflicts:
SugarCubes.pde

BenMorrow.pde
JackStahl.pde
JackieBavaro.pde [new file with mode: 0644]
SugarCubes.pde
TimBavaro.pde
VincentSiao.pde [new file with mode: 0644]
_Internals.pde
_Mappings.pde
_PandaDriver.pde

index 51945a8de70b68902a180e0979a8996d43a43cbb..f88e20857da377cfe5e67f41e4d98147025368d6 100644 (file)
@@ -1,3 +1,111 @@
+class XYZPixel extends SCPattern
+{
+       float xm = model.xMin;
+       float ym = model.yMin;
+       float zm = model.zMin;
+
+       float cubeWidth = 35;
+       float xm2 = model.xMin+cubeWidth;
+       float ym2 = model.yMin+cubeWidth;
+       float zm2 = model.zMin+cubeWidth;
+
+       XYZPixel(GLucose glucose) {
+               super(glucose);
+               //myP = new LXPoint(20,20,20);
+       }
+
+       void run(double deltaMs)
+       {
+               for(LXPoint p : model.points)
+               {
+                       if(p.x > xm && p.x<= xm2 && p.y > ym && p.y<= xm2 && p.z<= zm2 && p.z > zm)
+                       {
+                               colors[p.index] = lx.hsb(lx.getBaseHue()+100, 100, 100);
+                       
+                       }else{
+                               colors[p.index] = 0;
+                       }
+               }
+               float minIS=min(model.xMax,model.yMax,model.zMax);
+               xm = (xm + 1 ) % minIS;
+               ym = (ym + 1 ) % minIS;
+               zm = (zm + 1 ) % minIS;
+
+               xm2 = xm + cubeWidth;
+               ym2 = ym2 + cubeWidth;
+               zm2 = zm2 + cubeWidth;
+       }
+}
+
+class MultipleCubes extends SCPattern
+{
+       float xm = model.xMin;
+       float ym = model.yMin+10;
+       float zm = model.zMin+5;
+
+       float xma = model.xMin;
+       float xmb = model.xMin;
+
+       float cubeWidth = 35;
+
+       float minIS;
+
+       MultipleCubes(GLucose glucose) {
+               super(glucose);
+               minIS = 200;
+       }
+
+       void drawVirtualCube(float bottomX, float bottomY, float bottomZ, float side, int cubeColor)
+       {
+               for(LXPoint p : model.points)
+               {
+                       if(p.x > bottomX && p.x<= bottomX+side && p.y > bottomY && p.y<= bottomY + side  && p.z > bottomZ &&  p.z<= bottomZ+side)
+                       {
+                               colors[p.index] = cubeColor;
+                       }
+               }
+       }
+
+       void clear()
+       {
+               for(int i=0;i<colors.length;i++)
+               {
+                       colors[i]=0;
+               }
+       }
+       float side = 29.0;
+       int col;
+       int hueDo;
+       void run(double deltaMs)
+       {
+               boolean up = false;
+               clear();
+               for(int i = 0;i < model.yMax / side; i++)
+               {
+                       //println(Math.abs(minIS - xm - 30*(i % 3) - xm + 30*(i % 3)));
+                       if(i % 2 ==0)
+                       {
+                               xm = xma;
+                       }else{
+                               xm = xmb;
+                       }
+                       if(Math.abs(minIS - xm - 30*(i % 3) - xm + 30*(i % 3)) < side * 1.5)
+                       {
+                               hueDo = (hueDo+1) % 255;
+                               up = true;
+                       }
+                       col =  lx.hsb(lx.getBaseHue() + hueDo,100,100);
+                       drawVirtualCube(minIS-xm- 30*(i % 3), ym+i*side, zm, side, col);
+                       drawVirtualCube(xm + 30*(i % 3), ym+i*side, zm, side, col);
+               }
+               
+               xma = (xma + 7 ) % minIS;
+               xmb = (xmb + 3) % minIS;
+               //ym = (ym + 1 ) % minIS;
+               //zm = (zm + 1 ) % minIS;
+       }
+}
+
 class TowerParams extends SCPattern
 {
        BasicParameter hueoff = new BasicParameter("Hueoff", 0.0);
index 862558ce21f90f5c3c9798cff8fdef5872453dc1..4299543b63119b222062060b6c4b9cd5f4651367 100644 (file)
@@ -10,61 +10,70 @@ class Swim extends SCPattern {
 
   // Projection stuff
   private final LXProjection projection;
-  SawLFO rotation = new SawLFO(0, TWO_PI, 19000);
-  SinLFO yPos = new SinLFO(-25, 25, 12323);
-  final BasicParameter xAngle = new BasicParameter("XANG", 0.9);
-  final BasicParameter yAngle = new BasicParameter("YANG", 0.3);
-  final BasicParameter zAngle = new BasicParameter("ZANG", 0.3);
+  SinLFO rotationX = new SinLFO(-PI/16, PI/8, 9000);
+  SinLFO rotationY = new SinLFO(-PI/8, PI/8, 7000);
+  SinLFO rotationZ = new SinLFO(-PI/8, PI/16, 11000);
+  SinLFO yPos = new SinLFO(-1, 1, 13234);
+  SinLFO sineHeight = new SinLFO(1, 2.5, 13234);
+  SawLFO phaseLFO = new SawLFO(0, 2 * PI, 15000 - 13000 * 0.5);
+  final BasicParameter phaseParam = new BasicParameter("Spd", 0.5);
+  final BasicParameter crazyParam = new BasicParameter("Crzy", 0.5);
 
   final BasicParameter hueScale = new BasicParameter("HUE", 0.3);
 
   public Swim(GLucose glucose) {
     super(glucose);
     projection = new LXProjection(model);
-
-    addParameter(xAngle);
-    addParameter(yAngle);
-    addParameter(zAngle);
     addParameter(hueScale);
+    addParameter(crazyParam);
+    addParameter(phaseParam);
 
-    addModulator(rotation).trigger();
+    addModulator(rotationX).trigger();
+    addModulator(rotationY).trigger();
+    addModulator(rotationZ).trigger();
     addModulator(yPos).trigger();
+    addModulator(phaseLFO).trigger();
+  }
+  
+  public void onParameterChanged(LXParameter parameter) {
+    if (parameter == phaseParam) {
+      phaseLFO.setDuration(5000 - 4500 * parameter.getValuef());
+    }
   }
-
 
   int beat = 0;
   float prevRamp = 0;
   void run(double deltaMs) {
 
-    // Sync to the beat
-    float ramp = (float)lx.tempo.ramp();
-    if (ramp < prevRamp) {
-      beat = (beat + 1) % 4;
-    }
-    prevRamp = ramp;
-    float phase = (beat+ramp) / 2.0 * 2 * PI;
-
-    float denominator = max(xAngle.getValuef() + yAngle.getValuef() + zAngle.getValuef(), 1);
+    float phase = phaseLFO.getValuef();
+    
+    float up_down_range = (model.yMax - model.yMin) / 4;
 
+    // Swim around the world
+    float crazy_factor = crazyParam.getValuef() / 0.2;
     projection.reset()
-      // Swim around the world
-      .rotate(rotation.getValuef(), xAngle.getValuef() / denominator, yAngle.getValuef() / denominator, zAngle.getValuef() / denominator)
-        .translateCenter(0, 50 + yPos.getValuef(), 0);
+    .rotate(rotationZ.getValuef() * crazy_factor,  0, 1, 0)
+      .rotate(rotationX.getValuef() * crazy_factor, 0, 0, 1)
+        .rotate(rotationY.getValuef() * crazy_factor, 0, 1, 0)
+          .translate(0, up_down_range * yPos.getValuef(), 0);
+
 
     float model_height =  model.yMax - model.yMin;
     float model_width =  model.xMax - model.xMin;
     for (LXVector p : projection) {
       float x_percentage = (p.x - model.xMin)/model_width;
 
-      // Multiply by 1.4 to shrink the size of the sin wave to be less than the height of the cubes.
-      float y_in_range = 1.4 * (2*p.y - model.yMax - model.yMin) / model_height;
+      // Multiply by sineHeight to shrink the size of the sin wave to be less than the height of the cubes.
+      float y_in_range = sineHeight.getValuef() * (2*p.y - model.yMax - model.yMin) / model_height;
       float sin_x =  sin(phase + 2 * PI * x_percentage);       
 
-      // Color fade near the top of the sin wave
-      float v1 = sin_x > y_in_range  ? (100 + 100*(y_in_range - sin_x)) : 0;     
+      float size_of_sin_wave = 0.4;
+      
+      float v1 = (abs(y_in_range - sin_x) > size_of_sin_wave) ? 0 : abs((y_in_range - sin_x + size_of_sin_wave) / size_of_sin_wave / 2 * 100);
+
 
       float hue_color = (lx.getBaseHuef() + hueScale.getValuef() * (abs(p.x-model.xMax/2.)*.3 + abs(p.y-model.yMax/2)*.9 + abs(p.z - model.zMax/2.))) % 360;
-      colors[p.index] = lx.hsb(hue_color, 70, v1);
+      colors[p.index] = lx.hsb(hue_color, 100, v1);
     }
   }
 }
diff --git a/JackieBavaro.pde b/JackieBavaro.pde
new file mode 100644 (file)
index 0000000..fc1576a
--- /dev/null
@@ -0,0 +1,265 @@
+class JackieSquares extends SCPattern {
+  private BasicParameter rateParameter = new BasicParameter("RATE", 0.25);
+  private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3);
+  private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2);
+  private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7);
+    
+  SinLFO hueMod = new SinLFO(0, 360, 4000);
+  SinLFO spreadMod = new SinLFO(1, 10, 8000);
+
+  
+  class FaceFlash {
+    Face f;
+    float value;
+    float hue;
+    boolean hasPeaked;
+    
+    FaceFlash(int n) {
+      f = model.faces.get(n % model.faces.size());
+      hue = random(360);
+      boolean infiniteAttack = (attackParameter.getValuef() > 0.999);
+      hasPeaked = infiniteAttack;
+      value = (infiniteAttack ? 1 : 0);
+    }
+    
+    // returns TRUE if this should die
+    boolean age(double ms) {
+      if (!hasPeaked) {
+        value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5));
+        if (value >= 1.0) {
+          value = 1.0;
+          hasPeaked = true;
+        }
+        return false;
+      } else {
+        value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10));
+        return value <= 0;
+      }
+    }
+  }
+  
+  private float leftoverMs = 0;
+  private List<FaceFlash> flashes;
+  private int faceNum = 0;
+  
+  public JackieSquares(GLucose glucose) {
+    super(glucose);
+    addParameter(rateParameter);
+    addParameter(attackParameter);
+    addParameter(decayParameter);
+    addParameter(saturationParameter);
+    addModulator(hueMod).trigger();
+    addModulator(spreadMod).trigger();
+
+    flashes = new LinkedList<FaceFlash>();
+  }
+  
+  public void run(double deltaMs) {
+    leftoverMs += deltaMs;
+    float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100);
+    while (leftoverMs > msPerFlash) {
+      leftoverMs -= msPerFlash;
+      faceNum += int(spreadMod.getValuef());
+      flashes.add(new FaceFlash(faceNum));
+    }
+    
+    for (LXPoint p : model.points) {
+      colors[p.index] = 0;
+    }
+    
+    for (FaceFlash flash : flashes) {
+      float hue = (hueMod.getValuef() + flash.hue) % 360.0;
+      color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100);
+      for (LXPoint p : flash.f.points) {
+        colors[p.index] = c;
+      }
+    }
+    
+    Iterator<FaceFlash> i = flashes.iterator();
+    while (i.hasNext()) {
+      FaceFlash flash = i.next();
+      boolean dead = flash.age(deltaMs);
+      if (dead) {
+        i.remove();
+      }
+    }
+  } 
+}
+
+
+class JackieLines extends SCPattern {
+  private BasicParameter rateParameter = new BasicParameter("RATE", 0.25);
+  private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3);
+  private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2);
+  private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7);
+    
+  SinLFO hueMod = new SinLFO(0, 360, 4000);
+  SinLFO spreadMod = new SinLFO(1, 10, 8000);
+
+  
+  class StripFlash {
+    Strip f;
+    float value;
+    float hue;
+    boolean hasPeaked;
+    
+    StripFlash(int n) {
+      f = model.strips.get(n % model.strips.size());
+      hue = random(360);
+      boolean infiniteAttack = (attackParameter.getValuef() > 0.999);
+      hasPeaked = infiniteAttack;
+      value = (infiniteAttack ? 1 : 0);
+    }
+    
+    // returns TRUE if this should die
+    boolean age(double ms) {
+      if (!hasPeaked) {
+        value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5));
+        if (value >= 1.0) {
+          value = 1.0;
+          hasPeaked = true;
+        }
+        return false;
+      } else {
+        value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10));
+        return value <= 0;
+      }
+    }
+  }
+  
+  private float leftoverMs = 0;
+  private List<StripFlash> flashes;
+  private int stripNum = 0;
+  
+  public JackieLines(GLucose glucose) {
+    super(glucose);
+    addParameter(rateParameter);
+    addParameter(attackParameter);
+    addParameter(decayParameter);
+    addParameter(saturationParameter);
+    addModulator(hueMod).trigger();
+    addModulator(spreadMod).trigger();
+
+    flashes = new LinkedList<StripFlash>();
+  }
+  
+  public void run(double deltaMs) {
+    leftoverMs += deltaMs;
+    float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100);
+    while (leftoverMs > msPerFlash) {
+      leftoverMs -= msPerFlash;
+      stripNum += int(spreadMod.getValuef());
+      flashes.add(new StripFlash(stripNum));
+    }
+    
+    for (LXPoint p : model.points) {
+      colors[p.index] = 0;
+    }
+    
+    for (StripFlash flash : flashes) {
+      float hue = (hueMod.getValuef() + flash.hue) % 360.0;
+      color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100);
+      for (LXPoint p : flash.f.points) {
+        colors[p.index] = c;
+      }
+    }
+    
+    Iterator<StripFlash> i = flashes.iterator();
+    while (i.hasNext()) {
+      StripFlash flash = i.next();
+      boolean dead = flash.age(deltaMs);
+      if (dead) {
+        i.remove();
+      }
+    }
+  } 
+}
+
+
+
+class JackieDots extends SCPattern {
+  private BasicParameter rateParameter = new BasicParameter("RATE", 0.15);
+  private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3);
+  private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2);
+  private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7);
+    
+  SinLFO hueMod = new SinLFO(0, 360, 4000);
+  SinLFO spreadMod = new SinLFO(1, 10, 16000);
+
+  
+  class PointFlash {
+    LXPoint f;
+    float value;
+    float hue;
+    boolean hasPeaked;
+    
+    PointFlash(int n) {
+      f = model.points.get(n % model.points.size());
+      hue = random(360);
+      boolean infiniteAttack = (attackParameter.getValuef() > 0.999);
+      hasPeaked = infiniteAttack;
+      value = (infiniteAttack ? 1 : 0);
+    }
+    
+    // returns TRUE if this should die
+    boolean age(double ms) {
+      if (!hasPeaked) {
+        value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5));
+        if (value >= 1.0) {
+          value = 1.0;
+          hasPeaked = true;
+        }
+        return false;
+      } else {
+        value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10));
+        return value <= 0;
+      }
+    }
+  }
+  
+  private float leftoverMs = 0;
+  private List<PointFlash> flashes;
+  private int pointNum = 0;
+  
+  public JackieDots(GLucose glucose) {
+    super(glucose);
+    addParameter(rateParameter);
+    addParameter(attackParameter);
+    addParameter(decayParameter);
+    addParameter(saturationParameter);
+    addModulator(hueMod).trigger();
+    addModulator(spreadMod).trigger();
+
+    flashes = new LinkedList<PointFlash>();
+  }
+  
+  public void run(double deltaMs) {
+    leftoverMs += deltaMs;
+    float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 5000);
+    while (leftoverMs > msPerFlash) {
+      leftoverMs -= msPerFlash;
+      pointNum += int(spreadMod.getValuef());
+      flashes.add(new PointFlash(pointNum));
+    }
+    
+    for (LXPoint p : model.points) {
+      colors[p.index] = 0;
+    }
+    
+    for (PointFlash flash : flashes) {
+      float hue = (hueMod.getValuef() + flash.hue) % 360.0;
+      color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100);
+      colors[flash.f.index] = c;
+    }
+    
+    Iterator<PointFlash> i = flashes.iterator();
+    while (i.hasNext()) {
+      PointFlash flash = i.next();
+      boolean dead = flash.age(deltaMs);
+      if (dead) {
+        i.remove();
+      }
+    }
+  } 
+}
+
index c1d74a02472e381c10593d3945145c5b3f8cb5b9..2c9ecab95c290689624babc0a7d224167ed8453d 100644 (file)
@@ -43,6 +43,8 @@ LXPattern[] patterns(GLucose glucose) {
     new Blinders(glucose),
     new CrossSections(glucose),
     new Psychedelia(glucose),
+
+    new MultipleCubes(glucose),
     
     new Traktor(glucose).setEligible(false),
     new BassPod(glucose).setEligible(false),
@@ -58,14 +60,25 @@ LXPattern[] patterns(GLucose glucose) {
     // Alex G
      
      // Tim
+    new TimMetronome(glucose),
     new TimPlanes(glucose),
     new TimPinwheels(glucose),
     new TimRaindrops(glucose),
     new TimCubes(glucose),
     // new TimTrace(glucose),
     new TimSpheres(glucose),
+    
+    
+
+    // Jackie
+    new JackieSquares(glucose),
+    new JackieLines(glucose),
+    new JackieDots(glucose),
+
 
 
+    // Vincent
+    new VSTowers(glucose),
     
     // Toby
     new GlitchPlasma(glucose),
index 5ed805ba7265d565d5c90b5bed05220a7eba0af1..3fcd5b160353986498ff01793cd8cf64c5d05bf9 100644 (file)
@@ -3,8 +3,9 @@
  */
 class TimSpheres extends SCPattern {
   private BasicParameter hueParameter = new BasicParameter("RAD", 1.0);
+  private BasicParameter periodParameter = new BasicParameter("PERIOD", 4000.0, 200.0, 10000.0);
   private final SawLFO lfo = new SawLFO(0, 1, 10000);
-  private final SinLFO sinLfo = new SinLFO(0, 1, 4000);
+  private final SinLFO sinLfo = new SinLFO(0, 1, periodParameter);
   private final float centerX, centerY, centerZ;
   
   class Sphere {
@@ -18,6 +19,7 @@ class TimSpheres extends SCPattern {
   public TimSpheres(GLucose glucose) {
     super(glucose);
     addParameter(hueParameter);
+    addParameter(periodParameter);
     addModulator(lfo).trigger();
     addModulator(sinLfo).trigger();
     centerX = (model.xMax + model.xMin) / 2;
@@ -828,3 +830,72 @@ class TimTrace extends SCPattern {
     }
   }
 }
+
+class TimMetronome extends SCPattern {
+  private BasicParameter clickyParameter = new BasicParameter("CLICK", 0, 0, 10.0);
+  private BasicParameter derezParameter = new BasicParameter("DREZ", 0.5, 0, 1.0);
+  private BasicParameter driftParameter = new BasicParameter("DRIFT", 0, 0, 1.0);
+  private BasicParameter fadeParameter = new BasicParameter("FADE", 0.05, 0, 0.2);
+  private float modelWidth;
+  private int beatNum;
+  private float prevTempoRamp;
+  private LXProjection projection;
+  private float[] values;
+  private float[] hues;
+  
+  TimMetronome(GLucose glucose) {
+    super(glucose);
+    addParameter(clickyParameter);
+    addParameter(derezParameter);
+    addParameter(driftParameter);
+    addParameter(fadeParameter);
+    modelWidth = model.xMax - model.xMin;
+    projection = new LXProjection(model);
+    beatNum = 0;
+    prevTempoRamp = 0;
+    values = new float[model.points.size()];
+    hues = new float[model.points.size()];
+  }
+  
+  public void run(double deltaMs) {
+    float tempoRamp = lx.tempo.rampf();
+    if (tempoRamp < prevTempoRamp) {
+      beatNum = (beatNum + 1) % 1000;
+    }
+    prevTempoRamp = tempoRamp;
+    
+    float phase = beatNum + pow(tempoRamp, 1.0 + clickyParameter.getValuef());
+    
+    projection.reset();
+    projection.translateCenter(model.xMin, model.yMin, model.cz);
+    projection.rotate(phase * 0.5 * PI, 0, 0, 1);
+    
+    projection.translate(driftParameter.getValuef() * tempoRamp * modelWidth * 0.5, 0, 0);
+    
+    float derezCutoff = derezParameter.getValuef();
+    
+    float fadeMultiplier = (1.0 - fadeParameter.getValuef());
+    
+    float armRadius = modelWidth * 0.1;
+    for (LXVector p : projection) {
+      boolean onArm = false;
+      if (abs(p.x) < armRadius) {
+        onArm = (p.y > 0) || (sqrt(pow(p.x, 2) + pow(p.y, 2)) < armRadius);
+      }
+      if (onArm) {
+        values[p.index] = 1.0;
+        hues[p.index] = (floor(phase / 4) * 90) % 360;
+      } else {
+        values[p.index] *= fadeMultiplier;
+      }
+      
+      float saturation = pow(1 - values[p.index], 0.5) * 0.7 + 0.3;
+      float brightness = values[p.index];
+      
+      if (random(1.0) > derezCutoff) {
+        colors[p.index] = lx.hsb(hues[p.index], saturation * 100, brightness * 100);
+      }
+    }
+  }
+}
+
diff --git a/VincentSiao.pde b/VincentSiao.pde
new file mode 100644 (file)
index 0000000..48a368e
--- /dev/null
@@ -0,0 +1,119 @@
+class VSTowers extends SCPattern {
+  private BasicParameter saturationParameter = new BasicParameter("SAT", 80, 0, 100);
+  private BasicParameter attackParameter = new BasicParameter("ATTK", 0.96, 0.1, 1.0);
+  private BasicParameter decayParameter = new BasicParameter("DECAY", 0.7, 0.1, 1.0);
+  private SawLFO hueLfo = new SawLFO(0, 360, 20000);
+
+  private Map<Tower, Boolean> towerOn;
+
+  class TowerFlash {
+    Tower t;
+    float value;
+    float maxVal;
+    float hue;
+    boolean hasPeaked;
+
+    TowerFlash() {
+      do {
+        t = model.towers.get(floor(random(model.towers.size())));
+      } while (towerOn.get(t));
+      towerOn.put(t, true);
+      hue = (hueLfo.getValuef() + 50*(random(2)-1.0f)) % 360;
+      value = 0.0;
+      maxVal = random(0.4) + 0.6;
+    }
+
+    boolean run(double deltaMs) {
+      if (!hasPeaked) {
+        float atk = attackParameter.getValuef();
+        float atkDuration = 10000 * (1/sqrt(atk) - 1.0f);
+        value = value + (float)deltaMs / atkDuration;
+        if (value >= maxVal) {
+          value = maxVal;
+          hasPeaked = true;
+        }
+        return false;
+      } else {
+        float dec = decayParameter.getValuef();
+        float decDuration = 10000 * (1/sqrt(dec) - 1.0f);
+        value = value - (float)deltaMs / decDuration;
+        return value <= 0;
+      }
+    }
+  }
+
+  public VSTowers(GLucose glucose) {
+    super(glucose);
+    addParameter(saturationParameter);
+    addParameter(attackParameter);
+    addParameter(decayParameter);
+    addModulator(hueLfo).trigger();
+    flashes = new LinkedList<TowerFlash>();
+    towerOn = new HashMap();
+    for (Tower t : model.towers) {
+      towerOn.put(t, false);
+    }
+  }
+
+  private List<TowerFlash> flashes;
+  private float accDelta = 0;
+
+  public void run(double deltaMs) {
+    accDelta += deltaMs;
+    float rate = lx.tempo.rampf();
+    float msPerFlash = 5000 * (1/sqrt(rate) - 1.0f);
+    if (accDelta >= msPerFlash) {
+      accDelta -= msPerFlash;
+      if (flashes.size() < model.towers.size()) {
+        flashes.add(new TowerFlash());
+      }
+    }
+    for (LXPoint p : model.points) {
+      if (random(1) < 0.2) {
+        colors[p.index] = 0;
+      }
+    }
+    for (TowerFlash tf : flashes) {
+      for (LXPoint p : tf.t.points) {
+        float towerHeight = model.yMin + tf.value * (model.yMax - model.yMin);
+        if (p.y <= towerHeight) {
+          colors[p.index] = lx.hsb(
+            (tf.hue + tf.value*50 - p.y/2) % 360,
+            saturationParameter.getValuef(),
+            tf.value*100);
+        }
+      }
+      if (tf.hasPeaked) {
+        float towerMaxHeight = model.yMin + tf.maxVal * (model.yMax - model.yMin);
+        Cube top = tf.t.cubes.get(tf.t.cubes.size()-1);
+        for (int i = tf.t.cubes.size()-1; i >= 0; --i) {
+          Cube c = tf.t.cubes.get(i);
+          float maxY = c.points.get(0).y;
+          for (LXPoint p : c.points) {
+            maxY = max(maxY, p.y);
+          }
+          if (towerMaxHeight < maxY) {
+            top = c;
+          }
+        }
+        for (LXPoint p : top.points) {
+          if (tf.value > 0.5) {
+            colors[p.index] = lx.hsb(0, 0, tf.value*100);
+          } else if (random(1) < 0.2) {
+            colors[p.index] = 0;
+          }
+        }
+      }
+    }
+    // Run flashes and remove completed ones
+    Iterator<TowerFlash> it = flashes.iterator();
+    while (it.hasNext()) {
+      TowerFlash flash = it.next();
+      if (flash.run(deltaMs)) {
+        towerOn.put(flash.t, false);
+        it.remove();
+      }
+    }
+  }
+}
+
index 61c453e34d88eaa31273e754b30f5224431ccd94..425ea0e3c8a34532ef54f39f10bca368be15ba28 100644 (file)
@@ -36,9 +36,6 @@ final float TRAILER_WIDTH = 240;
 final float TRAILER_DEPTH = 97;
 final float TRAILER_HEIGHT = 33;
 
-final int MaxCubeHeight = 7;
-final int NumBackTowers = 18;
-
 int targetFramerate = 60;
 int startMillis, lastMillis;
 
index 435ca9086fd7fba8fffc2425c731e89d2803de81..171ff13e26808b056c55392661fecb621050a8a4 100644 (file)
@@ -13,6 +13,9 @@
  * when physical changes or tuning is being done to the structure.
  */
 
+final int MaxCubeHeight = 6;
+final int NumBackTowers = 16;
+
 public Model buildModel() {
 
   // Shorthand helpers for specifying wiring more quickly
@@ -24,8 +27,6 @@ public Model buildModel() {
   // Utility value if you need the height of a cube shorthand
   final float CH = Cube.EDGE_HEIGHT;
   final float CW = Cube.EDGE_WIDTH ;
-
-  
   
   // Positions for the bass box
   final float BBY = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH;
@@ -79,14 +80,14 @@ public Model buildModel() {
         for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower(
                   (i+1)*CW,                                                                 // x
                   (i % 2 == 0) ? 0 : CH * 2./3.                ,   // y
-                 - ((i % 2 == 0) ? 0 : 11) + 80          ,   // z
-                 225, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight-1) );         // num cubes
+                 - ((i % 2 == 0) ? 11 : 0) + 80          ,   // z
+                 -45, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight) );         // num cubes
         
-        for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower(
-                  (i+1)*CW,                                                                 // x
-                  (i % 2 == 0) ? 0 : CH * 2./3.                ,   // y
-                 - ((i % 2 == 0) ? 0 : 11) + 80 - pow(CH*CH + CW*CW, .5),   // z
-                 225, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight-1) ); 
+//        for (int i=0; i<NumBackTowers/2; i++) scubes.add(new StaggeredTower(
+//                  (i+1)*CW,                                                                 // x
+//                  (i % 2 == 0) ? 0 : CH * 2./3.                ,   // y
+//                 - ((i % 2 == 0) ? 0 : 11) + 80 - pow(CH*CH + CW*CW, .5),   // z
+//                 225, (i % 2 == 0) ? MaxCubeHeight : MaxCubeHeight-1) ); 
 
       // for (int i=0; i<2 ; i++) scubes.add(new StaggeredTower(
       //             (i+1)*CW,                                                                 // x
@@ -213,9 +214,13 @@ float current_x_position = 0;
   }
 
   
-  for (Cube cube : singleCubes) cubes[cubeIndex++] = cube;
-  for (Cube cube : dcubes)                 cubes[cubeIndex++] = cube;
-for (StaggeredTower st : scubes) {
+  for (Cube cube : singleCubes) {
+    cubes[cubeIndex++] = cube;
+  }
+  for (Cube cube : dcubes) {
+    cubes[cubeIndex++] = cube;
+  }
+  for (StaggeredTower st : scubes) {
     tower = new ArrayList<Cube>();
     for (int i=0; i < st.n; i++) {
       Cube.Wiring w = (i < st.wiring.length) ? st.wiring[i] : WRR;
@@ -239,48 +244,63 @@ public PandaMapping[] buildPandaList() {
   return new PandaMapping[] {
     new PandaMapping(
       "10.200.1.28", new ChannelMapping[] {
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 16, 17, 18}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 4, 5, 6}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 7, 8, 9}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 10, 11, 12}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 13, 14, 15}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37, 38, 39 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] {  }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 43, 44, 45 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 46, 47, 48 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] {  }), // new front thing
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] {  }), // new back thing
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 13, 14, 15 }), // new back thing
     }),
     new PandaMapping(
       "10.200.1.29", new ChannelMapping[] {
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 34, 35, 36}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19, 20, 21}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 22, 23, 24}), 
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 25, 26, 27}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28, 29, 30}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 31, 32, 33}),
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19, 20, 21 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] {  }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 4, 5, 6 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 7, 8, 9 }),
+
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 10, 11, 12 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 16, 17, 18 }),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 34, 35, 36}),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19, 20, 21}),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 22, 23, 24}), 
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 25, 26, 27}),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28, 29, 30}),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 31, 32, 33}),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
     }),    
     new PandaMapping(
       "10.200.1.30", new ChannelMapping[] {
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}), // 30 J3 *
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}),  // 30 J4 //ORIG *
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37, 38, 39}),                // 30 J7 *
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 40, 41, 42}),  // 30 J8 *
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 43, 44, 45}),                // 30 J13 (not working)
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 46, 47, 48}),                // 30 J14 (unplugged)
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 49, 50, 51}),                // 30 J15 (unplugged)
-        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 52, 53, 54}), // 30 J16
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 40, 41, 42 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 22, 23, 24 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 25, 26, 27 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28, 29, 30 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 31, 32, 33 }),
+        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 34, 35, 36 }),
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}), // 30 J3 *
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}),  // 30 J4 //ORIG *
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37, 38, 39}),                // 30 J7 *
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 40, 41, 42}),  // 30 J8 *
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 43, 44, 45}),                // 30 J13 (not working)
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 46, 47, 48}),                // 30 J14 (unplugged)
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 49, 50, 51}),                // 30 J15 (unplugged)
+//        new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 52, 53, 54}), // 30 J16
    }),    
-     new PandaMapping(
-       "10.200.1.31", new ChannelMapping[] {
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 65, 66}),       // J3 
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}),       // J4
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 55, 56}), // 30 J7 
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 57, 58}), //  J8 
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 59, 60}),           // J13 
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 61, 62}),                // 30 J14 
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 63, 64}),                //  J15
-         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}),              //  J16
-     }),
+//     new PandaMapping(
+//       "10.200.1.31", new ChannelMapping[] {
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 65, 66}),       // J3 
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}),       // J4
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 55, 56}), // 30 J7 
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 57, 58}), //  J8 
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 59, 60}),           // J13 
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 61, 62}),                // 30 J14 
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 63, 64}),                //  J15
+//         new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}),              //  J16
+//     }),
+
      // new PandaMapping(
      //   "10.200.1.32", new ChannelMapping[] {
      //     new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }),       // J3 
index 24afa20438d80422bab8bef435901781824beec0..5d8ad249bbe3171446033c720c1d15f60cfda226 100644 (file)
@@ -84,10 +84,17 @@ public static class PandaDriver {
    * corner of the cube the data wire comes in.
    */
   private final static int[][] CUBE_STRIP_ORDERINGS = new int[][] {
+//    {  2,  1,  0,  3, 13, 12, 15, 14,  4,  7,  6,  5, 11, 10,  9,  8 }, // FRONT_LEFT
+//    {  6,  5,  4,  7,  1,  0,  3,  2,  8, 11, 10,  9, 15, 14, 13, 12 }, // FRONT_RIGHT
+//    { 14, 13, 12, 15,  9,  8, 11, 10,  0,  3,  2,  1,  7,  6,  5,  4 }, // REAR_LEFT
+//    { 10,  9,  8, 11,  5,  4,  7,  6, 12, 15, 14, 13,  3,  2,  1,  0 }, // REAR_RIGHT
+
+
     {  2,  1,  0,  3, 13, 12, 15, 14,  4,  7,  6,  5, 11, 10,  9,  8 }, // FRONT_LEFT
     {  6,  5,  4,  7,  1,  0,  3,  2,  8, 11, 10,  9, 15, 14, 13, 12 }, // FRONT_RIGHT
     { 14, 13, 12, 15,  9,  8, 11, 10,  0,  3,  2,  1,  7,  6,  5,  4 }, // REAR_LEFT
-    { 10,  9,  8, 11,  5,  4,  7,  6, 12, 15, 14, 13,  3,  2,  1,  0 }, // REAR_RIGHT
+    {  9,  8, 11,  5,  4,  7,  6, 10, 14,  2,  1,  0,  3, 13, 12, 15 }, // REAR_RIGHT
+
   };
   
   private final static int[][] BASS_STRIP_ORDERING = {