From: Alexander Green Date: Fri, 15 Nov 2013 07:44:26 +0000 (-0800) Subject: Merge branch 'master' of https://github.com/sugarcubes/SugarCubes into alexgreen X-Git-Url: https://git.piment-noir.org/?p=SugarCubes.git;a=commitdiff_plain;h=09f7f5dff86f1b54a789e39b4f6ab24ed072c17d;hp=1c44211b1a15965afee7056a2f1d43a1306df61b Merge branch 'master' of https://github.com/sugarcubes/SugarCubes into alexgreen LX point stuff, etc don't know if it works yet Conflicts: AlexGreen.pde SugarCubes.pde --- diff --git a/AlexGreen.pde b/AlexGreen.pde index e3897cf..e507d20 100644 --- a/AlexGreen.pde +++ b/AlexGreen.pde @@ -6,15 +6,7 @@ class SineSphere extends SCPattern { private int pitch = 0; private int channel = 0; private int velocity = 0; - public final Projection sinespin; - public final Projection sinespin2; - - //to-do: how to sync all hues across sphery's via one basicparameter - //public BasicParameter huespread = new BasicParameter("HueSpread", 180, 360); - public BasicParameter rotationx = new BasicParameter("rotx", 0, 0, 1 ); - public BasicParameter rotationy = new BasicParameter("roty", 1, 0, 1); - public BasicParameter rotationz = new BasicParameter("rotz", 0, 0, 1); - + public final LXProjection sinespin; float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax)); Pick Sshape; public final PVector P = new PVector(); @@ -160,7 +152,7 @@ final Sphery[] spherys; SineSphere(GLucose glucose) { super(glucose); - sinespin = new Projection(model); + sinespin = new LXProjection(model); sinespin2 = new Projection(model); addParameter(huespread); addParameter(rotationx); @@ -206,11 +198,13 @@ final Sphery[] spherys; public void run( double deltaMs) { double t = lx.tempo.ramp(); double bpm = lx.tempo.bpm(); - spherys[0].run(deltaMs); - spherys[1].run(deltaMs); - spherys[2].run(deltaMs); - spherys[3].run(deltaMs); - + //spherys[0].run(deltaMs); + //spherys[1].run(deltaMs); + //spherys[2].run(deltaMs); + //spherys[3].run(deltaMs);] + sinespin.reset() + .center + .rotate(yrot.getValuef(), 0, 1, 0); switch (pitch) { @@ -221,7 +215,7 @@ final Sphery[] spherys; case 55: t = 2*t; bpm = 2*bpm; break; default: t= t; bpm = bpm; - +} } @@ -273,8 +267,6 @@ final Sphery[] spherys; } - - } color blendIfColor(color c1, color c2, int mode) { @@ -353,7 +345,7 @@ float cfloor = c.y; // if (i%3 == 0){ -// for (Point p : c.points ){ +// for (LXPoint p : c.points ){ // // colors[p.index]=color(0,0,0); // //float dif = (p.y - c.y); // //colors[p.index] = color( bg.getValuef() , 80 , dif < curl.getValuef() ? 80 : 0, ADD); @@ -362,7 +354,7 @@ float cfloor = c.y; // else if (i%3 == 1) { -// for (Point p: c.points){ +// for (LXPoint p: c.points){ // colors[p.index]=color(0,0,0); // float dif = (p.y - c.y); // // colors[p.index] = @@ -373,7 +365,7 @@ float cfloor = c.y; // } // else if (i%3 == 2){ // centerlist[i].sub(cubeorigin(i); - for (Point p: c.points) { + for (LXPoint p: c.points) { PVector pv = new PVector(p.x, p.y, p.z); colors[p.index] =color( constrain(4* pv.dist(centerlist.get(i)), 0, 360) , 50, 100 ); // colors[p.index] =color(constrain(centerlist[i].x, 0, 360), constrain(centerlist[i].y, 0, 100), ); @@ -401,7 +393,7 @@ HueTestHSB(GLucose glucose) { } void run(double deltaMs){ - for (Point p : model.points) { + for (LXPoint p : model.points) { color c = 0; c = blendColor(c, lx.hsb(360*HueT.getValuef(), 100*SatT.getValuef(), 100*BriT.getValuef()), ADD); colors[p.index]= c; diff --git a/AlexGreen.pde.orig b/AlexGreen.pde.orig index 13abdfe..9d657e9 100644 --- a/AlexGreen.pde.orig +++ b/AlexGreen.pde.orig @@ -1,9 +1,25 @@ class SineSphere extends SCPattern { +<<<<<<< HEAD private SawLFO yrot = new SawLFO(0, TWO_PI, 3000); private SawLFO yrot2 = new SawLFO(0, -TWO_PI, 8000); + public BasicParameter huespread = new BasicParameter("Hue", 0, 180); + public BasicParameter widthparameter= new BasicParameter("Width", .2); + private int pitch = 0; + private int channel = 0; + private int velocity = 0; public final Projection sinespin; public final Projection sinespin2; - private BasicParameter rotation = new BasicParameter("rotation", 0); + + //to-do: how to sync all hues across sphery's via one basicparameter + //public BasicParameter huespread = new BasicParameter("HueSpread", 180, 360); + public BasicParameter rotationx = new BasicParameter("rotx", 0, 0, 1 ); + public BasicParameter rotationy = new BasicParameter("roty", 1, 0, 1); + public BasicParameter rotationz = new BasicParameter("rotz", 0, 0, 1); + +======= + private SinLFO yrot = new SinLFO(0, TWO_PI, 2000); + public final LXProjection sinespin; +>>>>>>> b8bb27489db7dc687bf150576e9d9439f1fa17a6 float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax)); Pick Sshape; public final PVector P = new PVector(); @@ -17,14 +33,12 @@ class SineSphere extends SCPattern { public SinLFO ybounce; private SinLFO zbounce; float vibration_min, vibration_max, vperiod; - public BasicParameter widthparameter; - public BasicParameter huespread; + + //public BasicParameter huespread; public BasicParameter bouncerate; public BasicParameter bounceamp; -<<<<<<< HEAD -======= + public BasicParameter vibrationrate; public final PVector circlecenter = new PVector(); ->>>>>>> 4ad9f85959980d306800ad50636f4fd7c2a5d36b public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_min, float vibration_max, float vperiod) { @@ -36,40 +50,49 @@ class SineSphere extends SCPattern { this.vperiod = vperiod; //addParameter(bounceamp = new BasicParameter("Amp", .5)); //addParameter(bouncerate = new BasicParameter("Rate", .5)); //ybounce.modulateDurationBy(bouncerate); - addParameter(widthparameter = new BasicParameter("Width", .1)); - addParameter(huespread = new BasicParameter("Hue", .5, 10)); + //addParameter(vibrationrate = new BasicParameter("vibration", 1000, 10000)); + //addParameter(widthparameter = new BasicParameter("Width", .2)); + - addModulator( vx = new SinLFO(-4000, 10000, 100000)).trigger() ; + addModulator( vx = new SinLFO(500, 10000, 100000)).trigger() ; //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger(); - addModulator(ybounce= new SinLFO(model.yMax/3, 2*model.yMax/3, 240000./lx.tempo.bpm())).trigger(); //ybounce.modulateDurationBy + addModulator(ybounce= new SinLFO(model.yMax/3, 2*model.yMax/3, 240000./lx.tempo.bpm())).trigger(); //bounce.modulateDurationBy //addModulator(bounceamp); //ybounce.setMagnitude(bouncerate); - addModulator( vibration = new SinLFO(vibration_min , vibration_max, 240000./lx.tempo.bpm())).trigger(); //vibration.modulateDurationBy(vx); + addModulator( vibration = new SinLFO(vibration_min , vibration_max, 10000)).trigger(); //vibration.setPeriod(240000/lx.tempo.bpm()); } - public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float f2xcenter, float f2ycenter, float f2zcenter, - float vibration_min, float vibration_max, float vperiod) + + //for an ellipse +// public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float f2xcenter, float f2ycenter, float f2zcenter, +// float vibration_min, float vibration_max, float vperiod) - { - this.f1xcenter = f1xcenter; - this.f1ycenter = f1ycenter; - this.f1zcenter = f1zcenter; - this.f2xcenter = f2xcenter; - this.f2ycenter = f2ycenter; - this.f2zcenter = f2zcenter; - this.vibration_min = vibration_min; - this.vibration_max = vibration_max; - this.vperiod = vperiod; - //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger(); - addModulator(ybounce).trigger(); - addModulator( vibration = new SinLFO(vibration_min , vibration_max, lx.tempo.rampf())).trigger(); //vibration.modulateDurationBy(vx); - addParameter(widthparameter = new BasicParameter("Width", .1)); - addParameter(huespread = new BasicParameter("Hue", .2)); +// { +// this.f1xcenter = f1xcenter; +// this.f1ycenter = f1ycenter; +// this.f1zcenter = f1zcenter; +// this.f2xcenter = f2xcenter; +// this.f2ycenter = f2ycenter; +// this.f2zcenter = f2zcenter; +// this.vibration_min = vibration_min; +// this.vibration_max = vibration_max; +// this.vperiod = vperiod; +// //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger(); +// addModulator(ybounce).trigger(); +// addModulator( vibration = new SinLFO(vibration_min , vibration_max, lx.tempo.rampf())).trigger(); //vibration.modulateDurationBy(vx); +// addParameter(widthparameter = new BasicParameter("Width", .1)); +// //addParameter(huespread = new BasicParameter("bonk", .2)); -} +// } + +void setVibrationPeriod(double period){ +// to-do: make this conditional upon time signature +vibration.setPeriod(period); + +} float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, float f1z) @@ -80,16 +103,16 @@ float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, f float quadrant(PVector q) { float qtheta = atan2( (q.x-f1xcenter) , (q.z - f1zcenter) ); - //println( "qtheta " + qtheta); - return map(qtheta, -PI/2, PI/2, 140, 240); + + return map(qtheta, -PI/2, PI/2, 160-huespread.getValuef(), 240 +huespread.getValuef()); //if (q.x > f1xcenter ) {return 140 ;} //else {return 250;} } color spheryvalue (PVector p, float f1xcenter, float f1ycenter, float f1zcenter) { circlecenter.set(f1xcenter, f1ycenter, f1zcenter); - // circlecenter = new PVector(f1xcenter, f1ycenter, f1zcenter); + //switch(sShpape.cur() ) {} float b = max(0, 100 - 100*widthparameter.getValuef()*abs(p.dist(circlecenter) @@ -100,7 +123,7 @@ float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, f } return lx.hsb( - constrain(huespread.getValuef()*5*quadrant(p), 0, 360), + constrain(quadrant(p), 0, 360), 80, b ); @@ -123,17 +146,39 @@ void run(double deltaMs) { } +// public boolean gridPressed(int row, int co){ +// midiengine.grid.setState(); + +// return true; + +// } + +public boolean noteOn(Note note) { +pitch= note.getPitch(); +velocity=note.getVelocity(); +channel=note.getChannel(); +return true; +} final Sphery[] spherys; SineSphere(GLucose glucose) { super(glucose); +<<<<<<< HEAD sinespin = new Projection(model); sinespin2 = new Projection(model); + addParameter(huespread); + addParameter(rotationx); + addParameter(rotationy); + addParameter(rotationz); +======= + sinespin = new LXProjection(model); +>>>>>>> b8bb27489db7dc687bf150576e9d9439f1fa17a6 addModulator(yrot).trigger(); addModulator(yrot2).trigger(); - addParameter(rotation); + + //addParameter(huespread); //Sshape = addPick("Shape", , 1); spherys = new Sphery[] { new Sphery(model.xMax/4, model.yMax/2, model.zMax/2, modelrad/16, modelrad/8, 3000), @@ -167,14 +212,53 @@ final Sphery[] spherys; // } // } +<<<<<<< HEAD public void run( double deltaMs) { - float t = lx.tempo.rampf(); - float bpm = lx.tempo.bpmf(); + double t = lx.tempo.ramp(); + double bpm = lx.tempo.bpm(); spherys[0].run(deltaMs); spherys[1].run(deltaMs); spherys[2].run(deltaMs); spherys[3].run(deltaMs); + + switch (pitch) + { + case 53: t = .5*t; bpm = .5*bpm; break; +======= + void run( double deltaMs) { + float t = lx.tempo.rampf(); + float bpm = lx.tempo.bpmf(); + //spherys[1].run(deltaMs); + //spherys[2].run(deltaMs); + //spherys[3].run(deltaMs);] + sinespin.reset() + + // Translate so the center of the car is the origin, offset by yPos + .center() +>>>>>>> b8bb27489db7dc687bf150576e9d9439f1fa17a6 + + case 54: t = t; bpm = bpm; break; + + case 55: t = 2*t; bpm = 2*bpm; break; + + default: t= t; bpm = bpm; + +<<<<<<< HEAD +======= + for (LXPoint p : model.points){ + color c = 0; + c = blendColor(c, spherys[1].spheryvalue(p.x, p.y, p.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD); + c = blendColor(c, spherys[0].spheryvalue(p.x, p.y, p.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD); + c = blendColor(c, spherys[2].spheryvalue(p.x, p.y, p.z, model.xMax/2, model.yMax/2, model.zMax/2),ADD); +>>>>>>> b8bb27489db7dc687bf150576e9d9439f1fa17a6 + + } + + for ( Sphery s: spherys){ + s.setVibrationPeriod(480000/bpm); + s.vibration.setBasis(t); + } sinespin.reset(model) @@ -182,7 +266,7 @@ final Sphery[] spherys; .translateCenter(model, 0, 0, 0) // .scale(1.3,1.3,1.3) // Rotate around the origin (now the center of the car) about an y-vector - .rotate(yrot.getValuef(), 0, 1 , 0) + .rotate(yrot.getValuef(), rotationx.getValuef(), rotationy.getValuef() , rotationz.getValuef()) .translate(model.cx, model.cy, model.cz); @@ -299,7 +383,7 @@ float cfloor = c.y; // if (i%3 == 0){ -// for (Point p : c.points ){ +// for (LXPoint p : c.points ){ // // colors[p.index]=color(0,0,0); // //float dif = (p.y - c.y); // //colors[p.index] = color( bg.getValuef() , 80 , dif < curl.getValuef() ? 80 : 0, ADD); @@ -308,7 +392,7 @@ float cfloor = c.y; // else if (i%3 == 1) { -// for (Point p: c.points){ +// for (LXPoint p: c.points){ // colors[p.index]=color(0,0,0); // float dif = (p.y - c.y); // // colors[p.index] = @@ -319,7 +403,7 @@ float cfloor = c.y; // } // else if (i%3 == 2){ // centerlist[i].sub(cubeorigin(i); - for (Point p: c.points) { + for (LXPoint p: c.points) { PVector pv = new PVector(p.x, p.y, p.z); colors[p.index] =color( constrain(4* pv.dist(centerlist.get(i)), 0, 360) , 50, 100 ); // colors[p.index] =color(constrain(centerlist[i].x, 0, 360), constrain(centerlist[i].y, 0, 100), ); @@ -347,7 +431,7 @@ HueTestHSB(GLucose glucose) { } void run(double deltaMs){ - for (Point p : model.points) { + for (LXPoint p : model.points) { color c = 0; c = blendColor(c, lx.hsb(360*HueT.getValuef(), 100*SatT.getValuef(), 100*BriT.getValuef()), ADD); colors[p.index]= c; diff --git a/ArjunBanker.pde b/ArjunBanker.pde index c8fe1a6..4709bdc 100644 --- a/ArjunBanker.pde +++ b/ArjunBanker.pde @@ -15,7 +15,7 @@ class TelevisionStatic extends SCPattern { void run(double deltaMs) { boolean d = direction.getValuef() > 5.0; - for (Point p : model.points) { + for (LXPoint p : model.points) { colors[p.index] = lx.hsb((lx.getBaseHuef() + random(hueParameter.getValuef() * 360))%360, random(saturationParameter.getValuef() * 100), random(brightParameter.getValuef() * 100)); } } @@ -38,7 +38,7 @@ class AbstractPainting extends SCPattern { } void run(double deltaMs) { - for (Point p : model.points) { + for (LXPoint p : model.points) { color c = img.get((int)((p.x / model.xMax) * img.width), img.height - (int)((p.y / model.yMax) * img.height)); colors[p.index] = lx.hsb(hue(c) + colorMod.getValuef()%360, saturation(c), brightness(c) - ((p.z - brightMod.getValuef())/p.z)); } @@ -55,7 +55,7 @@ class Spirality extends SCPattern { Spirality(GLucose glucose) { super(glucose); addParameter(r); - for (Point p : model.points) { + for (LXPoint p : model.points) { colors[p.index] = lx.hsb(0, 0, 0); } } @@ -65,7 +65,7 @@ class Spirality extends SCPattern { rad += deltaMs * .025 * direction; float x = model.xMax / 2 + cos(angle) * rad; float y = model.yMax / 2 + sin(angle) * rad; - for (Point p : model.points) { + for (LXPoint p : model.points) { float b = dist(x,y,p.x,p.y); if (b < 90) { colors[p.index] = blendColor( diff --git a/BenMorrow.pde b/BenMorrow.pde index 7024148..51945a8 100644 --- a/BenMorrow.pde +++ b/BenMorrow.pde @@ -59,7 +59,7 @@ class TowerParams extends SCPattern for(int i=0; i> 12; diff --git a/DanKaminsky.pde b/DanKaminsky.pde index 4021d07..8e236a2 100644 --- a/DanKaminsky.pde +++ b/DanKaminsky.pde @@ -3,15 +3,15 @@ class GenericController { public void RotateKnob(int type, int num, float val){ LXParameter p = null; if(type==0) { - p = glucose.patternKnobs.get(num); + p = glucose.getPattern().getParameters().get(num); if(p!=null) { p.setValue(val); } } if(type==1) { - p = glucose.transitionKnobs.get(num); + p = glucose.getSelectedTransition().getParameters().get(num); if(p!=null) { p.setValue(val); } } if(type==2) { - p = glucose.effectKnobs.get(num); + p = glucose.getSelectedEffect().getParameters().get(num); if(p!=null) { p.setValue(val); } } } @@ -38,9 +38,9 @@ OscP5 listener; // } // if(cc.getCC()==1){ // for(int i=0; i<16; i++){ -// if(noteState[i] && i<8) { LXParameter p = glucose.patternKnobs.get(i); p.setValue(cc.getValue()/127.0); } -// else if(noteState[i] && i<12) { LXParameter p = glucose.transitionKnobs.get(i-8); p.setValue(cc.getValue()/127.0); } -// else if(noteState[i] && i<16) { LXParameter p = glucose.effectKnobs.get(i-12); p.setValue(cc.getValue()/127.0); } +// if(noteState[i] && i<8) { LXParameter p = glucose.getPattern().getParameters().get(i); p.setValue(cc.getValue()/127.0); } +// else if(noteState[i] && i<12) { LXParameter p = glucose.getSelectedTransition().getParameters().get(i-8); p.setValue(cc.getValue()/127.0); } +// else if(noteState[i] && i<16) { LXParameter p = glucose.getSelectedEffect().getParameters().get(i-12); p.setValue(cc.getValue()/127.0); } // } // } //} @@ -174,10 +174,10 @@ class OSC_Balls extends OSCPattern { } void run(double deltaMs){ - for(Point p: model.points){ colors[p.index]=0; } + for(LXPoint p: model.points){ colors[p.index]=0; } for(int i=1; i x-4 && p.y < y+4 && p.y > y-4) { colors[p.index] = #FF0000; } @@ -207,7 +207,7 @@ import processing.serial.*; pret.pixels = ss.getScreenShotJNI2(x, y, w, h); //for(int i=0; i= b && a <= c; } float interp (float a, float b, float c) { return (1-a)*b + a*c; } float randctr (float a) { return random(a) - a*.5; } float min (float a, float b, float c, float d) { return min(min(a,b),min(c,d)); } -float pointDist(Point p1, Point p2) { return dist(p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); } -float xyDist (Point p1, Point p2) { return dist(p1.x,p1.y,p2.x,p2.y); } +float pointDist(LXPoint p1, LXPoint p2) { return dist(p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); } +float xyDist (LXPoint p1, LXPoint p2) { return dist(p1.x,p1.y,p2.x,p2.y); } float distToSeg(float x, float y, float x1, float y1, float x2, float y2) { float A = x - x1, B = y - y1, C = x2 - x1, D = y2 - y1; float dot = A * C + B * D, len_sq = C * C + D * D; @@ -79,7 +79,7 @@ public class DPat extends SCPattern float interpWv(float i, float[] vals) { return interp(i-floor(i), vals[floor(i)], vals[ceil(i)]); } void setNorm (PVector vec) { vec.set(vec.x/mMax.x, vec.y/mMax.y, vec.z/mMax.z); } void setRand (PVector vec) { vec.set(random(mMax.x), random(mMax.y), random(mMax.z)); } - void setVec (PVector vec, Point p) { vec.set(p.x, p.y, p.z); } + void setVec (PVector vec, LXPoint p) { vec.set(p.x, p.y, p.z); } 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)); } void StartRun(double deltaMs) { } float val (BasicParameter p) { return p.getValuef(); } @@ -211,7 +211,7 @@ public class DPat extends SCPattern xWaveNz[i] = wvAmp * (noise(i/(mMax.y*.3)-(1e3+NoiseMove)/1500.) - .5) * (mMax.x/2.); } - for (Point p : model.points) { nPoint++; + for (LXPoint p : model.points) { nPoint++; setVec(P,p); P.sub(modmin); P.sub(pTrans); @@ -248,8 +248,8 @@ class dVertex { int dir, ci; // dir -- 1 or -1. // ci -- color index - dVertex(Strip _s, Point _p) { s = _s; ci = _p.index; } - Point getPoint(int i) { return s.points.get(dir>0 ? i : 15-i); } + dVertex(Strip _s, LXPoint _p) { s = _s; ci = _p.index; } + LXPoint getPoint(int i) { return s.points.get(dir>0 ? i : 15-i); } void setOpp(dVertex _opp) { opp = _opp; dir = (ci < opp.ci ? 1 : -1); } } //---------------------------------------------------------------------------------------------------------------------------------- @@ -262,7 +262,7 @@ class dLattice { if (v0.t3 == null) { v0.t3=t; return; } } float dist2 (Strip s1, int pos1, Strip s2, int pos2) { return pointDist(s1.points.get(pos1), s2.points.get(pos2)); } - float pd2 (Point p1, float x, float y, float z) { return dist(p1.x,p1.y,p1.z,x,y,z); } + float pd2 (LXPoint p1, float x, float y, float z) { return dist(p1.x,p1.y,p1.z,x,y,z); } boolean sameSame (Strip s1, Strip s2) { return max(dist2(s1, 0, s2, 0), dist2(s1,15, s2,15)) < 5 ; } // same strut, same direction boolean sameOpp (Strip s1, Strip s2) { return max(dist2(s1, 0, s2,15), dist2(s1,15, s2,0 )) < 5 ; } // same strut, opp direction boolean sameBar (Strip s1, Strip s2) { return sameSame(s1,s2) || sameOpp(s1,s2); } // 2 strips on same strut diff --git a/GranimPattern.pde b/GranimPattern.pde index 450c17e..da4c78f 100644 --- a/GranimPattern.pde +++ b/GranimPattern.pde @@ -109,7 +109,7 @@ class GranimPattern extends SCPattern { ((Granim) g).update(); } - List drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1)); + List drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1)); //println("drawlistsize "+drawList.size()); gbuffer = g.graphicBuffer.toArray(new Integer[0]); diff --git a/JR.pde b/JR.pde index 6692baa..ba9498b 100644 --- a/JR.pde +++ b/JR.pde @@ -6,7 +6,7 @@ class Gimbal extends SCPattern { private final int MAXIMUM_BEATS_PER_REVOLUTION = 100; private boolean first_run = true; - private final Projection projection; + private final LXProjection projection; private final BasicParameter beatsPerRevolutionParam = new BasicParameter("SLOW", 20./MAXIMUM_BEATS_PER_REVOLUTION); private final BasicParameter hueDeltaParam = new BasicParameter("HUED", 60./360); private final BasicParameter fadeFromCoreParam = new BasicParameter("FADE", 1); @@ -21,7 +21,7 @@ class Gimbal extends SCPattern { Gimbal(GLucose glucose) { super(glucose); - projection = new Projection(model); + projection = new LXProjection(model); addParameter(beatsPerRevolutionParam); addParameter(hueDeltaParam); addParameter(fadeFromCoreParam); @@ -75,11 +75,11 @@ class Gimbal extends SCPattern { Ring ring2 = new Ring((hue + hue_delta * 1) % 360, radius2, girth); Ring ring3 = new Ring((hue + hue_delta * 2) % 360, radius3, girth); - projection.reset(model) + projection.reset() // Translate so the center of the car is the origin - .translateCenter(model, 0, 0, 0); + .center(); - for (Coord c : projection) { + for (LXVector c : projection) { //if (first_run) println(c.x + "," + c.y + "," + c.z); rotate3d(c, a, 0, 0); @@ -109,7 +109,7 @@ class Gimbal extends SCPattern { this.girth = girth; } - public color colorFor(Coord c) { + public color colorFor(LXVector c) { float theta = atan2(c.y, c.x); float nearest_circle_x = cos(theta) * radius; float nearest_circle_y = sin(theta) * radius; @@ -135,7 +135,7 @@ class Gimbal extends SCPattern { class Zebra extends SCPattern { - private final Projection projection; + private final LXProjection projection; SinLFO angleM = new SinLFO(0, PI * 2, 30000); /* @@ -146,12 +146,12 @@ class Zebra extends SCPattern { Zebra(GLucose glucose) { super(glucose); - projection = new Projection(model); + projection = new LXProjection(model); addModulator(angleM).trigger(); } - color colorFor(Coord c) { + color colorFor(LXVector c) { float hue = lx.getBaseHuef(); @@ -191,11 +191,11 @@ class Zebra extends SCPattern { float b = (millis() / 1200.f) % (2 * PI); float g = (millis() / 1600.f) % (2 * PI); - projection.reset(model) + projection.reset() // Translate so the center of the car is the origin - .translateCenter(model, 0, 0, 0); + .center(); - for (Coord c : projection) { + for (LXVector c : projection) { // rotate3d(c, a, b, g); colors[c.index] = colorFor(c); } @@ -215,7 +215,7 @@ class Zebra extends SCPattern { } -void rotate3d(Coord c, float a /* roll */, float b /* pitch */, float g /* yaw */) { +void rotate3d(LXVector c, float a /* roll */, float b /* pitch */, float g /* yaw */) { float cosa = cos(a); float cosb = cos(b); float cosg = cos(g); diff --git a/JackStahl.pde b/JackStahl.pde index 081ea40..862558c 100644 --- a/JackStahl.pde +++ b/JackStahl.pde @@ -9,7 +9,7 @@ class Swim extends SCPattern { // Projection stuff - private final Projection projection; + private final LXProjection projection; SawLFO rotation = new SawLFO(0, TWO_PI, 19000); SinLFO yPos = new SinLFO(-25, 25, 12323); final BasicParameter xAngle = new BasicParameter("XANG", 0.9); @@ -20,7 +20,7 @@ class Swim extends SCPattern { public Swim(GLucose glucose) { super(glucose); - projection = new Projection(model); + projection = new LXProjection(model); addParameter(xAngle); addParameter(yAngle); @@ -46,14 +46,14 @@ class Swim extends SCPattern { float denominator = max(xAngle.getValuef() + yAngle.getValuef() + zAngle.getValuef(), 1); - projection.reset(model) + projection.reset() // Swim around the world .rotate(rotation.getValuef(), xAngle.getValuef() / denominator, yAngle.getValuef() / denominator, zAngle.getValuef() / denominator) - .translateCenter(model, 0, 50 + yPos.getValuef(), 0); + .translateCenter(0, 50 + yPos.getValuef(), 0); float model_height = model.yMax - model.yMin; float model_width = model.xMax - model.xMin; - for (Coord p : projection) { + for (LXVector p : projection) { float x_percentage = (p.x - model.xMin)/model_width; // Multiply by 1.4 to shrink the size of the sin wave to be less than the height of the cubes. @@ -83,7 +83,7 @@ class Balance extends SCPattern { // Projection stuff - private final Projection projection; + private final LXProjection projection; SinLFO sphere1Z = new SinLFO(0, 0, 15323); SinLFO sphere2Z = new SinLFO(0, 0, 8323); @@ -102,7 +102,7 @@ class Balance extends SCPattern { public Balance(GLucose glucose) { super(glucose); - projection = new Projection(model); + projection = new LXProjection(model); addParameter(hueScale); addParameter(phaseParam); @@ -157,12 +157,12 @@ class Balance extends SCPattern { float phase = phaseLFO.getValuef(); float crazy_factor = crazyParam.getValuef() / 0.2; - projection.reset(model) + projection.reset() .rotate(rotationZ.getValuef() * crazy_factor, 0, 1, 0) .rotate(rotationX.getValuef() * crazy_factor, 0, 0, 1) .rotate(rotationY.getValuef() * crazy_factor, 0, 1, 0); - for (Coord p : projection) { + for (LXVector p : projection) { float x_percentage = (p.x - model.xMin)/modelWidth; float y_in_range = heightMod.getValuef() * (2*p.y - model.yMax - model.yMin) / modelHeight; diff --git a/MarkSlee.pde b/MarkSlee.pde index d3237e1..62a474d 100644 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@ -45,7 +45,7 @@ class Cathedrals extends SCPattern { float sf = 100. / (70 - 69.9*sat.getValuef()); - for (Point p : model.points) { + for (LXPoint p : model.points) { float d = MAX_FLOAT; if (p.y > model.cy) { arm = tarm; @@ -109,7 +109,7 @@ class MidiMusic extends SCPattern { return; } float posf = position.getValuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { colors[p.index] = blendColor(colors[p.index], lx.hsb( (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360, 100, @@ -151,7 +151,7 @@ class MidiMusic extends SCPattern { return; } float yVal = yPos.getValuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { float falloff = 6 - 5*lightSize.getValuef(); float b = max(0, bVal - falloff*dist(p.x, p.y, xPos, yVal)); if (b > 0) { @@ -252,7 +252,7 @@ class MidiMusic extends SCPattern { float maxBright = sparkleBright * (1 - sparkle.getValuef()); for (Strip s : model.strips) { int i = 0; - for (Point p : s.points) { + for (LXPoint p : s.points) { int wavi = (int) constrain(p.x / model.xMax * wval.length, 0, wval.length-1); float wavb = max(0, wave.getValuef()*100. - 8.*abs(p.y - wval[wavi])); colors[p.index] = lx.hsb( @@ -366,7 +366,7 @@ class Pulley extends SCPattern { fPos = .2 + 4 * (.2 - fPos); } float falloff = 100. / (3 + sz.getValuef() * 36 + fPos * beatAmount.getValuef()*48); - for (Point p : model.points) { + for (LXPoint p : model.points) { int gi = (int) constrain((p.x - model.xMin) * NUM_DIVISIONS / (model.xMax - model.xMin), 0, NUM_DIVISIONS-1); colors[p.index] = lx.hsb( (lx.getBaseHuef() + abs(p.x - model.cx)*.8 + p.y*.4) % 360, @@ -438,7 +438,7 @@ class ViolinWave extends SCPattern { } float pFalloff = (30 - 27*pSize.getValuef()); - for (Point p : model.points) { + for (LXPoint p : model.points) { float b = 100 - pFalloff * (abs(p.x - x.getValuef()) + abs(p.y - y.getValuef())); if (b > 0) { colors[p.index] = blendColor(colors[p.index], lx.hsb( @@ -489,7 +489,7 @@ class ViolinWave extends SCPattern { float rng = (78 - 64 * range.getValuef()) / (model.yMax - model.cy); float val = max(2, dbValue.getValuef()); - for (Point p : model.points) { + for (LXPoint p : model.points) { int ci = (int) lerp(0, centers.length-1, (p.x - model.xMin) / (model.xMax - model.xMin)); float rFactor = 1.0 - 0.9 * abs(p.x - model.cx) / (model.xMax - model.cx); colors[p.index] = lx.hsb( @@ -545,7 +545,7 @@ class BouncyBalls extends SCPattern { float xv = xPos.getValuef(); float yv = yPos.getValuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { float d = sqrt((p.x-xv)*(p.x-xv) + (p.y-yv)*(p.y-yv) + .1*(p.z-zPos)*(p.z-zPos)); float b = constrain(130 - falloff*d, 0, 100); if (b > 0) { @@ -630,7 +630,7 @@ class SpaceTime extends SCPattern { int s = 0; for (Strip strip : model.strips) { int i = 0; - for (Point p : strip.points) { + for (LXPoint p : strip.points) { colors[p.index] = lx.hsb( (lx.getBaseHuef() + 360 - p.x*.2 + p.y * .3) % 360, constrain(.4 * min(abs(s - sVal1), abs(s - sVal2)), 20, 100), @@ -648,9 +648,9 @@ class Swarm extends SCPattern { SawLFO offset = new SawLFO(0, 1, 1000); SinLFO rate = new SinLFO(350, 1200, 63000); SinLFO falloff = new SinLFO(15, 50, 17000); - SinLFO fX = new SinLFO(0, model.xMax, 19000); - SinLFO fY = new SinLFO(0, model.yMax, 11000); - SinLFO hOffX = new SinLFO(0, model.xMax, 13000); + SinLFO fX = new SinLFO(model.xMin, model.xMax, 19000); + SinLFO fY = new SinLFO(model.yMin, model.yMax, 11000); + SinLFO hOffX = new SinLFO(model.xMin, model.xMax, 13000); public Swarm(GLucose glucose) { super(glucose); @@ -677,9 +677,9 @@ class Swarm extends SCPattern { void run(double deltaMs) { float s = 0; - for (Strip strip : model.strips ) { + for (Strip strip : model.strips) { int i = 0; - for (Point p : strip.points) { + for (LXPoint p : strip.points) { float fV = max(-1, 1 - dist(p.x/2., p.y, fX.getValuef()/2., fY.getValuef()) / 64.); colors[p.index] = lx.hsb( (lx.getBaseHuef() + 0.3 * abs(p.x - hOffX.getValuef())) % 360, @@ -707,7 +707,7 @@ class SwipeTransition extends SCTransition { void computeBlend(int[] c1, int[] c2, double progress) { float bleedf = 10 + bleed.getValuef() * 200.; float xPos = (float) (-bleedf + progress * (model.xMax + bleedf)); - for (Point p : model.points) { + for (LXPoint p : model.points) { float d = (p.x - xPos) / bleedf; if (d < 0) { colors[p.index] = c2[p.index]; @@ -830,7 +830,7 @@ class BassPod extends SCPattern { float satBase = bassLevel*480*clr.getValuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { int avgIndex = (int) constrain(1 + abs(p.x-model.cx)/(model.cx)*(eq.numBands-5), 0, eq.numBands-5); float value = 0; for (int i = avgIndex; i < avgIndex + 5; ++i) { @@ -881,7 +881,7 @@ class CubeEQ extends SCPattern { float edgeConst = 2 + 30*edge.getValuef(); float clrConst = 1.1 + clr.getValuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { float avgIndex = constrain(2 + p.x / model.xMax * (eq.numBands-4), 0, eq.numBands-4); int avgFloor = (int) avgIndex; @@ -936,7 +936,7 @@ class BoomEffect extends SCEffect { float falloffv = falloffv(); float satv = sat.getValuef() * 100; float huev = lx.getBaseHuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { colors[p.index] = blendColor( colors[p.index], lx.hsb(huev, satv, constrain(brightv - falloffv*abs(boom.getValuef() - dist(p.x, 2*p.y, 3*p.z, model.xMax/2, model.yMax, model.zMax*1.5)), 0, 100)), @@ -1112,7 +1112,7 @@ class CrossSections extends SCPattern { float ywv = 100. / (10 + 40*yw.getValuef()); float zwv = 100. / (10 + 40*zw.getValuef()); - for (Point p : model.points) { + for (LXPoint p : model.points) { color c = 0; c = blendColor(c, lx.hsb( (lx.getBaseHuef() + p.x/10 + p.y/3) % 360, @@ -1159,7 +1159,7 @@ class Blinders extends SCPattern { for (Strip strip : model.strips) { int i = 0; float mv = m[si % m.length].getValuef(); - for (Point p : strip.points) { + for (LXPoint p : strip.points) { colors[p.index] = lx.hsb( (hv + p.z + p.y*hs.getValuef()) % 360, min(100, abs(p.x - s.getValuef())/2.), @@ -1195,7 +1195,7 @@ class Psychedelia extends SCPattern { float mv = m.getValuef(); int i = 0; for (Strip strip : model.strips) { - for (Point p : strip.points) { + for (LXPoint p : strip.points) { colors[p.index] = lx.hsb( (huev + i*constrain(cv, 0, 2) + p.z/2. + p.x/4.) % 360, min(100, abs(p.y-sv)), @@ -1257,7 +1257,7 @@ class AskewPlanes extends SCPattern { planes[1].run(deltaMs); planes[2].run(deltaMs); - for (Point p : model.points) { + for (LXPoint p : model.points) { float d = MAX_FLOAT; for (Plane plane : planes) { if (plane.denom != 0) { @@ -1295,7 +1295,7 @@ class ShiftingPlane extends SCPattern { float cv = c.getValuef(); float dv = d.getValuef(); float denom = sqrt(av*av + bv*bv + cv*cv); - for (Point p : model.points) { + for (LXPoint p : model.points) { float d = abs(av*(p.x-model.cx) + bv*(p.y-model.cy) + cv*(p.z-model.cz) + dv) / denom; colors[p.index] = lx.hsb( (hv + abs(p.x-model.cx)*.6 + abs(p.y-model.cy)*.9 + abs(p.z - model.cz)) % 360, @@ -1362,7 +1362,7 @@ class Traktor extends SCPattern { bass[index] = rawBass * rawBass * rawBass * rawBass; treble[index] = rawTreble * rawTreble; - for (Point p : model.points) { + for (LXPoint p : model.points) { int i = (int) constrain((model.xMax - p.x) / model.xMax * FRAME_WIDTH, 0, FRAME_WIDTH-1); int pos = (index + FRAME_WIDTH - i) % FRAME_WIDTH; @@ -1521,3 +1521,4 @@ class BlurEffect extends SCEffect { } } + diff --git a/ShaheenGandhi.pde b/ShaheenGandhi.pde index d718e36..83b97cf 100644 --- a/ShaheenGandhi.pde +++ b/ShaheenGandhi.pde @@ -252,7 +252,7 @@ class HelixPattern extends SCPattern { h2.step(deltaMs); calculateSpokes(); - for (Point p : model.points) { + for (LXPoint p : model.points) { PVector pt = new PVector(p.x,p.y,p.z); color h1c = h1.colorOfPoint(pt); color h2c = h2.colorOfPoint(pt); diff --git a/SugarCubes.pde b/SugarCubes.pde index 6318339..d1052bd 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -26,8 +26,6 @@ LXPattern[] patterns(GLucose glucose) { return new LXPattern[] { - new SineSphere(glucose), - new CubeCurl(glucose), // Slee new Cathedrals(glucose), new MidiMusic(glucose), @@ -104,7 +102,6 @@ LXPattern[] patterns(GLucose glucose) { new TestBassMapping(glucose), new TestFloorMapping(glucose), new TestSpeakerMapping(glucose), - new TestPerformancePattern(glucose), // new TestHuePattern(glucose), // new TestXPattern(glucose), // new TestYPattern(glucose), diff --git a/SugarCubes.pde.orig b/SugarCubes.pde.orig new file mode 100644 index 0000000..e989980 --- /dev/null +++ b/SugarCubes.pde.orig @@ -0,0 +1,148 @@ +/** + * +-+-+-+-+-+ +-+-+-+-+-+ + * / /| |\ \ + * / / + + \ \ + * +-+-+-+-+-+ | +-+-+-+-+ | +-+-+-+-+-+ + * | | + / \ + | | + * + THE + / / \ \ + CUBES + + * | |/ +-+-+-+-+-+-+-+ \| | + * +-+-+-+-+-+ | | +-+-+-+-+-+ + * + + + * | SUGAR | + * + + + * | | + * +-+-+-+-+-+-+-+ + * + * Welcome to the Sugar Cubes! This Processing sketch is a fun place to build + * animations, effects, and interactions for the platform. Most of the icky + * code guts are embedded in the GLucose library extension. If you're an + * artist, you shouldn't need to worry about any of that. + * + * Below, you will find definitions of the Patterns, Effects, and Interactions. + * If you're an artist, create a new tab in the Processing environment with + * your name. Implement your classes there, and add them to the list below. + */ + +LXPattern[] patterns(GLucose glucose) { + return new LXPattern[] { + +<<<<<<< HEAD + new SineSphere(glucose), + new CubeCurl(glucose), +======= +>>>>>>> b8bb27489db7dc687bf150576e9d9439f1fa17a6 + // Slee + new Cathedrals(glucose), + new MidiMusic(glucose), + new Pulley(glucose), + new Swarm(glucose), + new ViolinWave(glucose), + new BouncyBalls(glucose), + new SpaceTime(glucose), + new ShiftingPlane(glucose), + new AskewPlanes(glucose), + new Blinders(glucose), + new CrossSections(glucose), + new Psychedelia(glucose), + + new Traktor(glucose).setEligible(false), + new BassPod(glucose).setEligible(false), + new CubeEQ(glucose).setEligible(false), + new PianoKeyPattern(glucose).setEligible(false), + + // DanH + new Noise(glucose), + new Play (glucose), + new Pong (glucose), + new Worms(glucose), + + // Alex G + + + // Shaheen + new HelixPattern(glucose).setEligible(false), + + // Toby + new GlitchPlasma(glucose), + new FireEffect(glucose).setEligible(false), + new StripBounce(glucose), + new SoundRain(glucose).setEligible(false), + new SoundSpikes(glucose).setEligible(false), + new FaceSync(glucose), + + // Jack + new Swim(glucose), + new Balance(glucose), + + // Tim + new TimPlanes(glucose), + new TimPinwheels(glucose), + new TimRaindrops(glucose), + new TimCubes(glucose), + // new TimTrace(glucose), + new TimSpheres(glucose), + + // Ben + // new Sandbox(glucose), + new TowerParams(glucose), + new DriveableCrossSections(glucose), + new GranimTestPattern2(glucose), + + //JR + new Gimbal(glucose), + + // Sam + new JazzRainbow(glucose), + + // Arjun + new TelevisionStatic(glucose), + new AbstractPainting(glucose), + new Spirality(glucose), + + // Basic test patterns for reference, not art + new TestCubePattern(glucose), + new TestTowerPattern(glucose), + new TestProjectionPattern(glucose), + new TestStripPattern(glucose), + new TestBassMapping(glucose), + new TestFloorMapping(glucose), + new TestSpeakerMapping(glucose), + // new TestHuePattern(glucose), + // new TestXPattern(glucose), + // new TestYPattern(glucose), + // new TestZPattern(glucose), + + }; +} + +LXTransition[] transitions(GLucose glucose) { + return new LXTransition[] { + new DissolveTransition(lx), + new AddTransition(glucose), + new MultiplyTransition(glucose), + new OverlayTransition(glucose), + new DodgeTransition(glucose), + new SwipeTransition(glucose), + new FadeTransition(lx), +// new SubtractTransition(glucose), // similar to multiply - dh +// new BurnTransition(glucose), // similar to multiply - dh +// new ScreenTransition(glucose), // same as add -dh +// new SoftLightTransition(glucose), // same as overlay -dh + }; +} + +// Handles to globally triggerable effects +class Effects { + FlashEffect flash = new FlashEffect(lx); + BoomEffect boom = new BoomEffect(glucose); + BlurEffect blur = new BlurEffect(glucose); + QuantizeEffect quantize = new QuantizeEffect(glucose); + ColorFuckerEffect colorFucker = new ColorFuckerEffect(glucose); + + Effects() { + blur.enable(); + quantize.enable(); + colorFucker.enable(); + } +} + diff --git a/TestPatterns.pde b/TestPatterns.pde index 1c2ea70..6a662f2 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -25,7 +25,7 @@ class TestSpeakerMapping extends TestPattern { for (Speaker speaker : model.speakers) { for (Strip strip : speaker.strips) { float b = 100; - for (Point p : strip.points) { + for (LXPoint p : strip.points) { colors[p.index] = lx.hsb(h % 360, 100, b); b = max(0, b - 10); } @@ -46,7 +46,7 @@ class TestBassMapping extends TestPattern { int h = 0; for (int si : strips) { float b = 100; - for (Point p : model.bassBox.strips.get(si).points) { + for (LXPoint p : model.bassBox.strips.get(si).points) { colors[p.index] = lx.hsb(h % 360, 100, b); b = max(0, b - 10); } @@ -65,7 +65,7 @@ class TestFloorMapping extends TestPattern { int h = 0; for (int si : strutIndices) { float b = 100; - for (Point p : model.bassBox.struts.get(si).points) { + for (LXPoint p : model.bassBox.struts.get(si).points) { colors[p.index] = lx.hsb(h % 360, 100, b); b = max(0, b - 10); } @@ -75,7 +75,7 @@ class TestFloorMapping extends TestPattern { h = 0; for (int fi : floorIndices) { float b = 100; - for (Point p : model.boothFloor.strips.get(fi).points) { + for (LXPoint p : model.boothFloor.strips.get(fi).points) { colors[p.index] = lx.hsb(h, 100, b); b = max(0, b - 3); } @@ -84,59 +84,6 @@ class TestFloorMapping extends TestPattern { } } -class TestPerformancePattern extends TestPattern { - - final BasicParameter ops = new BasicParameter("OPS", 0); - final BasicParameter iter = new BasicParameter("ITER", 0); - - TestPerformancePattern(GLucose glucose) { - super(glucose); - addParameter(ops); - addParameter(iter); - } - - public void run(double deltaMs) { - float x = 1; - for (int j = 0; j < ops.getValuef() * 400000; ++j) { - x *= random(0, 1); - } - - if (iter.getValuef() < 0.25) { - for (Point p : model.points) { - colors[p.index] = lx.hsb( - (p.x*.1 + p.y*.1) % 360, - 100, - 100 - ); - } - } else if (iter.getValuef() < 0.5) { - for (int i = 0; i < colors.length; ++i) { - colors[i] = lx.hsb( - (90 + model.px[i]*.1 + model.py[i]*.1) % 360, - 100, - 100 - ); - } - } else if (iter.getValuef() < 0.75) { - for (int i = 0; i < colors.length; ++i) { - colors[i] = lx.hsb( - (180 + model.p[3*i]*.1 + model.p[3*i+1]*.1) % 360, - 100, - 100 - ); - } - } else { - for (int i = 0; i < colors.length; ++i) { - colors[i] = lx.hsb( - (270 + model.x(i)*.1 + model.y(i)*.1) % 360, - 100, - 100 - ); - } - } - } -} - class TestStripPattern extends TestPattern { SinLFO d = new SinLFO(4, 40, 4000); @@ -148,7 +95,7 @@ class TestStripPattern extends TestPattern { public void run(double deltaMs) { for (Strip s : model.strips) { - for (Point p : s.points) { + for (LXPoint p : s.points) { colors[p.index] = lx.hsb( lx.getBaseHuef(), 100, @@ -188,7 +135,7 @@ class TestXPattern extends TestPattern { } public void run(double deltaMs) { float hv = lx.getBaseHuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { // This is a common technique for modulating brightness. // You can use abs() to determine the distance between two // values. The further away this point is from an exact @@ -210,7 +157,7 @@ class TestYPattern extends TestPattern { } public void run(double deltaMs) { float hv = lx.getBaseHuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { float bv = max(0, 100 - abs(p.y - yPos.getValuef())); colors[p.index] = lx.hsb(hv, 100, bv); } @@ -228,7 +175,7 @@ class TestZPattern extends TestPattern { } public void run(double deltaMs) { float hv = lx.getBaseHuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { float bv = max(0, 100 - abs(p.z - zPos.getValuef())); colors[p.index] = lx.hsb(hv, 100, bv); } @@ -249,7 +196,7 @@ class TestTowerPattern extends TestPattern { public void run(double deltaMs) { int ti = 0; for (Tower t : model.towers) { - for (Point p : t.points) { + for (LXPoint p : t.points) { colors[p.index] = lx.hsb( lx.getBaseHuef(), 100, @@ -282,13 +229,13 @@ class TestTowerPattern extends TestPattern { */ class TestProjectionPattern extends TestPattern { - private final Projection projection; + private final LXProjection projection; private final SawLFO angle = new SawLFO(0, TWO_PI, 9000); private final SinLFO yPos = new SinLFO(-20, 40, 5000); public TestProjectionPattern(GLucose glucose) { super(glucose); - projection = new Projection(model); + projection = new LXProjection(model); addModulator(angle).trigger(); addModulator(yPos).trigger(); } @@ -297,10 +244,10 @@ class TestProjectionPattern extends TestPattern { // For the same reasons described above, it may logically feel to you that // some of these operations are in reverse order. Again, just keep in mind that // the car itself is what's moving, not the object - projection.reset(model) + projection.reset() // Translate so the center of the car is the origin, offset by yPos - .translateCenter(model, 0, yPos.getValuef(), 0) + .translateCenter(0, yPos.getValuef(), 0) // Rotate around the origin (now the center of the car) about an X-vector .rotate(angle.getValuef(), 1, 0, 0) @@ -309,7 +256,7 @@ class TestProjectionPattern extends TestPattern { .scale(1, 1.5, 1); float hv = lx.getBaseHuef(); - for (Coord c : projection) { + for (LXVector c : projection) { float d = sqrt(c.x*c.x + c.y*c.y + c.z*c.z); // distance from origin // d = abs(d-60) + max(0, abs(c.z) - 20); // life saver / ring thing d = max(0, abs(c.y) - 10 + .1*abs(c.z) + .02*abs(c.x)); // plane / spear thing @@ -334,7 +281,7 @@ class TestCubePattern extends TestPattern { public void run(double deltaMs) { for (Cube c : model.cubes) { int i = 0; - for (Point p : c.points) { + for (LXPoint p : c.points) { colors[p.index] = lx.hsb( lx.getBaseHuef(), 100, diff --git a/TimBavaro.pde b/TimBavaro.pde index a10e89e..5ed805b 100644 --- a/TimBavaro.pde +++ b/TimBavaro.pde @@ -53,7 +53,7 @@ class TimSpheres extends SCPattern { spheres[0].radius = 100 * hueParameter.getValuef(); spheres[1].radius = 100 * hueParameter.getValuef(); - for (Point p : model.points) { + for (LXPoint p : model.points) { float value = 0; color c = lx.hsb(0, 0, 0); @@ -124,7 +124,7 @@ class Vector3 { return distanceTo(v.x, v.y, v.z); } - float distanceTo(Point p) { + float distanceTo(LXPoint p) { return distanceTo(p.x, p.y, p.z); } @@ -246,7 +246,7 @@ class TimRaindrops extends SCPattern { raindrops.add(new Raindrop()); } - for (Point p : model.points) { + for (LXPoint p : model.points) { color c = blendColor( lx.hsb(210, 20, (float)Math.max(0, 1 - Math.pow((model.yMax - p.y) / 10, 2)) * 50), @@ -337,14 +337,14 @@ class TimCubes extends SCPattern { flashes.add(new CubeFlash()); } - for (Point p : model.points) { + for (LXPoint p : model.points) { colors[p.index] = 0; } for (CubeFlash flash : flashes) { float hue = (hueParameter.getValuef() + (hueVarianceParameter.getValuef() * flash.hue)) % 1.0; color c = lx.hsb(hue * 360, saturationParameter.getValuef() * 100, (flash.value) * 100); - for (Point p : flash.c.points) { + for (LXPoint p : flash.c.points) { colors[p.index] = c; } } @@ -456,7 +456,7 @@ class TimPlanes extends SCPattern { Vector3 normalizedPoint = new Vector3(); - for (Point p : model.points) { + for (LXPoint p : model.points) { if (random(1.0) < derez) { continue; } @@ -631,7 +631,7 @@ class TimPinwheels extends SCPattern { float zSlope = (zSlopeParameter.getValuef() - 0.5) * 2; int i = -1; - for (Point p : model.points) { + for (LXPoint p : model.points) { ++i; int value = 0; @@ -663,25 +663,25 @@ class TimPinwheels extends SCPattern { * it but there may be useful code here. */ class TimTrace extends SCPattern { - private Map> pointToNeighbors; - private Map pointToStrip; + private Map> pointToNeighbors; + private Map pointToStrip; // private final Map> stripToNearbyStrips; int extraMs; class MovingPoint { - Point currentPoint; + LXPoint currentPoint; float hue; private Strip currentStrip; private int currentStripIndex; private int direction; // +1 or -1 - MovingPoint(Point p) { + MovingPoint(LXPoint p) { this.setPointOnNewStrip(p); hue = random(360); } - private void setPointOnNewStrip(Point p) { + private void setPointOnNewStrip(LXPoint p) { this.currentPoint = p; this.currentStrip = pointToStrip.get(p); for (int i = 0; i < this.currentStrip.points.size(); ++i) { @@ -703,9 +703,9 @@ class TimTrace extends SCPattern { } void step() { - List neighborsOnOtherStrips = pointToNeighbors.get(this.currentPoint); + List neighborsOnOtherStrips = pointToNeighbors.get(this.currentPoint); - Point nextPointOnCurrentStrip = null; + LXPoint nextPointOnCurrentStrip = null; this.currentStripIndex += this.direction; if (this.currentStripIndex >= 0 && this.currentStripIndex < this.currentStrip.points.size()) { nextPointOnCurrentStrip = this.currentStrip.points.get(this.currentStripIndex); @@ -745,7 +745,7 @@ class TimTrace extends SCPattern { Map stripToCenter = new HashMap(); for (Strip s : model.strips) { Vector3 v = new Vector3(); - for (Point p : s.points) { + for (LXPoint p : s.points) { v.add(p.x, p.y, p.z); } v.divide(s.points.size()); @@ -770,23 +770,23 @@ class TimTrace extends SCPattern { return stripToNeighbors; } - private Map> buildPointToNeighborsMap() { - Map> m = new HashMap(); + private Map> buildPointToNeighborsMap() { + Map> m = new HashMap(); Map> stripToNearbyStrips = this.buildStripToNearbyStripsMap(); for (Strip s : model.strips) { List nearbyStrips = stripToNearbyStrips.get(s); - for (Point p : s.points) { + for (LXPoint p : s.points) { Vector3 v = new Vector3(p.x, p.y, p.z); - List neighbors = new ArrayList(); + List neighbors = new ArrayList(); for (Strip nearbyStrip : nearbyStrips) { - Point closestPoint = null; + LXPoint closestPoint = null; float closestPointDistance = 100000; - for (Point nsp : nearbyStrip.points) { + for (LXPoint nsp : nearbyStrip.points) { float distance = v.distanceTo(nsp.x, nsp.y, nsp.z); if (closestPoint == null || distance < closestPointDistance) { closestPoint = nsp; @@ -806,10 +806,10 @@ class TimTrace extends SCPattern { return m; } - private Map buildPointToStripMap() { - Map m = new HashMap(); + private Map buildPointToStripMap() { + Map m = new HashMap(); for (Strip s : model.strips) { - for (Point p : s.points) { + for (LXPoint p : s.points) { m.put(p, s); } } @@ -817,7 +817,7 @@ class TimTrace extends SCPattern { } public void run(double deltaMs) { - for (Point p : model.points) { + for (LXPoint p : model.points) { color c = colors[p.index]; colors[p.index] = lx.hsb(lx.h(c), lx.s(c), lx.b(c) - 3); } diff --git a/TobySegaran.pde b/TobySegaran.pde index 82ad4d2..8aaacb1 100644 --- a/TobySegaran.pde +++ b/TobySegaran.pde @@ -24,7 +24,7 @@ class GlitchPlasma extends SCPattern { } public void run(double deltaMs) { - for (Point p : model.points) { + for (LXPoint p : model.points) { float hv = sin(dist(p.x + pos, p.y, 128.0, 128.0) / 8.0) + sin(dist(p.x, p.y, 64.0, 64.0) / 8.0) + sin(dist(p.x, p.y + pos / 7, 192.0, 64.0) / 7.0) @@ -81,7 +81,7 @@ class FireEffect extends SCPattern { } } - for (Point p : model.points) { + for (LXPoint p : model.points) { int x = max(0,(int(p.x)+int(p.z))%xm); int y = constrain(ym-int(p.y),0,ym-1); colors[p.index] = flameColor(intensity[x][y]); @@ -120,7 +120,7 @@ class StripBounce extends SCPattern { boolean on = avgdist<30; float hv = (lx.getBaseHuef()+colorOffset[i])%360; float br = max(0,100-avgdist*4); - for (Point p : strip.points) { + for (LXPoint p : strip.points) { if (on && br>bright[p.index]) { colors[p.index] = lx.hsb(hv,sat[i].getValuef(),br); bright[p.index] = br; @@ -184,7 +184,7 @@ class SoundRain extends SCPattern { for (int j=0; javgSize) seq=avgSize-seq; diff --git a/_DebugUI.pde b/_DebugUI.pde index 5b99d43..a36f688 100644 --- a/_DebugUI.pde +++ b/_DebugUI.pde @@ -200,7 +200,7 @@ class DebugUI { if (state != DEBUG_STATE_ANIM) { color debugColor = (state == DEBUG_STATE_WHITE) ? white : off; Cube cube = glucose.model.getCubeByRawIndex(rawCubeIndex); - for (Point p : cube.points) { + for (LXPoint p : cube.points) { colors[p.index] = debugColor; } } @@ -214,7 +214,7 @@ class DebugUI { if (state != DEBUG_STATE_ANIM) { color debugColor = (state == DEBUG_STATE_WHITE) ? white : off; for (Strip s : glucose.model.bassBox.boxStrips) { - for (Point p : s.points) { + for (LXPoint p : s.points) { colors[p.index] = debugColor; } } @@ -225,11 +225,11 @@ class DebugUI { state = debugState[channelIndex][1]; if (state != DEBUG_STATE_ANIM) { color debugColor = (state == DEBUG_STATE_WHITE) ? white : off; - for (Point p : glucose.model.boothFloor.points) { + for (LXPoint p : glucose.model.boothFloor.points) { colors[p.index] = debugColor; } for (Strip s : glucose.model.bassBox.struts) { - for (Point p : s.points) { + for (LXPoint p : s.points) { colors[p.index] = debugColor; } } @@ -240,7 +240,7 @@ class DebugUI { state = debugState[channelIndex][1]; if (state != DEBUG_STATE_ANIM) { color debugColor = (state == DEBUG_STATE_WHITE) ? white : off; - for (Point p : glucose.model.speakers.get(channel.objectIndices[0]).points) { + for (LXPoint p : glucose.model.speakers.get(channel.objectIndices[0]).points) { colors[p.index] = debugColor; } } diff --git a/_Internals.pde b/_Internals.pde index fb2a9c7..61c453e 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -14,17 +14,13 @@ */ import glucose.*; -import glucose.control.*; -import glucose.effect.*; import glucose.model.*; -import glucose.pattern.*; -import glucose.transform.*; -import glucose.transition.*; import heronarts.lx.*; -import heronarts.lx.control.*; import heronarts.lx.effect.*; import heronarts.lx.modulator.*; +import heronarts.lx.parameter.*; import heronarts.lx.pattern.*; +import heronarts.lx.transform.*; import heronarts.lx.transition.*; import ddf.minim.*; import ddf.minim.analysis.*; @@ -140,7 +136,7 @@ void setup() { lx = glucose.lx; lx.enableKeyboardTempo(); logTime("Built GLucose engine"); - + // Set the patterns LXEngine engine = lx.engine; engine.setPatterns(patterns = _leftPatterns(glucose)); @@ -328,7 +324,7 @@ void drawDiagnostics(long drawNanos, long simulationNanos, long uiNanos, long ga } void drawSimulation(color[] simulationColors) { - camera( + camera( eyeX, eyeY, eyeZ, midX, midY, midZ, 0, -1, 0 @@ -370,7 +366,7 @@ void drawSimulation(color[] simulationColors) { noFill(); strokeWeight(2); beginShape(POINTS); - for (Point p : glucose.model.points) { + for (LXPoint p : glucose.model.points) { stroke(simulationColors[p.index]); vertex(p.x, p.y, p.z); } diff --git a/_MIDI.pde b/_MIDI.pde index 36ec92c..7673f7f 100644 --- a/_MIDI.pde +++ b/_MIDI.pde @@ -710,7 +710,7 @@ class KorgNanoKontrolMidiInput extends GenericDeviceMidiInput { } } -class APC40MidiOutput implements LXParameter.Listener, GridOutput { +class APC40MidiOutput implements LXParameterListener, GridOutput { private final MidiEngine midiEngine; private final MidiOutput output; diff --git a/_Mappings.pde b/_Mappings.pde index 6b9b98c..12449cd 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -222,7 +222,7 @@ for (StaggeredTower st : scubes) { tower.add(cubes[cubeIndex++] = new Cube(st.x, st.y + CH* 4/3.*i, st.z, 0, st.r, 0, w)); } towerList.add(new Tower(tower)); - } + } return new Model(towerList, cubes, bassBox, speakers); } @@ -434,4 +434,4 @@ class ChannelMapping { objectIndices[i] = (i < rawObjectIndices.length) ? rawObjectIndices[i] : NO_OBJECT; } } -} \ No newline at end of file +} diff --git a/_PandaDriver.pde b/_PandaDriver.pde index 0aca6af..24afa20 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -264,7 +264,7 @@ public static class PandaDriver { private int mapStrip(Strip s, int direction, int[] points, int pi) { if (direction == FORWARD) { - for (Point p : s.points) { + for (LXPoint p : s.points) { points[pi++] = p.index; } } else if (direction == BACKWARD) { diff --git a/_Presets.pde b/_Presets.pde index 9d5c305..91598ac 100644 --- a/_Presets.pde +++ b/_Presets.pde @@ -10,7 +10,7 @@ class PresetManager { public static final String FILENAME = "data/presets.txt"; public static final String DELIMITER = "\t"; - class DeckState implements LXParameter.Listener { + class DeckState implements LXParameterListener { final LXDeck deck; LXPattern selectedPattern = null; diff --git a/_UIFramework.pde b/_UIFramework.pde index 6d80ad6..8ecb7e9 100644 --- a/_UIFramework.pde +++ b/_UIFramework.pde @@ -527,7 +527,7 @@ public class UIToggleSet extends UIObject { } -public abstract class UIParameterControl extends UIObject implements LXParameter.Listener { +public abstract class UIParameterControl extends UIObject implements LXParameterListener { protected LXParameter parameter = null; protected UIParameterControl(float x, float y, float w, float h) { diff --git a/_UIImplementation.pde b/_UIImplementation.pde index 95ac57d..0ea8073 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -479,7 +479,7 @@ class UISpeed extends UIWindow { super("SPEED", x, y, w, h); speed = new BasicParameter("SPEED", 0.5); new UIParameterSlider(4, titleHeight, w-10, 20) - .setParameter(speed.addListener(new LXParameter.Listener() { + .setParameter(speed.addListener(new LXParameterListener() { public void onParameterChanged(LXParameter parameter) { lx.setSpeed(parameter.getValuef() * 2); } diff --git a/code/GLucose.jar b/code/GLucose.jar index 92f9ff9..c27d414 100755 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ diff --git a/code/HeronLX.jar b/code/HeronLX.jar index 396a41e..e49c4df 100755 Binary files a/code/HeronLX.jar and b/code/HeronLX.jar differ