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