proposed new lattice, plus dpat changes
[SugarCubes.git] / _Internals.pde
index 0b8949decdfed12f53b09e4b3256d216c1f49333..4dd145a80d62964c190e6ff1bea08d84261c53a6 100644 (file)
@@ -72,14 +72,31 @@ float eyeR, eyeA, eyeX, eyeY, eyeZ, midX, midY, midZ;
 /**
  * Engine construction and initialization.
  */
-LXPattern[] _patterns(GLucose glucose) {
+
+LXTransition _transition(GLucose glucose) {
+  return new DissolveTransition(glucose.lx).setDuration(1000);
+}
+
+LXPattern[] _leftPatterns(GLucose glucose) {
   LXPattern[] patterns = patterns(glucose);
   for (LXPattern p : patterns) {
-    p.setTransition(new DissolveTransition(glucose.lx).setDuration(1000));
+    p.setTransition(_transition(glucose));
   }
   return patterns;
 }
 
+LXPattern[] _rightPatterns(GLucose glucose) {
+  LXPattern[] patterns = _leftPatterns(glucose);
+  LXPattern[] rightPatterns = new LXPattern[patterns.length+1];
+  int i = 0;
+  rightPatterns[i++] = new BlankPattern(glucose).setTransition(_transition(glucose));
+  for (LXPattern p : patterns) {
+    rightPatterns[i++] = p;
+  }
+  return rightPatterns;
+}
+  
+
 void logTime(String evt) {
   int now = millis();
   println(evt + ": " + (now - lastMillis) + "ms");
@@ -108,8 +125,8 @@ void setup() {
 
   // Set the patterns
   Engine engine = lx.engine;
-  engine.setPatterns(patterns = _patterns(glucose));
-  engine.addDeck(_patterns(glucose));
+  engine.setPatterns(patterns = _leftPatterns(glucose));
+  engine.addDeck(_rightPatterns(glucose));
   logTime("Built patterns");
   glucose.setTransitions(transitions(glucose));
   logTime("Built transitions");
@@ -217,10 +234,12 @@ void draw() {
   popMatrix();
   
   noStroke();
-//  drawBassBox(glucose.model.bassBox);
-//  for (Speaker s : glucose.model.speakers) {
-//    drawSpeaker(s);
-//  }
+  if (glucose.model.bassBox.exists) {
+    drawBassBox(glucose.model.bassBox, false);
+  }
+  for (Speaker speaker : glucose.model.speakers) {
+    drawSpeaker(speaker);
+  }
   for (Cube c : glucose.model.cubes) {
     drawCube(c);
   }
@@ -228,13 +247,9 @@ void draw() {
   noFill();
   strokeWeight(2);
   beginShape(POINTS);
-  // TODO(mcslee): restore when bassBox/speakers are right again
-  // for (Point p : glucose.model.points) {
-  for (Cube cube : glucose.model.cubes) {
-    for (Point p : cube.points) {
-      stroke(colors[p.index]);
-      vertex(p.fx, p.fy, p.fz);
-    }
+  for (Point p : glucose.model.points) {
+    stroke(colors[p.index]);
+    vertex(p.fx, p.fy, p.fz);
   }
   endShape();
   
@@ -264,15 +279,18 @@ void draw() {
   }
 }
 
-void drawBassBox(BassBox b) {
+void drawBassBox(BassBox b, boolean hasSub) {
+  
   float in = .15;
-
-  noStroke();
-  fill(#191919);
-  pushMatrix();
-  translate(b.x + BassBox.EDGE_WIDTH/2., b.y + BassBox.EDGE_HEIGHT/2, b.z + BassBox.EDGE_DEPTH/2.);
-  box(BassBox.EDGE_WIDTH-20*in, BassBox.EDGE_HEIGHT-20*in, BassBox.EDGE_DEPTH-20*in);
-  popMatrix();
+  
+  if (hasSub) {
+    noStroke();
+    fill(#191919);
+    pushMatrix();
+    translate(b.x + BassBox.EDGE_WIDTH/2., b.y + BassBox.EDGE_HEIGHT/2, b.z + BassBox.EDGE_DEPTH/2.);
+    box(BassBox.EDGE_WIDTH-20*in, BassBox.EDGE_HEIGHT-20*in, BassBox.EDGE_DEPTH-20*in);
+    popMatrix();
+  }
 
   noStroke();
   fill(#393939);
@@ -412,7 +430,7 @@ void keyPressed() {
       frameRate(++targetFramerate);
       break; 
     case 'b':
-      boom.trigger();
+      EFF_boom.trigger();
       break;    
     case 'd':
       if (!midiEngine.isQwertyEnabled()) {
@@ -490,8 +508,8 @@ void mouseReleased() {
     context.mouseReleased(mouseX, mouseY);
   }
 }
-void mouseWheel(int delta) {
+
+void mouseWheel(int delta) {delta*=20;
   boolean wheeled = false;
   for (UIContext context : overlays) {
     wheeled |= context.mouseWheel(mouseX, mouseY, delta);