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