-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKomorebi.pde
executable file
·276 lines (233 loc) · 6.88 KB
/
Komorebi.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
import de.looksgood.ani.*; //test
import de.looksgood.ani.easing.*; //test
/**
* Komorebi Light
*
*/
import ddf.minim.*;
import java.util.*;
import toxi.geom.*;
import toxi.math.*;
import plethora.core.*;
import processing.opengl.*;
import processing.video.*;
import codeanticode.syphon.*;
//NightScene Variables
float globalRotation;
//maximum number of active particles for NightScene
int maxPGparticles = 800; //originally 800
int maxBGparticles = 4000; //originally 4000
//particles are stored in ArrayList PARTICLES
ArrayList<Particle> particles = new ArrayList<Particle>();
ArrayList<ParticleBGimage> particlesBG = new ArrayList<ParticleBGimage>();
color BACKGROUND_COLOR = color(0);
color PGRAPHICS_COLOR = color(0);
PGraphics pg; //drawing path layer
PGraphics bg; //default bg image
PImage sourceImage;
//end NightScene Variables
//SunnyScene Variables
//color sunnyFromBGColor = color(#FBFFC4);
//color sunnyFromBGColor = color(#FF9E00);
//color sunnyToBGColor = color(#FFC276); //original
//color sunnyToBGColor = color(#FF530D);
//color sunnyToBGColor = color(255, 87, 55);
//end SunnyScene Variables
//CloudScene Variables
//color cloudFromBGColor = color(#000000);
//color cloudToBGColor = color(#000020);
//end CloudScene Variables
//FireflyScene Variables
color fireFlyFromBGColor;
color fireFlyToBGColor;
ArrayList <Ple_Agent> fireflyBoids;
int fireflyPopulation = 800;
//end FireflyScene
long count;
Minim minim;
AudioPlayer BGMplayer;
RainScene rainScene;
NightScene nightScene;
CloudyScene cloudyScene;
SunnyScene sunnyScene;
FireflyScene fireflyScene;
RootsScene rootsScene;
BlackOut blackOut;
int currentScene = 0;
int sceneLength = toMillisecond(2,0);
int elapsedTime = 0;
boolean scenePaused = false;
boolean resetFullscreen = false;
Capture cam;
SyphonServer syphon;
void settings() {
size(1920, 2400, P3D); //fps 50 -- for running at NDC
//size(1280, 800, P3D); //laptop testing
//fullScreen(P3D, SPAN);
PJOGL.profile=1;
}
void setup() {
//size(1920, 1200); //fps 22
//fullScreen(P3D, SPAN); //during exhibit
//background(0);
noCursor();
syphon = new SyphonServer(this, "Komorebi");
String[] cameras = Capture.list();
//println(cameras);
cam = new Capture(this, cameras[0]);
noStroke();
rectMode(CENTER);
frameRate(35);
rainScene = new RainScene();
nightScene = new NightScene();
cloudyScene = new CloudyScene();
sunnyScene = new SunnyScene();
fireflyScene = new FireflyScene();
rootsScene = new RootsScene();
blackOut = new BlackOut();
minim = new Minim(this);
// BGMplayer = minim.loadFile("jingle.mp3");
BGMplayer = minim.loadFile("soundscape-rainy.wav");
//BGMplayer.play();
/*
* FireflyScene Begin
*/
//initialize the arrayList
fireflyBoids = new ArrayList <Ple_Agent>();
fireFlyFromBGColor = color(#000380); //from rainScene final blue
fireFlyToBGColor = color(#000000); //to black for NightScene
for (int i = 0; i < fireflyPopulation; i++) {
//set the initial location as 0,0,0
Vec3D v = new Vec3D ();
v.x = random(width);
v.y = random(height);
v.z = 0;
//create the plethora agents!
Ple_Agent pa = new Ple_Agent(this, v);
//generate a random initial velocity
Vec3D initialVelocity = new Vec3D (random(-1, 1), random(-1, 1), random(-1, 1));
//set some initial values:
//initial velocity
pa.setVelocity(initialVelocity);
//initialize the tail
pa.initTail((int)random(5, 10)); //originally 5 --> larger number = harder glow outline.
//add the agents to the list
fireflyBoids.add(pa);
}
/*
* FireflyScene End
*/
}
int sceneTimer() {
int hour = hour();
int minute = minute();
int second = second();
if(!resetFullscreen && hour == 18 && minute == 55){
launch(dataPath("MadFullscreen.app"));
resetFullscreen = true;
}
else if(hour == 3) resetFullscreen = false; //change this depending on day of the week: M—Th = 00; F—Sa = 03
if( (hour >= 0 && hour < 2) || (hour >= 19 && hour <= 23)) { //change this depending on day of the week: M—Th = hour < 23; F—Sa = hour < 02
//if((hour >= 19 && hour < 23)) { //change this depending on day of the week: M—Th = hour < 23; F—Sa = hour < 02
//if( hour >= 16 && hour < 19){
elapsedTime = toMillisecond(minute%15,second);
}else{
elapsedTime = -1;
}
//elapsedTime = toMillisecond(minute%15,second);
//elapsedTime = BGMplayer.position();
println("currentScene"+currentScene);
println("elapsedTime:"+ elapsedTime);
if (elapsedTime >= 0 && elapsedTime < toMillisecond(2, 00) ) {
if(currentScene==-1) {
BGMplayer.rewind();
BGMplayer.play();
}
currentScene = 0;
} else if (elapsedTime >= toMillisecond(2, 00) && elapsedTime < toMillisecond(4, 00) ) {
currentScene = 1;
} else if (elapsedTime >= toMillisecond(4, 00) && elapsedTime < toMillisecond(6, 00)) {
currentScene = 2;
} else if (elapsedTime >= toMillisecond(6, 00) && elapsedTime < toMillisecond(8, 00)) {
currentScene = 3;
} else if (elapsedTime >= toMillisecond(8, 00) && elapsedTime < toMillisecond(10,00)) {
currentScene = 4;
} else if (elapsedTime >= toMillisecond(10,00) && elapsedTime < toMillisecond(12,00)) {
currentScene = 5;
} else if(elapsedTime < 0 || (elapsedTime >= toMillisecond(12,00) && elapsedTime < toMillisecond(15,00))){
currentScene = -1;
}
return currentScene;
}
void draw() {
if (!scenePaused) currentScene = sceneTimer();
switch(currentScene) {
case -1:
blackOut.display();
break;
case 0:
rainScene.display();
break;
case 2:
nightScene.display();
break;
case 3:
cloudyScene.display();
break;
case 4:
sunnyScene.display();
break;
case 1:
fireflyScene.display();
break;
case 5:
rootsScene.display();
break;
}
/*noStroke();
fill(255, 204);
ellipse(mouseX, mouseY, mouseY/2+10, mouseY/2+10);
fill(255, 204);
int inverseX = width-mouseX;
int inverseY = height-mouseY;
ellipse(inverseX, inverseY, (inverseY/2)+10, (inverseY/2)+10);
*/
syphon.sendScreen();
}
//NightScene refresh with random globalRotation of particle generation
void keyPressed() {
switch(key) {
case 'r':
//clears the screen
background(BACKGROUND_COLOR);
particles.clear();
//randomly sets the global rotation / direction of the Particles
globalRotation = random(TWO_PI);
pg.beginDraw();
pg.clear();
pg.endDraw();
bg.beginDraw();
bg.clear();
bg.endDraw();
break;
case ' ':
scenePaused = !scenePaused;
break;
case 'b':
scenePaused = true;
currentScene = -1;
break;
case 'm':
println("mental");
launch(dataPath("MadFullscreen.app"));
break;
}
if (key >= 48 && key <= 54) {
scenePaused = true;
currentScene = key - 49;
println("current:" + currentScene);
}
}
void captureEvent(Capture cam) {
cam.read();
}