forked from disorient/acw
/
domeTransmitter.pde
165 lines (129 loc) · 3.42 KB
/
domeTransmitter.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
//import codeanticode.gsvideo.*;
import processing.opengl.*;
import java.lang.reflect.Method;
import hypermedia.net.*;
import java.io.*;
// This should be 127.0.0.1, 58802
String transmit_address = "127.0.0.1";
int transmit_port = 58082;
// Display configuration
int WIDTH = 40;
int HEIGHT = 160;
boolean VERTICAL = false;
int FRAMERATE = 45;
int TYPICAL_MODE_TIME = 300;
float bright = 0.05; // Global brightness modifier
Routine drop = new Seizure();
Routine pong = new Pong();
Routine[] enabledRoutines = new Routine[] {
new Warp(new WarpSpeedMrSulu(), false, true, 0.5, 0.5),
// new Warp(null, true, false, 0.5, 0.5),
new Bursts(),
// new Chase(),
new ColorDrop(),
// new Fire(),
// new RGBRoutine(),
// new RainbowColors(),
new Waves(),
};
int w = 0;
int x = WIDTH;
PFont font;
int ZOOM = 1;
long modeFrameStart;
int mode = 0;
int direction = 1;
int position = 0;
Routine currentRoutine = null;
Sculpture sculpture;
PGraphics fadeLayer;
int fadeOutFrames = 0;
int fadeInFrames = 0;
WiiController controller;
void setup() {
// Had to enable OPENGL for some reason new fonts don't work in JAVA2D.
size(WIDTH, HEIGHT);
frameRate(FRAMERATE);
sculpture = new Sculpture(this, WIDTH, HEIGHT, true, transmit_address, transmit_port);
sculpture.setAddressingMode(Sculpture.ADDRESSING_HORIZONTAL_NORMAL);
sculpture.setEnableGammaCorrection(true);
setMode(0);
controller = new WiiController();
for (Routine r : enabledRoutines) {
r.setup(this);
}
drop.setup(this);
}
void setFadeLayer(int g) {
fadeLayer = createGraphics(WIDTH, HEIGHT, P2D);
fadeLayer.beginDraw();
fadeLayer.stroke(g);
fadeLayer.fill(g);
fadeLayer.rect(0, 0, WIDTH, HEIGHT);
fadeLayer.endDraw();
}
void setMode(int newMode) {
currentRoutine = enabledRoutines[newMode];
mode = newMode;
modeFrameStart = frameCount;
println("New mode " + currentRoutine.getClass().getName());
currentRoutine.reset();
}
void newMode() {
int newMode = mode;
String methodName;
fadeOutFrames = FRAMERATE;
setFadeLayer(240);
if (enabledRoutines.length > 1) {
while (newMode == mode) {
newMode = int(random(enabledRoutines.length));
}
}
setMode(newMode);
}
void draw() {
// if (((keyPressed && key == '1') || (controller.buttonOne && controller.buttonTwo)) && currentRoutine != pong) {
// currentRoutine = pong;
// pong.setup(this);
// }
if (controller.buttonA || (keyPressed && key == 'a') && currentRoutine != drop) {
//drop.draw();
currentRoutine = drop;
drop.reset();
}
else if (controller.buttonB || (keyPressed && key == 'c')) {
newMode();
}
else {
if (fadeOutFrames > 0) {
fadeOutFrames--;
blend(fadeLayer, 0, 0, WIDTH, HEIGHT, 0, 0, WIDTH, HEIGHT, MULTIPLY);
if (fadeOutFrames == 0) {
fadeInFrames = FRAMERATE;
}
}
else if (currentRoutine != null) {
currentRoutine.predraw();
currentRoutine.draw();
}
else {
println("Current method is null");
}
if (fadeInFrames > 0) {
setFadeLayer(240 - fadeInFrames * (240 / FRAMERATE));
blend(fadeLayer, 0, 0, WIDTH, HEIGHT, 0, 0, WIDTH, HEIGHT, MULTIPLY);
fadeInFrames--;
}
if (currentRoutine.isDone) {
currentRoutine.isDone = false;
newMode();
}
}
// }
// println(frameRate);
sculpture.sendData();
}