A few cleanups to test patterns
[SugarCubes.git] / _Internals.pde
CommitLineData
49815cc0
MS
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
7import glucose.*;
8import glucose.control.*;
3f8be614 9import glucose.effect.*;
f3f5a876 10import glucose.model.*;
49815cc0 11import glucose.pattern.*;
f3f5a876 12import glucose.transform.*;
49815cc0 13import glucose.transition.*;
49815cc0 14import heronarts.lx.*;
3f8be614 15import heronarts.lx.control.*;
49815cc0 16import heronarts.lx.effect.*;
49815cc0 17import heronarts.lx.modulator.*;
f3f5a876 18import heronarts.lx.pattern.*;
49815cc0
MS
19import heronarts.lx.transition.*;
20import ddf.minim.*;
21import ddf.minim.analysis.*;
22import processing.opengl.*;
23import java.lang.reflect.*;
5d70e4d7 24import rwmidi.*;
49815cc0
MS
25
26final int VIEWPORT_WIDTH = 900;
27final int VIEWPORT_HEIGHT = 700;
28final int TARGET_FRAMERATE = 45;
29
30int startMillis, lastMillis;
31GLucose glucose;
32HeronLX lx;
33LXPattern[] patterns;
34LXTransition[] transitions;
35LXEffect[] effects;
36OverlayUI ui;
49815cc0
MS
37
38void setup() {
39 startMillis = lastMillis = millis();
40
41 // Initialize the Processing graphics environment
42 size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL);
43 frameRate(TARGET_FRAMERATE);
3f8be614 44 noSmooth();
49815cc0
MS
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
809f3518 66 SCMidiDevices.initializeStandardDevices(glucose, ui.patternKnobs, ui.transitionKnobs, ui.effectKnobs);
3f8be614 67 logTime("Setup MIDI devices");
49815cc0
MS
68
69 println("Total setup: " + (millis() - startMillis) + "ms");
70}
71
72void logTime(String evt) {
73 int now = millis();
74 println(evt + ": " + (now - lastMillis) + "ms");
75 lastMillis = now;
76}
77
78void 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
83void drawUI() {
84 if (uiOn) {
85 ui.draw();
86 } else {
87 ui.drawHelpTip();
88 }
89 ui.drawFPS();
90}
91
92boolean uiOn = true;
3f8be614 93boolean knobsOn = true;
49815cc0 94void keyPressed() {
3f8be614
MS
95 switch (key) {
96 case 'u':
97 uiOn = !uiOn;
98 break;
99 case 'k':
100 knobsOn = !knobsOn;
101 break;
49815cc0
MS
102 }
103}
104
105