Import the projection libraries and add TestProjectionPattern to illustrate usage
[SugarCubes.git] / _Internals.pde
1 /**
2 * If you are an artist, you may ignore this file! It just sets
3 * up the framework to run the patterns. Should not need modification
4 * for general animation work.
5 */
6
7 import glucose.*;
8 import glucose.control.*;
9 import glucose.effect.*;
10 import glucose.model.*;
11 import glucose.pattern.*;
12 import glucose.transform.*;
13 import glucose.transition.*;
14 import heronarts.lx.*;
15 import heronarts.lx.control.*;
16 import heronarts.lx.effect.*;
17 import heronarts.lx.modulator.*;
18 import heronarts.lx.pattern.*;
19 import heronarts.lx.transition.*;
20 import ddf.minim.*;
21 import ddf.minim.analysis.*;
22 import processing.opengl.*;
23 import java.lang.reflect.*;
24 import rwmidi.*;
25
26 final int VIEWPORT_WIDTH = 900;
27 final int VIEWPORT_HEIGHT = 700;
28 final int TARGET_FRAMERATE = 45;
29
30 int startMillis, lastMillis;
31 GLucose glucose;
32 HeronLX lx;
33 LXPattern[] patterns;
34 LXTransition[] transitions;
35 LXEffect[] effects;
36 OverlayUI ui;
37
38 void setup() {
39 startMillis = lastMillis = millis();
40
41 // Initialize the Processing graphics environment
42 size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL);
43 frameRate(TARGET_FRAMERATE);
44 noSmooth();
45 // hint(ENABLE_OPENGL_4X_SMOOTH); // no discernable improvement?
46 logTime("Created viewport");
47
48 // Create the GLucose engine to run the cubes
49 glucose = new GLucose(this);
50 lx = glucose.lx;
51 logTime("Built GLucose engine");
52
53 // Set the patterns
54 glucose.lx.setPatterns(patterns = patterns(glucose));
55 logTime("Built patterns");
56 glucose.lx.addEffects(effects = effects(glucose));
57 logTime("Built effects");
58 transitions = transitions(glucose);
59 logTime("Built transitions");
60
61 // Build overlay UI
62 ui = new OverlayUI();
63 logTime("Built overlay UI");
64
65 // MIDI devices
66 SCMidiDevices.initializeStandardDevices(glucose, ui.patternKnobs, ui.transitionKnobs, ui.effectKnobs);
67 logTime("Setup MIDI devices");
68
69 println("Total setup: " + (millis() - startMillis) + "ms");
70 }
71
72 void logTime(String evt) {
73 int now = millis();
74 println(evt + ": " + (now - lastMillis) + "ms");
75 lastMillis = now;
76 }
77
78 void draw() {
79 // The glucose engine deals with the core simulation here, we don't need
80 // to do anything specific. This method just needs to exist.
81 }
82
83 void drawUI() {
84 if (uiOn) {
85 ui.draw();
86 } else {
87 ui.drawHelpTip();
88 }
89 ui.drawFPS();
90 }
91
92 boolean uiOn = true;
93 boolean knobsOn = true;
94 void keyPressed() {
95 switch (key) {
96 case 'u':
97 uiOn = !uiOn;
98 break;
99 case 'k':
100 knobsOn = !knobsOn;
101 break;
102 }
103 }
104
105