2 * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND
5 * ///\\\ ///\\\ ///\\\ ///\\\
6 * \\\/// \\\/// \\\/// \\\///
9 * EXPERTS ONLY!! EXPERTS ONLY!!
11 * If you are an artist, you may ignore this file! It just sets
12 * up the framework to run the patterns. Should not need modification
13 * for general animation work.
17 import glucose.control.*;
18 import glucose.effect.*;
19 import glucose.model.*;
20 import glucose.pattern.*;
21 import glucose.transform.*;
22 import glucose.transition.*;
23 import heronarts.lx.*;
24 import heronarts.lx.control.*;
25 import heronarts.lx.effect.*;
26 import heronarts.lx.modulator.*;
27 import heronarts.lx.pattern.*;
28 import heronarts.lx.transition.*;
30 import ddf.minim.analysis.*;
31 import processing.opengl.*;
34 final int VIEWPORT_WIDTH = 900;
35 final int VIEWPORT_HEIGHT = 700;
36 final int TARGET_FRAMERATE = 45;
38 int startMillis, lastMillis;
42 LXTransition[] transitions;
45 PandaDriver pandaFront;
46 PandaDriver pandaRear;
48 boolean pandaBoardsEnabled = false;
51 startMillis = lastMillis = millis();
53 // Initialize the Processing graphics environment
54 size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL);
55 frameRate(TARGET_FRAMERATE);
57 // hint(ENABLE_OPENGL_4X_SMOOTH); // no discernable improvement?
58 logTime("Created viewport");
60 // Create the GLucose engine to run the cubes
61 glucose = new GLucose(this, new SCMapping());
63 logTime("Built GLucose engine");
66 glucose.lx.setPatterns(patterns = patterns(glucose));
67 logTime("Built patterns");
68 glucose.lx.addEffects(effects = effects(glucose));
69 logTime("Built effects");
70 transitions = transitions(glucose);
71 logTime("Built transitions");
73 // Build output driver
74 int[][] frontChannels = glucose.mapping.buildFrontChannelList();
75 int[][] rearChannels = glucose.mapping.buildRearChannelList();
76 int[][] flippedRGB = glucose.mapping.buildFlippedRGBList();
77 pandaFront = new PandaDriver(new NetAddress("192.168.1.28", 9001), glucose.model, frontChannels, flippedRGB);
78 pandaRear = new PandaDriver(new NetAddress("192.168.1.29", 9001), glucose.model, rearChannels, flippedRGB);
79 logTime("Build PandaDriver");
83 logTime("Built overlay UI");
86 SCMidiDevices.initializeStandardDevices(glucose, ui.patternKnobs, ui.transitionKnobs, ui.effectKnobs);
87 logTime("Setup MIDI devices");
89 println("Total setup: " + (millis() - startMillis) + "ms");
90 println("Hit the 'p' key to toggle Panda Board output");
93 void logTime(String evt) {
95 println(evt + ": " + (now - lastMillis) + "ms");
100 // The glucose engine deals with the core simulation here, we don't need
101 // to do anything specific. This method just needs to exist.
103 // TODO(mcslee): move into GLucose engine
104 if (pandaBoardsEnabled) {
105 color[] colors = glucose.getColors();
106 pandaFront.send(colors);
107 pandaRear.send(colors);
121 boolean knobsOn = true;
125 pandaBoardsEnabled = !pandaBoardsEnabled;
126 println("PandaBoard Output: " + (pandaBoardsEnabled ? "ON" : "OFF"));