2 class SineSphere extends APat {
3 float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax));
4 private BasicParameter yrotspeed = new BasicParameter("yspeed", 3000, 1, 10000);
5 private BasicParameter yrot2speed = new BasicParameter("y2speed", 4000, 1, 15000);
6 private BasicParameter yrot3speed = new BasicParameter("y3speed", 1400, 1, 15000);
7 private BasicParameter vibrationrate = new BasicParameter("vib", 3000, 1, 10000);
8 private SawLFO yrot = new SawLFO(0, TWO_PI, yrotspeed);
9 private SawLFO yrot2 = new SawLFO(0, -TWO_PI, yrot2speed);
10 private SawLFO yrot3 = new SawLFO(0, -TWO_PI, yrot3speed);
11 public BasicParameter huespread = new BasicParameter("Hue", 0, 180);
12 public BasicParameter widthparameter= new BasicParameter("Width", 20, 1, 60);
13 public BasicParameter vibration_magnitude = new BasicParameter("Vmag", 20, 2, modelrad/2);
14 public BasicParameter scale = new BasicParameter("Scale", 1, .1, 5);
15 private int pitch = 0;
16 private int channel = 0;
17 private int velocity = 0;
19 public final LXProjection sinespin;
20 public final LXProjection sinespin2;
21 public final LXProjection sinespin3;
25 public BasicParameter rotationx = new BasicParameter("rotx", 0, 0, 1 );
26 public BasicParameter rotationy = new BasicParameter("roty", 1, 0, 1);
27 public BasicParameter rotationz = new BasicParameter("rotz", 0, 0, 1);
29 public final PVector P = new PVector();
32 float f1xcenter, f1ycenter, f1zcenter, f2xcenter , f2ycenter, f2zcenter; //second three are for an ellipse with two foci
33 private SinLFO vibration;
34 private SinLFO surfacewave;
36 private SinLFO xbounce;
37 public SinLFO ybounce;
38 private SinLFO zbounce;
39 float vibration_magnitude, vperiod, radius, vibration_min, vibration_max;
41 //public BasicParameter huespread;
42 public BasicParameter bouncerate;
43 public BasicParameter bounceamp;
44 public BasicParameter vibrationrate;
45 public final PVector circlecenter;
47 public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float radius, float vibration_magnitude , float vperiod)
49 this.f1xcenter = f1xcenter;
50 this.f1ycenter = f1ycenter;
51 this.f1zcenter = f1zcenter;
53 this.circlecenter= new PVector(f1xcenter,f1ycenter,f1zcenter);
55 this.vibration_magnitude = vibration_magnitude;
57 this.vperiod = vperiod;
58 //addParameter(bounceamp = new BasicParameter("Amp", .5));
59 //addParameter(bouncerate = new BasicParameter("Rate", .5)); //ybounce.modulateDurationBy(bouncerate);
60 //addParameter(vibrationrate = new BasicParameter("vibration", 1000, 10000));
61 //addParameter(widthparameter = new BasicParameter("Width", .2));
62 //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger();
63 addModulator(ybounce= new SinLFO(model.yMax/3, 2*model.yMax/3, 240000)).trigger(); //bounce.modulateDurationBy
65 //addModulator(bounceamp); //ybounce.setMagnitude(bouncerate);
66 addModulator( vibration = new SinLFO( this.radius - vibration_magnitude , this.radius + vibration_magnitude, vperiod)).trigger(); //vibration.setPeriod(240000/lx.tempo.bpm());
71 // public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_magnitude, float vperiod)
73 // this.f1xcenter = f1xcenter;
74 // this.f1ycenter = f1ycenter;
75 // this.f1zcenter = f1zcenter;
76 // this.vibration_magnitude = vibration_magnitude;
77 // this.vperiod = vperiod;
78 // addModulator(ybounce= new SinLFO(model.yMax/3, 2*model.yMax/3, 240000)).trigger(); //bounce.modulateDurationBy
79 // addModulator( vibration = new SinLFO( modelrad/10 - vibration_magnitude , modelrad/10 + vibration_magnitude, vperiod)).trigger(); //vibration.setPeriod(240000/lx.tempo.bpm());
84 // public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float f2xcenter, float f2ycenter, float f2zcenter,
85 // float vibration_min, float vibration_max, float vperiod)
88 // this.f1xcenter = f1xcenter;
89 // this.f1ycenter = f1ycenter;
90 // this.f1zcenter = f1zcenter;
91 // this.f2xcenter = f2xcenter;
92 // this.f2ycenter = f2ycenter;
93 // this.f2zcenter = f2zcenter;
94 // this.vibration_min = vibration_min;
95 // this.vibration_max = vibration_max;
96 // this.vperiod = vperiod;
97 // //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger();
98 // addModulator(ybounce).trigger();
99 // addModulator( vibration = new SinLFO(vibration_min , vibration_max, lx.tempo.rampf())).trigger(); //vibration.modulateDurationBy(vx);
100 // addParameter(widthparameter = new BasicParameter("Width", .1));
101 // //addParameter(huespread = new BasicParameter("bonk", .2));
105 public int c1c (float a) { return round(100*constrain(a,0,1)); }
107 void setVibrationPeriod(double period){
108 // to-do: make this conditional upon time signature
110 this.vibration.setPeriod(period);
113 void setVibrationMagnitude(double mag){
114 //to-do: make this optionally conditional upon decibel volume, frequency spectrum)
115 this.vibration.setRange(-mag,mag);
120 float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, float f1z)
122 return dist(px, py, pz, f1x, f1y, f1z);
124 //void updatespherey(deltaMs, )
126 float quadrant(PVector q) {
127 float qtheta = atan2( (q.x-f1xcenter) , (q.z - f1zcenter) );
128 float qphi = acos( (q.z-f1zcenter)/(PVector.dist(q,circlecenter)) );
131 return map(qtheta, -PI/2, PI/2, 200-huespread.getValuef(), 240+huespread.getValuef());
132 //if (q.x > f1xcenter ) {return 140 ;}
136 // float noisesat(PVector q) {
142 color spheryvalue (PVector p) {
143 circlecenter.set(this.f1xcenter, this.f1ycenter, this.f1zcenter);
146 //switch(sShpape.cur() ) {}
148 float b = max(0, 100 - widthparameter.getValuef()*abs(p.dist(circlecenter)
149 - vibration.getValuef()) );
156 constrain(quadrant(p), 0, 360),
157 // constrain(100*noise(quadrant(p)), 0, 100),
162 color ellipsevalue(float px, float py, float pz , float f1xc, float f1yc, float f1zc, float f2xc, float f2yc, float f2zc)
164 //switch(sShpape.cur() ) {}
165 return lx.hsb(huespread.getValuef()*5*px, dist(model.xMax-px, model.yMax-py, model.zMax-pz, f1xc, f1yc, f1zc) ,
166 max(0, 100 - 100*widthparameter.getValuef() *
167 abs( (dist(px, py, pz, f1xc, ybounce.getValuef(), f1zc) +
168 (dist(px, py , pz, f2xc, ybounce.getValuef(), f2zc) ) )/2
169 - 1.2*vibration.getValuef() ) ) ) ;
175 boolean noteOn(Note note) {
176 int row = note.getPitch(), col = note.getChannel();
177 // if (row == 57) {KeyPressed = col; return true; }
178 return super.noteOn(note);
182 // public boolean noteOn(Note note) {
183 // pitch= note.getPitch();
184 // velocity=note.getVelocity();
185 // channel=note.getChannel();
189 // public boolean gridPressed(int row, int col) {
190 // pitch = row; channel = col;
191 // cur = NumApcCols*(pitch-53)+col;
192 // //setState(row, col, 0 ? 1 : 0);
197 final Sphery[] spherys;
202 println("modelrad " + modelrad);
203 sinespin = new LXProjection(model);
204 sinespin2 = new LXProjection(model);
205 sinespin3= new LXProjection(model);
206 addParameter(huespread);
207 addParameter(vibrationrate);
208 addParameter(widthparameter);
209 addParameter(rotationx);
210 addParameter(rotationy);
211 addParameter(rotationz);
212 addParameter(yrotspeed);
213 addParameter(yrot2speed);
214 addParameter(yrot3speed);
215 addParameter(vibration_magnitude);
217 addModulator(yrot).trigger();
218 addModulator(yrot2).trigger();
219 addModulator(yrot3).trigger();
220 //Galaxy = addPick("Galaxy", 1, 3, new String[] {"home", "vertical","single","aquarium"});
221 STime =addPick("Time", 1, 4, new String[]{"half", "triplet", "beat", "2x", "3x" });
223 spherys = new Sphery[] {
224 new Sphery(model.xMax/4, model.yMax/2, model.zMax/2, modelrad/12, modelrad/25, 3000),
225 new Sphery(.75*model.xMax, model.yMax/2, model.zMax/2, modelrad/14, modelrad/28, 2000),
226 new Sphery(model.cx, model.cy, model.cz, modelrad/5, modelrad/15, 2300),
227 new Sphery(.7*model.xMax, .65*model.yMax, .5*model.zMax, modelrad/11, modelrad/25, 3500),
228 new Sphery(.75*model.xMax, .8*model.yMax, .7*model.zMax, modelrad/12, modelrad/30, 2000)
234 // public void onParameterChanged(LXParameter parameter)
238 // for (Sphery s : spherys) {
239 // if (s == null) continue;
240 // double bampv = s.bounceamp.getValue();
241 // double brv = s.bouncerate.getValue();
242 // double tempobounce = lx.tempo.bpm();
243 // if (parameter == s.bounceamp)
245 // s.ybounce.setRange(bampv*model.yMax/3 , bampv*2*model.yMax/3, brv);
247 // else if ( parameter == s.bouncerate )
249 // s.ybounce.setDuration(120000./tempobounce);
254 public void run( double deltaMs) {
255 float t = lx.tempo.rampf();
256 float bpm = lx.tempo.bpmf();
257 float scalevalue = scale.getValuef();
258 int spherytime= STime.Cur();
261 switch (spherytime) {
263 case 0: t = map(.5*t ,0,.5, 0,1); bpm = .5*bpm; break;
265 case 1: t = t; bpm = bpm; break;
267 case 2: t = map(2*t,0,2,0,1); bpm = 2*bpm; break;
269 default: t= t; bpm = bpm;
272 //switch(sphery.colorscheme)
274 for ( Sphery s: spherys){
275 s.setVibrationPeriod(vibrationrate.getValuef());
276 // s.setVibrationMagnitude(vibration_magnitude.getValuef());
282 // Translate so the center of the car is the origin, offset
284 .scale(scalevalue, scalevalue, scalevalue)
285 // Rotate around the origin (now the center of the car) about an y-vector
286 .rotate(yrot.getValuef(), rotationx.getValuef(), rotationy.getValuef() , rotationz.getValuef())
287 .translate(model.cx, model.cy, model.cz);
293 for (LXVector p: sinespin)
294 // for (Point p: model.points)
296 P.set(p.x, p.y, p.z);
297 // PVector P = new PVector(p.x, p.y, p.z);
299 c = blendIfColor(c, spherys[1].spheryvalue(P), ADD);
300 c = blendIfColor(c, spherys[0].spheryvalue(P), ADD);
301 c = blendIfColor(c, spherys[2].spheryvalue(P),ADD);
310 .scale(scalevalue,scalevalue,scalevalue)
311 .rotate(yrot2.getValuef(), rotationx.getValuef(), rotationy.getValuef() , rotationz.getValuef())
312 .translate(model.cx,model.cy,model.cz);
314 for (LXVector p: sinespin2)
316 // PVector P = new PVector(p.x, p.y, p.z);
317 P.set(p.x, p.y, p.z);
318 c = blendIfColor(c, spherys[3].spheryvalue(P),ADD);
320 colors[p.index] = blendIfColor(colors[p.index], c , ADD);
325 .scale(scalevalue,scalevalue,scalevalue)
326 .rotate(yrot3.getValuef(),-1 + rotationx.getValuef(), rotationy.getValuef(), rotationz.getValuef())
327 .translate(model.cx, model.cy, model.cz);
328 for (LXVector p: sinespin3)
330 // PVector P = new PVector(p.x, p.y, p.z);
331 P.set(p.x, p.y, p.z);
332 c = blendIfColor(c, spherys[4].spheryvalue(P),ADD);
334 colors[p.index] = blendIfColor(colors[p.index], c , ADD);
346 color blendIfColor(color c1, color c2, int mode) {
348 return blendColor(c1, c2, mode);
355 // 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);
358 // return lx.hsb(0,0,0);
359 // // else if(spheremode ==2)
361 // return lx.hsb(CalcCone( (xyz by = new xyz(0,spherys[2].ybounce.getValuef(),0) ), Px, mid) );
369 /*This just takes all of Dan Horwitz's code that I want to inherit and leaves the rest behind.
370 A work in progress. */
372 public class APat extends SCPattern
376 ArrayList<Pick> picks = new ArrayList<Pick> ();
377 ArrayList<DBool> bools = new ArrayList<DBool> ();
379 PVector mMax, mCtr, mHalf;
384 float[] xWaveNz, yWaveNz;
385 int nPoint , nPoints;
386 PVector xyzJog = new PVector(), modmin;
388 float NoiseMove = random(10000);
389 BasicParameter pSpark, pWave, pRotX, pRotY, pRotZ, pSpin, pTransX, pTransY;
390 DBool pXsym, pYsym, pRsym, pXdup, pXtrip, pJog, pGrey;
392 float lxh () { return lx.getBaseHuef(); }
393 int c1c (float a) { return round(100*constrain(a,0,1)); }
394 float interpWv(float i, float[] vals) { return interp(i-floor(i), vals[floor(i)], vals[ceil(i)]); }
395 void setNorm (PVector vec) { vec.set(vec.x/mMax.x, vec.y/mMax.y, vec.z/mMax.z); }
396 void setRand (PVector vec) { vec.set(random(mMax.x), random(mMax.y), random(mMax.z)); }
397 void setVec (PVector vec, LXPoint p) { vec.set(p.x, p.y, p.z); }
398 void interpolate(float i, PVector a, PVector b) { a.set(interp(i,a.x,b.x), interp(i,a.y,b.y), interp(i,a.z,b.z)); }
399 void StartRun(double deltaMs) { }
400 float val (BasicParameter p) { return p.getValuef(); }
401 color CalcPoint(PVector p) { return lx.hsb(0,0,0); }
402 color blend3(color c1, color c2, color c3) { return blendColor(c1,blendColor(c2,c3,ADD),ADD); }
404 void rotateZ (PVector p, PVector o, float nSin, float nCos) { p.set( nCos*(p.x-o.x) - nSin*(p.y-o.y) + o.x , nSin*(p.x-o.x) + nCos*(p.y-o.y) + o.y,p.z); }
405 void rotateX (PVector p, PVector o, float nSin, float nCos) { p.set(p.x,nCos*(p.y-o.y) - nSin*(p.z-o.z) + o.y , nSin*(p.y-o.y) + nCos*(p.z-o.z) + o.z ); }
406 void rotateY (PVector p, PVector o, float nSin, float nCos) { p.set( nSin*(p.z-o.z) + nCos*(p.x-o.x) + o.x,p.y, nCos*(p.z-o.z) - nSin*(p.x-o.x) + o.z ); }
408 BasicParameter addParam(String label, double value) { BasicParameter p = new BasicParameter(label, value); addParameter(p); return p; }
410 PVector vT1 = new PVector(), vT2 = new PVector();
411 float calcCone (PVector v1, PVector v2, PVector c) { vT1.set(v1); vT2.set(v2); vT1.sub(c); vT2.sub(c);
412 return degrees(PVector.angleBetween(vT1,vT2)); }
414 Pick addPick(String name, int def, int _max, String[] desc) {
415 Pick P = new Pick(name, def, _max+1, nMaxRow, desc);
416 nMaxRow = P.EndRow + 1;
421 boolean noteOff(Note note) {
422 int row = note.getPitch(), col = note.getChannel();
423 for (int i=0; i<bools.size(); i++) if (bools.get(i).set(row, col, false)) { presetManager.dirty(this); return true; }
424 updateLights(); return false;
427 boolean noteOn(Note note) {
428 int row = note.getPitch(), col = note.getChannel();
429 for (int i=0; i<picks.size(); i++) if (picks.get(i).set(row, col)) { presetManager.dirty(this); return true; }
430 for (int i=0; i<bools.size(); i++) if (bools.get(i).set(row, col, true)) { presetManager.dirty(this); return true; }
431 println("row: " + row + " col: " + col); return false;
434 void onInactive() { uiDebugText.setText(""); }
436 for (int i=0; i<bools .size(); i++) bools.get(i).reset();
437 for (int i=0; i<picks .size(); i++) picks.get(i).reset();
438 presetManager.dirty(this);
447 nPoints = model.points.size();
448 pXsym = new DBool("X-SYM", false, 48, 0); bools.add(pXsym );
449 pYsym = new DBool("Y-SYM", false, 48, 1); bools.add(pYsym );
450 pRsym = new DBool("R-SYM", false, 48, 2); bools.add(pRsym );
451 pXdup = new DBool("X-DUP", false, 48, 3); bools.add(pXdup );
452 pJog = new DBool("JOG" , false, 48, 4); bools.add(pJog );
453 pGrey = new DBool("GREY" , false, 48, 5); bools.add(pGrey );
455 modmin = new PVector(model.xMin, model.yMin, model.zMin);
456 mMax = new PVector(model.xMax, model.yMax, model.zMax); mMax.sub(modmin);
457 mCtr = new PVector(); mCtr.set(mMax); mCtr.mult(.5);
458 mHalf = new PVector(.5,.5,.5);
459 xWaveNz = new float[ceil(mMax.y)+1];
460 yWaveNz = new float[ceil(mMax.x)+1];
462 //println (model.xMin + " " + model.yMin + " " + model.zMin);
463 //println (model.xMax + " " + model.yMax + " " + model.zMax);
464 //for (MidiOutputDevice o: RWMidi.getOutputDevices()) { if (o.toString().contains("APC")) { APCOut = o.createOutput(); break;}}
468 float raw = val(pSpin);
471 } else if (raw >= 0.55) {
477 void setAPCOutput(MidiOutput output) {
481 void updateLights() { if (APCOut == null) return;
482 for (int i = 0; i < NumApcRows; ++i)
483 for (int j = 0; j < 8; ++j) APCOut.sendNoteOn(j, 53+i, 0);
484 for (int i=0; i<picks .size(); i++) APCOut.sendNoteOn(picks.get(i).CurCol, picks.get(i).CurRow, 3);
485 for (int i=0; i<bools .size(); i++) if (bools.get(i).b) APCOut.sendNoteOn (bools.get(i).col, bools.get(i).row, 1);
486 else APCOut.sendNoteOff (bools.get(i).col, bools.get(i).row, 0);
489 void run(double deltaMs)
491 if (deltaMs > 100) return;
493 if (this == midiEngine.getFocusedDeck().getActivePattern()) {
494 String Text1="", Text2="";
495 for (int i=0; i<bools.size(); i++) if (bools.get(i).b) Text1 += " " + bools.get(i).tag + " ";
496 for (int i=0; i<picks.size(); i++) Text1 += picks.get(i).tag + ": " + picks.get(i).CurDesc() + " ";
497 uiDebugText.setText(Text1, Text2);
500 NoiseMove += deltaMs; NoiseMove = NoiseMove % 1e7;
502 PVector P = new PVector(), tP = new PVector(), pSave = new PVector();
503 PVector pTrans = new PVector(val(pTransX)*200-100, val(pTransY)*100-50,0);
507 float tRamp = (lx.tempo.rampf() % .25);
508 if (tRamp < LastJog) xyzJog.set(randctr(mMax.x*.2), randctr(mMax.y*.2), randctr(mMax.z*.2));
512 // precalculate this stuff
513 float wvAmp = val(pWave), sprk = val(pSpark);
515 for (int i=0; i<ceil(mMax.x)+1; i++)
516 yWaveNz[i] = wvAmp * (noise(i/(mMax.x*.3)-(2e3+NoiseMove)/1500.) - .5) * (mMax.y/2.);
518 for (int i=0; i<ceil(mMax.y)+1; i++)
519 xWaveNz[i] = wvAmp * (noise(i/(mMax.y*.3)-(1e3+NoiseMove)/1500.) - .5) * (mMax.x/2.);
522 for (LXPoint p : model.points) { nPoint++;
526 if (sprk > 0) {P.y += sprk*randctr(50); P.x += sprk*randctr(50); P.z += sprk*randctr(50); }
527 if (wvAmp > 0) P.y += interpWv(p.x-modmin.x, yWaveNz);
528 if (wvAmp > 0) P.x += interpWv(p.y-modmin.y, xWaveNz);
529 if (pJog.b) P.add(xyzJog);
532 color cNew, cOld = colors[p.index];
533 { tP.set(P); cNew = CalcPoint(tP); }
534 if (pXsym.b) { tP.set(mMax.x-P.x,P.y,P.z); cNew = blendColor(cNew, CalcPoint(tP), ADD); }
535 if (pYsym.b) { tP.set(P.x,mMax.y-P.y,P.z); cNew = blendColor(cNew, CalcPoint(tP), ADD); }
536 if (pRsym.b) { tP.set(mMax.x-P.x,mMax.y-P.y,mMax.z-P.z); cNew = blendColor(cNew, CalcPoint(tP), ADD); }
537 if (pXdup.b) { tP.set((P.x+mMax.x*.5)%mMax.x,P.y,P.z); cNew = blendColor(cNew, CalcPoint(tP), ADD); }
538 if (pGrey.b) { cNew = lx.hsb(0, 0, lx.b(cNew)); }
539 colors[p.index] = cNew;
544 class CubeCurl extends SCPattern{
546 ArrayList<PVector> cubeorigin = new ArrayList<PVector>();
547 ArrayList<PVector> centerlist = new ArrayList<PVector>();
548 private SinLFO curl = new SinLFO(0, Cube.EDGE_HEIGHT, 5000 );
550 private SinLFO bg = new SinLFO(180, 220, 3000);
554 addModulator(curl).trigger();
555 addModulator(bg).trigger();
556 this.CH = Cube.EDGE_HEIGHT;
557 this.CW = Cube.EDGE_WIDTH;
558 this.diag = sqrt(CW*CW + CW*CW);
561 ArrayList<PVector> centerlistrelative = new ArrayList<PVector>();
562 for (int i = 0; i < model.cubes.size(); i++){
563 Cube a = model.cubes.get(i);
564 cubeorigin.add(new PVector(a.x, a.y, a.z));
565 centerlist.add(new PVector(a.cx, a.cy, a.cz) );
570 //there is definitely a better way of doing this!
571 PVector centerofcube(int i) {
572 Cube c = model.cubes.get(i);
573 PVector cubecenter = new PVector(c.cx, c.cy, c.cz);
579 void run(double deltaMs){
580 for (int i =0; i < model.cubes.size(); i++) {
581 Cube c = model.cubes.get(i);
586 // for (LXPoint p : c.points ){
587 // // colors[p.index]=color(0,0,0);
588 // //float dif = (p.y - c.y);
589 // //colors[p.index] = color( bg.getValuef() , 80 , dif < curl.getValuef() ? 80 : 0, ADD);
593 // else if (i%3 == 1) {
595 // for (LXPoint p: c.points){
596 // colors[p.index]=color(0,0,0);
597 // float dif = (p.y - c.y);
598 // // colors[p.index] =
599 // // color(bg.getValuef(),
600 // // map(curl.getValuef(), 0, Cube.EDGE_HEIGHT, 20, 100),
601 // // 100 - 10*abs(dif - curl.getValuef()), ADD );
604 // else if (i%3 == 2){
605 // centerlist[i].sub(cubeorigin(i);
606 for (LXPoint p: c.points) {
607 PVector pv = new PVector(p.x, p.y, p.z);
608 colors[p.index] =color( constrain(4* pv.dist(centerlist.get(i)), 0, 360) , 50, 100 );
609 // colors[p.index] =color(constrain(centerlist[i].x, 0, 360), constrain(centerlist[i].y, 0, 100), );
620 JGraphAdapterDemo graph1;
623 // class SpinningCube extends SCPattern{
624 // LXProjection spin1, spin2, spin3;
633 class PixelGraph implements EdgeFactory<dPixel, dVertex> {
635 dPixel p0; dPixel p1; dVertex v0;
637 public dVertex createEdge(dPixel p0, dPixel p1) {
646 class GraphTest extends SCPattern {
647 JGraphAdapterDemo graph1;
649 GraphTest( LX lx) {super(lx); JGraphAdapterDemo graph1 = new JGraphAdapterDemo();}
651 void run(double deltaMs){
655 class SpinningCube extends SCPattern{
657 LXProjection spin1, spin2, spin3;
658 SawLFO spinx, spiny, spinz;
659 SinLFO spinx1, spiny1, spinz1, cubesize;
660 BasicParameter xoff = new BasicParameter("xoff", 10, 0, 100);
661 BasicParameter toff = new BasicParameter("toff", 10,0,1000);
662 BasicParameter huev = new BasicParameter("hue", 200, 0, 360);
663 BasicParameter density = new BasicParameter("density", 0, 0, 1);
664 BasicParameter Vsize = new BasicParameter("size", model.xMax/3,0, model.xMax);
665 VirtualCube V1, V2, V3;
666 PVector P = new PVector();
672 VirtualCube(float x, float y, float z, float d) {
677 this.center=new PVector(x,y,z);
680 color getcolor(LXVector q) {
681 if ( q.x > this.x + d/2 || q.x < this.x - d/2 || q.y > this.y + d/2 || q.y < this.y - d/2 || q.z > this.z + d/2 || q.z < this.z - d/2 )
684 return lx.hsb(huev.getValuef()*noise(xoff.getValuef()*.001*noisetime ) , constrain(100*noise(xoff.getValuef()*.001*q.x*noisetime), 0, 100), max(100*(noise(xoff.getValuef()*.001*q.x*noisetime)-density.getValuef()), 0) );
687 void setcenter(float x, float y, float z) {this.x=x; this.y = y; this.z=z; }
688 void setsize(float din){ this.d=din ; }
692 SpinningCube(LX lx) {
698 addParameter(density);
700 V1 = new VirtualCube(model.cx, model.cy, model.cz, model.xMax/2);
701 spinx= new SawLFO(0, TWO_PI, 8000);
702 spin1 = new LXProjection(model);
707 void run(double deltaMs) {
709 noisetime+= deltaMs*.0001*toff.getValuef();
714 .rotate(spinx.getValuef(),0, 1, 0)
715 .translate(model.cx, model.cy, model.cz);
717 for (LXVector p: spin1) {
718 P.set(p.x, p.y, p.z);
720 colors[p.index] = V1.getcolor(p);
724 V1.setsize(Vsize.getValuef());
737 class HueTestHSB extends SCPattern{
738 BasicParameter HueT = new BasicParameter("Hue", .5);
739 BasicParameter SatT = new BasicParameter("Sat", .5);
740 BasicParameter BriT = new BasicParameter("Bright", .5);
748 void run(double deltaMs){
750 for (LXPoint p : model.points) {
752 c = blendColor(c, lx.hsb(360*HueT.getValuef(), 100*SatT.getValuef(), 100*BriT.getValuef()), ADD);
756 if (now % 1000 <= 20)
758 println("Hue: " + 360*HueT.getValuef() + "Sat: " + 100*SatT.getValuef() + "Bright: " + 100*BriT.getValuef());