X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=_Internals.pde;h=d24f13b3910c364055c769102ad0f5ddfef9aa86;hb=0137237dffbb4ffdfa3a995dd7daee5f1f15c982;hp=60a5f3296e11abc121aec4607abd44edb95832a8;hpb=d6ac1ee83fec42f9c5ba4a14248879b541f1f58d;p=SugarCubes.git diff --git a/_Internals.pde b/_Internals.pde index 60a5f32..d24f13b 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -39,6 +39,9 @@ final float TRAILER_WIDTH = 240; final float TRAILER_DEPTH = 97; final float TRAILER_HEIGHT = 33; +final int MaxCubeHeight = 7; +final int NumBackTowers = 9; + int targetFramerate = 60; int startMillis, lastMillis; @@ -72,14 +75,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"); @@ -102,10 +122,14 @@ void setup() { lx.enableKeyboardTempo(); logTime("Built GLucose engine"); + // MIDI devices + midiEngine = new MidiEngine(); + logTime("Setup MIDI devices"); + // 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"); @@ -122,10 +146,6 @@ void setup() { mappingTool = new MappingTool(glucose, pandaMappings); logTime("Built PandaDriver"); - // MIDI devices - midiEngine = new MidiEngine(); - logTime("Setup MIDI devices"); - // Build overlay UI debugUI = new DebugUI(pandaMappings); overlays = new UIContext[] { @@ -217,10 +237,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 +250,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(); @@ -244,35 +262,38 @@ void draw() { // Send output colors color[] sendColors = glucose.getColors(); if (debugMode) { - debugUI.maskColors(colors); + debugUI.maskColors(sendColors); } // Gamma correction here. Apply a cubic to the brightness // for better representation of dynamic range - for (int i = 0; i < colors.length; ++i) { - float b = brightness(colors[i]) / 100.f; - colors[i] = color( - hue(colors[i]), - saturation(colors[i]), + for (int i = 0; i < sendColors.length; ++i) { + float b = brightness(sendColors[i]) / 100.f; + sendColors[i] = color( + hue(sendColors[i]), + saturation(sendColors[i]), (b*b*b) * 100. ); } // TODO(mcslee): move into GLucose engine for (PandaDriver p : pandaBoards) { - p.send(colors); + p.send(sendColors); } } -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); @@ -410,7 +431,10 @@ void keyPressed() { case '=': case '+': frameRate(++targetFramerate); - break; + break; + case 'b': + EFF_boom.trigger(); + break; case 'd': if (!midiEngine.isQwertyEnabled()) { debugMode = !debugMode; @@ -487,8 +511,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);