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;
46 PandaDriver pandaFront;
47 PandaDriver pandaRear;
49 boolean pandaBoardsEnabled = false;
52 startMillis = lastMillis = millis();
54 // Initialize the Processing graphics environment
55 size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL);
56 frameRate(TARGET_FRAMERATE);
58 // hint(ENABLE_OPENGL_4X_SMOOTH); // no discernable improvement?
59 logTime("Created viewport");
61 // Create the GLucose engine to run the cubes
62 glucose = new GLucose(this, new SCMapping());
64 logTime("Built GLucose engine");
67 glucose.lx.setPatterns(patterns = patterns(glucose));
68 logTime("Built patterns");
69 glucose.lx.addEffects(effects = effects(glucose));
70 logTime("Built effects");
71 transitions = transitions(glucose);
72 logTime("Built transitions");
74 // Build output driver
75 int[][] frontChannels = glucose.mapping.buildFrontChannelList();
76 int[][] rearChannels = glucose.mapping.buildRearChannelList();
77 int[][] flippedRGB = glucose.mapping.buildFlippedRGBList();
78 pandaFront = new PandaDriver(new NetAddress("192.168.1.28", 9001), glucose.model, frontChannels, flippedRGB);
79 pandaRear = new PandaDriver(new NetAddress("192.168.1.29", 9001), glucose.model, rearChannels, flippedRGB);
80 logTime("Build PandaDriver");
84 logTime("Built overlay UI");
87 SCMidiDevices.initializeStandardDevices(glucose, ui.patternKnobs, ui.transitionKnobs, ui.effectKnobs);
88 logTime("Setup MIDI devices");
90 println("Total setup: " + (millis() - startMillis) + "ms");
91 println("Hit the 'p' key to toggle Panda Board output");
94 void logTime(String evt) {
96 println(evt + ": " + (now - lastMillis) + "ms");
101 // The glucose engine deals with the core simulation here, we don't need
102 // to do anything specific. This method just needs to exist.
104 // TODO(mcslee): move into GLucose engine
105 if (pandaBoardsEnabled) {
106 color[] colors = glucose.getColors();
107 pandaFront.send(colors);
108 pandaRear.send(colors);
122 boolean knobsOn = true;
126 pandaBoardsEnabled = !pandaBoardsEnabled;
127 println("PandaBoard Output: " + (pandaBoardsEnabled ? "ON" : "OFF"));