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