X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=_Internals.pde;h=9d6e2740a4aea94a54cd807202b86949403b6a98;hb=e530876366cf4c07a5e77b7e8890dff376cbcd3c;hp=4dd145a80d62964c190e6ff1bea08d84261c53a6;hpb=73687629fdcb02aa7c0a7c605319252da07f91d7;p=SugarCubes.git diff --git a/_Internals.pde b/_Internals.pde index 4dd145a..9d6e274 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 = 5; +final int NumBackTowers = 9; + int targetFramerate = 60; int startMillis, lastMillis; @@ -57,6 +60,7 @@ DebugUI debugUI; boolean uiOn = true; LXPattern restoreToPattern = null; PImage logo; +float[] hsb = new float[3]; // Handles to UI objects UIContext[] overlays; @@ -119,10 +123,6 @@ 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 = _leftPatterns(glucose)); @@ -132,7 +132,11 @@ void setup() { logTime("Built transitions"); glucose.lx.addEffects(effects(glucose)); logTime("Built effects"); - + + // MIDI devices + midiEngine = new MidiEngine(); + logTime("Setup MIDI devices"); + // Build output driver PandaMapping[] pandaMappings = buildPandaList(); pandaBoards = new PandaDriver[pandaMappings.length]; @@ -193,16 +197,19 @@ void setup() { void draw() { // Draws the simulation and the 2D UI overlay background(40); - color[] colors = glucose.getColors(); + color[] simulationColors; + color[] sendColors; + simulationColors = sendColors = glucose.getColors(); String displayMode = uiCrossfader.getDisplayMode(); if (displayMode == "A") { - colors = lx.engine.getDeck(0).getColors(); + simulationColors = lx.engine.getDeck(0).getColors(); } else if (displayMode == "B") { - colors = lx.engine.getDeck(1).getColors(); + simulationColors = lx.engine.getDeck(1).getColors(); } if (debugMode) { - debugUI.maskColors(colors); + debugUI.maskColors(simulationColors); + debugUI.maskColors(sendColors); } camera( @@ -248,34 +255,25 @@ void draw() { strokeWeight(2); beginShape(POINTS); for (Point p : glucose.model.points) { - stroke(colors[p.index]); - vertex(p.fx, p.fy, p.fz); + stroke(simulationColors[p.index]); + vertex(p.x, p.y, p.z); } endShape(); // 2D Overlay UI drawUI(); - // Send output colors - color[] sendColors = glucose.getColors(); - if (debugMode) { - debugUI.maskColors(colors); - } - // 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]), - (b*b*b) * 100. - ); + for (int i = 0; i < sendColors.length; ++i) { + lx.RGBtoHSB(sendColors[i], hsb); + float b = hsb[2]; + sendColors[i] = lx.hsb(360.*hsb[0], 100.*hsb[1], 100.*(b*b*b)); } // TODO(mcslee): move into GLucose engine for (PandaDriver p : pandaBoards) { - p.send(colors); + p.send(sendColors); } } @@ -455,6 +453,11 @@ void keyPressed() { } } break; + case 't': + if (!midiEngine.isQwertyEnabled()) { + lx.engine.setThreaded(!lx.engine.isThreaded()); + } + break; case 'p': for (PandaDriver p : pandaBoards) { p.toggle(); @@ -509,7 +512,7 @@ void mouseReleased() { } } -void mouseWheel(int delta) {delta*=20; +void mouseWheel(int delta) { boolean wheeled = false; for (UIContext context : overlays) { wheeled |= context.mouseWheel(mouseX, mouseY, delta);