Commit | Line | Data |
---|---|---|
1d414e45 AG |
1 | class SineSphere extends DPat { |
2 | private SinLFO yrot = new SinLFO(0, TWO_PI, 3000); | |
d8239019 | 3 | public final Projection sinespin; |
1d414e45 | 4 | private BasicParameter rotation = new BasicParameter("rotation", 0); |
a9aad043 | 5 | float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax)); |
a9aad043 AG |
6 | Pick Sshape; |
7 | ||
0b1785e3 | 8 | class Sphery { |
a9aad043 | 9 | float f1xcenter, f1ycenter, f1zcenter, f2xcenter , f2ycenter, f2zcenter; //second three are for an ellipse with two foci |
0b1785e3 AG |
10 | private SinLFO vibration; |
11 | private SinLFO surface; | |
12 | private SinLFO vx; | |
a9aad043 AG |
13 | private SinLFO xbounce; |
14 | public SinLFO ybounce; | |
15 | private SinLFO zbounce; | |
0b1785e3 | 16 | float vibration_min, vibration_max, vperiod; |
a9aad043 AG |
17 | public BasicParameter widthparameter; |
18 | public BasicParameter huespread; | |
19 | public BasicParameter bouncerate; | |
20 | public BasicParameter bounceamp; | |
0b1785e3 | 21 | |
a316cb97 | 22 | |
a9aad043 AG |
23 | |
24 | public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_min, float vibration_max, float vperiod) | |
25 | { | |
0b1785e3 AG |
26 | this.f1xcenter = f1xcenter; |
27 | this.f1ycenter = f1ycenter; | |
28 | this.f1zcenter = f1zcenter; | |
29 | this.vibration_min = vibration_min; | |
30 | this.vibration_max = vibration_max; | |
31 | this.vperiod = vperiod; | |
1d414e45 AG |
32 | //addParameter(bounceamp = new BasicParameter("Amp", .5)); |
33 | //addParameter(bouncerate = new BasicParameter("Rate", .5)); //ybounce.modulateDurationBy(bouncerate); | |
a9aad043 AG |
34 | addParameter(widthparameter = new BasicParameter("Width", .1)); |
35 | addParameter(huespread = new BasicParameter("Hue", .2)); | |
d8239019 | 36 | |
a9aad043 AG |
37 | addModulator( vx = new SinLFO(-4000, 10000, 100000)).trigger() ; |
38 | //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger(); | |
39 | addModulator(ybounce= new SinLFO(model.yMax/3, 2*model.yMax/3, 240000./lx.tempo.bpm())).trigger(); //ybounce.modulateDurationBy | |
40 | ||
41 | //addModulator(bounceamp); //ybounce.setMagnitude(bouncerate); | |
42 | addModulator( vibration = new SinLFO(vibration_min , vibration_max, 240000./lx.tempo.bpm())).trigger(); //vibration.modulateDurationBy(vx); | |
43 | ||
44 | } | |
45 | public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float f2xcenter, float f2ycenter, float f2zcenter, | |
46 | float vibration_min, float vibration_max, float vperiod) | |
47 | { | |
48 | this.f1xcenter = f1xcenter; | |
49 | this.f1ycenter = f1ycenter; | |
50 | this.f1zcenter = f1zcenter; | |
51 | this.f2xcenter = f2xcenter; | |
52 | this.f2ycenter = f2ycenter; | |
53 | this.f2zcenter = f2zcenter; | |
54 | this.vibration_min = vibration_min; | |
55 | this.vibration_max = vibration_max; | |
56 | this.vperiod = vperiod; | |
57 | //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger(); | |
58 | addModulator(ybounce).trigger(); | |
59 | addModulator( vibration = new SinLFO(vibration_min , vibration_max, lx.tempo.rampf())).trigger(); //vibration.modulateDurationBy(vx); | |
60 | addParameter(widthparameter = new BasicParameter("Width", .1)); | |
61 | addParameter(huespread = new BasicParameter("Hue", .2)); | |
62 | ||
63 | } | |
64 | ||
65 | ||
66 | ||
67 | ||
68 | ||
69 | float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, float f1z) | |
70 | { | |
0b1785e3 AG |
71 | return dist(px, py, pz, f1x, f1y, f1z); |
72 | } | |
c2f643bd | 73 | //void updatespherey(deltaMs, ) |
a9aad043 AG |
74 | color spheryvalue (float px, float py, float pz , float f1xc, float f1yc, float f1zc) |
75 | { | |
76 | //switch(sShpape.cur() ) {} | |
a41f334c | 77 | return lx.hsb(constrain(huespread.getValuef()*5*px, 0, 360) , dist(px, py, pz, f1xc, f1yc, f1zc) , |
a9aad043 AG |
78 | max(0, 100 - 100*widthparameter.getValuef()*abs(dist(px, py, pz, f1xcenter, ybounce.getValuef(), f1zcenter) |
79 | - vibration.getValuef() ) ) ); | |
0b1785e3 | 80 | } |
a9aad043 AG |
81 | color ellipsevalue(float px, float py, float pz , float f1xc, float f1yc, float f1zc, float f2xc, float f2yc, float f2zc) |
82 | { | |
83 | //switch(sShpape.cur() ) {} | |
a41f334c | 84 | return lx.hsb(huespread.getValuef()*5*px, dist(model.xMax-px, model.yMax-py, model.zMax-pz, f1xc, f1yc, f1zc) , |
a9aad043 AG |
85 | max(0, 100 - 100*widthparameter.getValuef() * |
86 | abs( (dist(px, py, pz, f1xc, ybounce.getValuef(), f1zc) + | |
87 | (dist(px, py , pz, f2xc, ybounce.getValuef(), f2zc) ) )/2 | |
88 | - 1.2*vibration.getValuef() ) ) ) ; | |
0b1785e3 | 89 | } |
a9aad043 | 90 | |
d8239019 AG |
91 | void run(double deltaMs) { |
92 | float vv = vibration.getValuef(); | |
93 | float ybv = ybounce.getValuef(); | |
94 | ||
95 | } | |
0b1785e3 | 96 | |
a9aad043 AG |
97 | } |
98 | ||
99 | ||
0b1785e3 | 100 | final Sphery[] spherys; |
1d414e45 | 101 | |
a9aad043 AG |
102 | SineSphere(GLucose glucose) |
103 | { | |
0b1785e3 | 104 | super(glucose); |
d8239019 AG |
105 | sinespin = new Projection(model); |
106 | addModulator(yrot).trigger(); | |
1d414e45 | 107 | addParameter(rotation); |
b30f14fd | 108 | //Sshape = addPick("Shape", , 1); |
a9aad043 AG |
109 | spherys = new Sphery[] { |
110 | new Sphery(model.xMax/4, model.yMax/2, model.zMax/2, modelrad/16, modelrad/8, 3000), | |
111 | new Sphery(.75*model.xMax, model.yMax/2, model.zMax/2, modelrad/20, modelrad/10, 2000), | |
112 | new Sphery(model.xMax/2, model.yMax/2, model.zMax/2, modelrad/4, modelrad/8, 2300), | |
113 | }; | |
c2f643bd | 114 | |
0b1785e3 AG |
115 | } |
116 | ||
a9aad043 AG |
117 | // public void onParameterChanged(LXParameter parameter) |
118 | // { | |
e28f168c | 119 | |
e28f168c | 120 | |
a9aad043 AG |
121 | // for (Sphery s : spherys) { |
122 | // if (s == null) continue; | |
123 | // double bampv = s.bounceamp.getValue(); | |
124 | // double brv = s.bouncerate.getValue(); | |
125 | // double tempobounce = lx.tempo.bpm(); | |
126 | // if (parameter == s.bounceamp) | |
127 | // { | |
128 | // s.ybounce.setRange(bampv*model.yMax/3 , bampv*2*model.yMax/3, brv); | |
129 | // } | |
130 | // else if ( parameter == s.bouncerate ) | |
131 | // { | |
132 | // s.ybounce.setDuration(120000./tempobounce); | |
133 | // } | |
134 | // } | |
135 | // } | |
e28f168c | 136 | |
1d414e45 | 137 | public void run( double deltaMs) { |
a9aad043 AG |
138 | float t = lx.tempo.rampf(); |
139 | float bpm = lx.tempo.bpmf(); | |
140 | //spherys[1].run(deltaMs); | |
141 | //spherys[2].run(deltaMs); | |
d8239019 AG |
142 | //spherys[3].run(deltaMs);] |
143 | sinespin.reset(model) | |
144 | ||
1d414e45 AG |
145 | // Translate so the center of the car is the origin, offset |
146 | .translateCenter(model, 0, model.cx, 0) | |
147 | .scale(1.3,1.3,1.3) | |
148 | // Rotate around the origin (now the center of the car) about an y-vector | |
149 | .rotate(yrot.getValuef(), 0, 1 , 0); | |
d8239019 | 150 | |
1d414e45 | 151 | |
d8239019 | 152 | |
1d414e45 AG |
153 | //.translateCenter(model, model.cx, , model.cz); |
154 | ||
d8239019 | 155 | |
1d414e45 AG |
156 | for (Coord p: sinespin) |
157 | // for (Point p: model.points) | |
158 | { | |
d8239019 AG |
159 | color c = 0; |
160 | c = blendColor(c, spherys[1].spheryvalue(p.x, p.y, p.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD); | |
161 | c = blendColor(c, spherys[0].spheryvalue(p.x, p.y, p.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD); | |
162 | c = blendColor(c, spherys[2].spheryvalue(p.x, p.y, p.z, model.xMax/2, model.yMax/2, model.zMax/2),ADD); | |
163 | ||
164 | colors[p.index] = lx.hsb(lx.h(c), lx.s(c), lx.b(c)); | |
165 | ||
166 | } | |
167 | ||
e28f168c | 168 | |
e27a8652 | 169 | |
a9aad043 AG |
170 | } |
171 | int spheremode = 0; | |
e27a8652 | 172 | |
a9aad043 AG |
173 | // void keyPressed() { |
174 | // spheremode++; | |
175 | // } | |
e28f168c | 176 | |
d8239019 AG |
177 | // color CalcPoint(PVector Px) |
178 | // { | |
179 | // // if (spheremode == 0 ) | |
a9aad043 | 180 | //{ |
d8239019 | 181 | |
a9aad043 AG |
182 | //} |
183 | // else if (spheremode == 1) | |
184 | // { | |
185 | ||
186 | // color c = 0; | |
187 | // c = blendColor(c, spherys[3].ellipsevalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/4, 3*model.xMax/4, 3*model.yMax/4, 3*model.zMax/4),ADD); | |
188 | // return c; | |
189 | // } | |
a41f334c | 190 | // return lx.hsb(0,0,0); |
a9aad043 AG |
191 | // // else if(spheremode ==2) |
192 | // { color c = 0; | |
a41f334c | 193 | // return lx.hsb(CalcCone( (xyz by = new xyz(0,spherys[2].ybounce.getValuef(),0) ), Px, mid) ); |
a9aad043 AG |
194 | |
195 | // } | |
196 | ||
197 | ||
d8239019 | 198 | // } |
a9aad043 AG |
199 | |
200 | } | |
201 | ||
5bc92bc2 | 202 | class CubeCurl extends SCPattern{ |
b30f14fd AG |
203 | float CH, CW, diag; |
204 | ArrayList<PVector> cubeorigin = new ArrayList<PVector>(); | |
205 | ArrayList<PVector> centerlist = new ArrayList<PVector>(); | |
5bc92bc2 AG |
206 | private SinLFO curl = new SinLFO(0, Cube.EDGE_HEIGHT, 5000 ); |
207 | ||
208 | private SinLFO bg = new SinLFO(180, 220, 3000); | |
209 | ||
210 | CubeCurl(GLucose glucose){ | |
211 | super(glucose); | |
212 | addModulator(curl).trigger(); | |
213 | addModulator(bg).trigger(); | |
7c7625ec AG |
214 | this.CH = Cube.EDGE_HEIGHT; |
215 | this.CW = Cube.EDGE_WIDTH; | |
f1370a0b | 216 | this.diag = sqrt(CW*CW + CW*CW); |
b30f14fd | 217 | |
7c7625ec | 218 | |
b30f14fd | 219 | ArrayList<PVector> centerlistrelative = new ArrayList<PVector>(); |
7c7625ec | 220 | for (int i = 0; i < model.cubes.size(); i++){ |
b30f14fd AG |
221 | Cube a = model.cubes.get(i); |
222 | cubeorigin.add(new PVector(a.x, a.y, a.z)); | |
7c7625ec | 223 | centerlist.add(centerofcube(i)); |
b30f14fd AG |
224 | |
225 | } | |
5bc92bc2 AG |
226 | |
227 | } | |
7c7625ec AG |
228 | //there is definitely a better way of doing this! |
229 | PVector centerofcube(int i) { | |
230 | Cube c = model.cubes.get(i); | |
f1370a0b AG |
231 | |
232 | println(" cube #: " + i + " c.x " + c.x + " c.y " + c.y + " c.z " + c.z ); | |
1d414e45 AG |
233 | // PVector cubeangle = new PVector(c.rx, c.ry, c.rz); |
234 | println("raw x angle: " + c.rx + "raw y angle: " + c.ry + "raw z angle: " + c.rz); | |
f1370a0b AG |
235 | PVector cubecenter = new PVector(c.x + CW/2, c.y + CH/2, c.z + CW/2); |
236 | println("cubecenter unrotated: " + cubecenter.x + " " +cubecenter.y + " " +cubecenter.z ); | |
1d414e45 | 237 | PVector centerrot = new PVector(cos(c.rx)*CW/2 - sin(c.rx)*CW/2, cubecenter.y, cos(c.rz)*CW/2 + sin(c.rz)*CW/2); |
f1370a0b | 238 | // nCos*(y-o.y) - nSin*(z-o.z) + o.y |
1d414e45 | 239 | cubecenter = PVector.add(new PVector(c.x, c.y, c.z), centerrot); |
f1370a0b AG |
240 | println( " cubecenter.x " + cubecenter.x + " cubecenter.y " + cubecenter.y + " cubecenter.z " + cubecenter.z + " "); |
241 | ||
242 | ||
b30f14fd | 243 | return cubecenter; |
7c7625ec AG |
244 | } |
245 | ||
5bc92bc2 AG |
246 | |
247 | void run(double deltaMs){ | |
248 | for (int i =0; i < model.cubes.size(); i++) { | |
249 | Cube c = model.cubes.get(i); | |
250 | float cfloor = c.y; | |
251 | ||
f1370a0b | 252 | // if (i%3 == 0){ |
5bc92bc2 | 253 | |
f1370a0b AG |
254 | // for (Point p : c.points ){ |
255 | // // colors[p.index]=color(0,0,0); | |
256 | // //float dif = (p.y - c.y); | |
257 | // //colors[p.index] = color( bg.getValuef() , 80 , dif < curl.getValuef() ? 80 : 0, ADD); | |
258 | // } | |
259 | // } | |
5bc92bc2 | 260 | |
f1370a0b | 261 | // else if (i%3 == 1) { |
5bc92bc2 | 262 | |
f1370a0b AG |
263 | // for (Point p: c.points){ |
264 | // colors[p.index]=color(0,0,0); | |
265 | // float dif = (p.y - c.y); | |
266 | // // colors[p.index] = | |
267 | // // color(bg.getValuef(), | |
268 | // // map(curl.getValuef(), 0, Cube.EDGE_HEIGHT, 20, 100), | |
269 | // // 100 - 10*abs(dif - curl.getValuef()), ADD ); | |
270 | // } | |
271 | // } | |
272 | // else if (i%3 == 2){ | |
b30f14fd | 273 | // centerlist[i].sub(cubeorigin(i); |
5bc92bc2 | 274 | for (Point p: c.points) { |
b30f14fd | 275 | PVector pv = new PVector(p.x, p.y, p.z); |
f1370a0b | 276 | colors[p.index] =color( constrain(4* pv.dist(centerlist.get(i)), 0, 360) , 50, 100 ); |
b30f14fd | 277 | // colors[p.index] =color(constrain(centerlist[i].x, 0, 360), constrain(centerlist[i].y, 0, 100), ); |
5bc92bc2 AG |
278 | |
279 | ||
b30f14fd | 280 | } |
5bc92bc2 AG |
281 | |
282 | ||
f1370a0b | 283 | //} |
5bc92bc2 AG |
284 | |
285 | } | |
286 | } | |
287 | } | |
288 | ||
a9aad043 AG |
289 | class HueTestHSB extends SCPattern{ |
290 | BasicParameter HueT = new BasicParameter("Hue", .5); | |
291 | BasicParameter SatT = new BasicParameter("Sat", .5); | |
292 | BasicParameter BriT = new BasicParameter("Bright", .5); | |
293 | ||
294 | HueTestHSB(GLucose glucose) { | |
295 | super(glucose); | |
296 | addParameter(HueT); | |
297 | addParameter(SatT); | |
298 | addParameter(BriT); | |
299 | } | |
300 | void run(double deltaMs){ | |
301 | ||
302 | for (Point p : model.points) { | |
303 | color c = 0; | |
a41f334c | 304 | c = blendColor(c, lx.hsb(360*HueT.getValuef(), 100*SatT.getValuef(), 100*BriT.getValuef()), ADD); |
a9aad043 AG |
305 | colors[p.index]= c; |
306 | } | |
307 | int now= millis(); | |
308 | if (now % 1000 <= 20) | |
309 | { | |
310 | println("Hue: " + 360*HueT.getValuef() + "Sat: " + 100*SatT.getValuef() + "Bright: " + 100*BriT.getValuef()); | |
311 | } | |
312 | } | |
0b1785e3 | 313 | |
a41f334c | 314 | } |