repositories
/
SugarCubes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
updated midi stuff
[SugarCubes.git]
/
_Internals.pde
diff --git
a/_Internals.pde
b/_Internals.pde
index 60a5f3296e11abc121aec4607abd44edb95832a8..9d6e2740a4aea94a54cd807202b86949403b6a98 100644
(file)
--- a/
_Internals.pde
+++ b/
_Internals.pde
@@
-39,6
+39,9
@@
final float TRAILER_WIDTH = 240;
final float TRAILER_DEPTH = 97;
final float TRAILER_HEIGHT = 33;
final float TRAILER_DEPTH = 97;
final float TRAILER_HEIGHT = 33;
+final int MaxCubeHeight = 5;
+final int NumBackTowers = 9;
+
int targetFramerate = 60;
int startMillis, lastMillis;
int targetFramerate = 60;
int startMillis, lastMillis;
@@
-57,6
+60,7
@@
DebugUI debugUI;
boolean uiOn = true;
LXPattern restoreToPattern = null;
PImage logo;
boolean uiOn = true;
LXPattern restoreToPattern = null;
PImage logo;
+float[] hsb = new float[3];
// Handles to UI objects
UIContext[] overlays;
// Handles to UI objects
UIContext[] overlays;
@@
-72,14
+76,31
@@
float eyeR, eyeA, eyeX, eyeY, eyeZ, midX, midY, midZ;
/**
* Engine construction and initialization.
*/
/**
* Engine construction and initialization.
*/
-LXPattern[] _patterns(GLucose glucose) {
+
+LXTransition _transition(GLucose glucose) {
+ return new DissolveTransition(glucose.lx).setDuration(1000);
+}
+
+LXPattern[] _leftPatterns(GLucose glucose) {
LXPattern[] patterns = patterns(glucose);
for (LXPattern p : patterns) {
LXPattern[] patterns = patterns(glucose);
for (LXPattern p : patterns) {
- p.setTransition(
new DissolveTransition(glucose.lx).setDuration(1000
));
+ p.setTransition(
_transition(glucose
));
}
return patterns;
}
}
return patterns;
}
+LXPattern[] _rightPatterns(GLucose glucose) {
+ LXPattern[] patterns = _leftPatterns(glucose);
+ LXPattern[] rightPatterns = new LXPattern[patterns.length+1];
+ int i = 0;
+ rightPatterns[i++] = new BlankPattern(glucose).setTransition(_transition(glucose));
+ for (LXPattern p : patterns) {
+ rightPatterns[i++] = p;
+ }
+ return rightPatterns;
+}
+
+
void logTime(String evt) {
int now = millis();
println(evt + ": " + (now - lastMillis) + "ms");
void logTime(String evt) {
int now = millis();
println(evt + ": " + (now - lastMillis) + "ms");
@@
-104,14
+125,18
@@
void setup() {
// Set the patterns
Engine engine = lx.engine;
// Set the patterns
Engine engine = lx.engine;
- engine.setPatterns(patterns = _
p
atterns(glucose));
- engine.addDeck(_
p
atterns(glucose));
+ engine.setPatterns(patterns = _
leftP
atterns(glucose));
+ engine.addDeck(_
rightP
atterns(glucose));
logTime("Built patterns");
glucose.setTransitions(transitions(glucose));
logTime("Built transitions");
glucose.lx.addEffects(effects(glucose));
logTime("Built effects");
logTime("Built patterns");
glucose.setTransitions(transitions(glucose));
logTime("Built transitions");
glucose.lx.addEffects(effects(glucose));
logTime("Built effects");
-
+
+ // MIDI devices
+ midiEngine = new MidiEngine();
+ logTime("Setup MIDI devices");
+
// Build output driver
PandaMapping[] pandaMappings = buildPandaList();
pandaBoards = new PandaDriver[pandaMappings.length];
// Build output driver
PandaMapping[] pandaMappings = buildPandaList();
pandaBoards = new PandaDriver[pandaMappings.length];
@@
-122,10
+147,6
@@
void setup() {
mappingTool = new MappingTool(glucose, pandaMappings);
logTime("Built PandaDriver");
mappingTool = new MappingTool(glucose, pandaMappings);
logTime("Built PandaDriver");
- // MIDI devices
- midiEngine = new MidiEngine();
- logTime("Setup MIDI devices");
-
// Build overlay UI
debugUI = new DebugUI(pandaMappings);
overlays = new UIContext[] {
// Build overlay UI
debugUI = new DebugUI(pandaMappings);
overlays = new UIContext[] {
@@
-176,16
+197,19
@@
void setup() {
void draw() {
// Draws the simulation and the 2D UI overlay
background(40);
void draw() {
// Draws the simulation and the 2D UI overlay
background(40);
- color[] colors = glucose.getColors();
+ color[] simulationColors;
+ color[] sendColors;
+ simulationColors = sendColors = glucose.getColors();
String displayMode = uiCrossfader.getDisplayMode();
if (displayMode == "A") {
String displayMode = uiCrossfader.getDisplayMode();
if (displayMode == "A") {
-
c
olors = lx.engine.getDeck(0).getColors();
+
simulationC
olors = lx.engine.getDeck(0).getColors();
} else if (displayMode == "B") {
} else if (displayMode == "B") {
-
c
olors = lx.engine.getDeck(1).getColors();
+
simulationC
olors = lx.engine.getDeck(1).getColors();
}
if (debugMode) {
}
if (debugMode) {
- debugUI.maskColors(colors);
+ debugUI.maskColors(simulationColors);
+ debugUI.maskColors(sendColors);
}
camera(
}
camera(
@@
-217,10
+241,12
@@
void draw() {
popMatrix();
noStroke();
popMatrix();
noStroke();
-// drawBassBox(glucose.model.bassBox);
-// for (Speaker s : glucose.model.speakers) {
-// drawSpeaker(s);
-// }
+ if (glucose.model.bassBox.exists) {
+ drawBassBox(glucose.model.bassBox, false);
+ }
+ for (Speaker speaker : glucose.model.speakers) {
+ drawSpeaker(speaker);
+ }
for (Cube c : glucose.model.cubes) {
drawCube(c);
}
for (Cube c : glucose.model.cubes) {
drawCube(c);
}
@@
-228,51
+254,41
@@
void draw() {
noFill();
strokeWeight(2);
beginShape(POINTS);
noFill();
strokeWeight(2);
beginShape(POINTS);
- // TODO(mcslee): restore when bassBox/speakers are right again
- // for (Point p : glucose.model.points) {
- for (Cube cube : glucose.model.cubes) {
- for (Point p : cube.points) {
- stroke(colors[p.index]);
- vertex(p.fx, p.fy, p.fz);
- }
+ for (Point p : glucose.model.points) {
+ stroke(simulationColors[p.index]);
+ vertex(p.x, p.y, p.z);
}
endShape();
// 2D Overlay UI
drawUI();
}
endShape();
// 2D Overlay UI
drawUI();
- // Send output colors
- color[] sendColors = glucose.getColors();
- if (debugMode) {
- debugUI.maskColors(colors);
- }
-
// Gamma correction here. Apply a cubic to the brightness
// for better representation of dynamic range
// Gamma correction here. Apply a cubic to the brightness
// for better representation of dynamic range
- for (int i = 0; i < colors.length; ++i) {
- float b = brightness(colors[i]) / 100.f;
- colors[i] = color(
- hue(colors[i]),
- saturation(colors[i]),
- (b*b*b) * 100.
- );
+ for (int i = 0; i < sendColors.length; ++i) {
+ lx.RGBtoHSB(sendColors[i], hsb);
+ float b = hsb[2];
+ sendColors[i] = lx.hsb(360.*hsb[0], 100.*hsb[1], 100.*(b*b*b));
}
// TODO(mcslee): move into GLucose engine
for (PandaDriver p : pandaBoards) {
}
// TODO(mcslee): move into GLucose engine
for (PandaDriver p : pandaBoards) {
- p.send(
c
olors);
+ p.send(
sendC
olors);
}
}
}
}
-void drawBassBox(BassBox b) {
+void drawBassBox(BassBox b, boolean hasSub) {
+
float in = .15;
float in = .15;
-
- noStroke();
- fill(#191919);
- pushMatrix();
- translate(b.x + BassBox.EDGE_WIDTH/2., b.y + BassBox.EDGE_HEIGHT/2, b.z + BassBox.EDGE_DEPTH/2.);
- box(BassBox.EDGE_WIDTH-20*in, BassBox.EDGE_HEIGHT-20*in, BassBox.EDGE_DEPTH-20*in);
- popMatrix();
+
+ if (hasSub) {
+ noStroke();
+ fill(#191919);
+ pushMatrix();
+ translate(b.x + BassBox.EDGE_WIDTH/2., b.y + BassBox.EDGE_HEIGHT/2, b.z + BassBox.EDGE_DEPTH/2.);
+ box(BassBox.EDGE_WIDTH-20*in, BassBox.EDGE_HEIGHT-20*in, BassBox.EDGE_DEPTH-20*in);
+ popMatrix();
+ }
noStroke();
fill(#393939);
noStroke();
fill(#393939);
@@
-410,7
+426,10
@@
void keyPressed() {
case '=':
case '+':
frameRate(++targetFramerate);
case '=':
case '+':
frameRate(++targetFramerate);
- break;
+ break;
+ case 'b':
+ EFF_boom.trigger();
+ break;
case 'd':
if (!midiEngine.isQwertyEnabled()) {
debugMode = !debugMode;
case 'd':
if (!midiEngine.isQwertyEnabled()) {
debugMode = !debugMode;
@@
-434,6
+453,11
@@
void keyPressed() {
}
}
break;
}
}
break;
+ case 't':
+ if (!midiEngine.isQwertyEnabled()) {
+ lx.engine.setThreaded(!lx.engine.isThreaded());
+ }
+ break;
case 'p':
for (PandaDriver p : pandaBoards) {
p.toggle();
case 'p':
for (PandaDriver p : pandaBoards) {
p.toggle();
@@
-487,7
+511,7
@@
void mouseReleased() {
context.mouseReleased(mouseX, mouseY);
}
}
context.mouseReleased(mouseX, mouseY);
}
}
-
+
void mouseWheel(int delta) {
boolean wheeled = false;
for (UIContext context : overlays) {
void mouseWheel(int delta) {
boolean wheeled = false;
for (UIContext context : overlays) {