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