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();
SineSphere(GLucose glucose)
{
super(glucose);
- sinespin = new Projection(model);
+ sinespin = new LXProjection(model);
sinespin2 = new Projection(model);
addParameter(huespread);
addParameter(rotationx);
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)
{
case 55: t = 2*t; bpm = 2*bpm; break;
default: t= t; bpm = bpm;
-
+}
}
}
-
-
}
color blendIfColor(color c1, color c2, int mode) {
// 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);
// 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] =
// }
// 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), );
}
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;
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();
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)
{
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)
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)
}
return lx.hsb(
- constrain(huespread.getValuef()*5*quadrant(p), 0, 360),
+ constrain(quadrant(p), 0, 360),
80,
b
);
}
+// 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),
// }
// }
+<<<<<<< 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)
.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);
// 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);
// 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] =
// }
// 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), );
}
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;
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));
}
}
}
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));
}
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);
}
}
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(
for(int i=0; i<towerSize ;i++)
{
t= model.towers.get(i);
- for(Point p : t.points)
+ for(LXPoint p : t.points)
{
if(p.y<towerParams.get(i).getValuef()*200)
{
public void clearALL()
{
- for(Point p : model.points)
+ for(LXPoint p : model.points)
{
colors[p.index] = 0;
}
public void doDraw(int c,long col)
{
Tower t= model.towers.get((int) c);
- for(Point p : t.points)
+ for(LXPoint p : t.points)
{
colors[p.index] = (int) col;
}
}
public void clearALL()
{
- for(Point p : model.points)
+ for(LXPoint p : model.points)
{
colors[p.index] = 0;
}
evalTurn(vCur.t2); evalTurn(vCur.t3);
}
- Point p1, p2; int i2;
+ LXPoint p1, p2; int i2;
int draw(int nAmount, SCPattern pat) {
int nFrom = (pos ) >> 12;
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); }
}
}
// }
// 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); }
// }
// }
//}
}
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<balls.length; i++){
if(millis() - balls[i].lastSeen < 1000) {
- for(Point p: model.points){
+ for(LXPoint p: model.points){
int x = int(balls[i].x * 255.0);
int y = int(balls[i].y * 127.0);
if(p.x < x+4 && p.x > x-4 && p.y < y+4 && p.y > y-4) { colors[p.index] = #FF0000; }
pret.pixels = ss.getScreenShotJNI2(x, y, w, h);
//for(int i=0; i<px.length; i++){ pret.pixels[i] = px[i]; }
//println(pret.get(10,10));
- for(Point p: model.points){
+ for(LXPoint p: model.points){
colors[p.index] = pret.get((int(p.x)/8)*8, 128-int(p.y));
}
}
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;
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(); }
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);
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); }
}
//----------------------------------------------------------------------------------------------------------------------------------
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
{
((Granim) g).update();
}
- List<Point> drawList = model.points.subList(Math.min(g.position,colors.length-1), Math.min(g.position + g.width(),colors.length-1));
+ List<LXPoint> 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]);
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);
Gimbal(GLucose glucose) {
super(glucose);
- projection = new Projection(model);
+ projection = new LXProjection(model);
addParameter(beatsPerRevolutionParam);
addParameter(hueDeltaParam);
addParameter(fadeFromCoreParam);
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);
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;
class Zebra extends SCPattern {
- private final Projection projection;
+ private final LXProjection projection;
SinLFO angleM = new SinLFO(0, PI * 2, 30000);
/*
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();
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);
}
}
-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);
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);
public Swim(GLucose glucose) {
super(glucose);
- projection = new Projection(model);
+ projection = new LXProjection(model);
addParameter(xAngle);
addParameter(yAngle);
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.
// Projection stuff
- private final Projection projection;
+ private final LXProjection projection;
SinLFO sphere1Z = new SinLFO(0, 0, 15323);
SinLFO sphere2Z = new SinLFO(0, 0, 8323);
public Balance(GLucose glucose) {
super(glucose);
- projection = new Projection(model);
+ projection = new LXProjection(model);
addParameter(hueScale);
addParameter(phaseParam);
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;
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;
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,
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) {
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(
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,
}
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(
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(
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) {
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),
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);
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,
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];
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) {
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;
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)),
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,
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.),
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)),
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) {
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,
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;
}
}
+
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);
LXPattern[] patterns(GLucose glucose) {
return new LXPattern[] {
- new SineSphere(glucose),
- new CubeCurl(glucose),
// Slee
new Cathedrals(glucose),
new MidiMusic(glucose),
new TestBassMapping(glucose),
new TestFloorMapping(glucose),
new TestSpeakerMapping(glucose),
- new TestPerformancePattern(glucose),
// new TestHuePattern(glucose),
// new TestXPattern(glucose),
// new TestYPattern(glucose),
--- /dev/null
+/**
+ * +-+-+-+-+-+ +-+-+-+-+-+
+ * / /| |\ \
+ * / / + + \ \
+ * +-+-+-+-+-+ | +-+-+-+-+ | +-+-+-+-+-+
+ * | | + / \ + | |
+ * + 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();
+ }
+}
+
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);
}
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);
}
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);
}
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);
}
}
}
-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);
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,
}
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
}
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);
}
}
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);
}
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,
*/
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();
}
// 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)
.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
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,
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);
return distanceTo(v.x, v.y, v.z);
}
- float distanceTo(Point p) {
+ float distanceTo(LXPoint p) {
return distanceTo(p.x, p.y, p.z);
}
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),
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;
}
}
Vector3 normalizedPoint = new Vector3();
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
if (random(1.0) < derez) {
continue;
}
float zSlope = (zSlopeParameter.getValuef() - 0.5) * 2;
int i = -1;
- for (Point p : model.points) {
+ for (LXPoint p : model.points) {
++i;
int value = 0;
* it but there may be useful code here.
*/
class TimTrace extends SCPattern {
- private Map<Point, List<Point>> pointToNeighbors;
- private Map<Point, Strip> pointToStrip;
+ private Map<LXPoint, List<LXPoint>> pointToNeighbors;
+ private Map<LXPoint, Strip> pointToStrip;
// private final Map<Strip, List<Strip>> 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) {
}
void step() {
- List<Point> neighborsOnOtherStrips = pointToNeighbors.get(this.currentPoint);
+ List<LXPoint> 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);
Map<Strip, Vector3> 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());
return stripToNeighbors;
}
- private Map<Point, List<Point>> buildPointToNeighborsMap() {
- Map<Point, List<Point>> m = new HashMap();
+ private Map<LXPoint, List<LXPoint>> buildPointToNeighborsMap() {
+ Map<LXPoint, List<LXPoint>> m = new HashMap();
Map<Strip, List<Strip>> stripToNearbyStrips = this.buildStripToNearbyStripsMap();
for (Strip s : model.strips) {
List<Strip> 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<Point> neighbors = new ArrayList();
+ List<LXPoint> 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;
return m;
}
- private Map<Point, Strip> buildPointToStripMap() {
- Map<Point, Strip> m = new HashMap();
+ private Map<LXPoint, Strip> buildPointToStripMap() {
+ Map<LXPoint, Strip> m = new HashMap();
for (Strip s : model.strips) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
m.put(p, s);
}
}
}
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);
}
}
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)
}
}
- 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]);
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;
for (int j=0; j<c.strips.size(); j++) {
Strip s = c.strips.get(j);
if (j%4!=0 && j%4!=2) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
int seq = int(p.y*avgSize/model.yMax+pos.getValuef()+sin(p.x+p.z)*2)%avgSize;
seq=min(abs(seq-(avgSize/2)),avgSize-1);
colors[p.index] = lx.hsb(200,max(0,100-abs(p.x-col1.getValuef())/2),lightVals[seq]);
int i=0;
for (Strip s : model.strips) {
i++;
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
float dx, dz;
if (i%32 < 16) {
dx = p.x - (s.cx+xosc.getValuef());
for (int j=0; j<c.strips.size(); j++) {
Strip s = c.strips.get(j);
if (j%4!=0 && j%4!=2) {
- for (Point p : s.points) {
+ for (LXPoint p : s.points) {
float dis = (abs(p.x-model.xMax/2)+pos.getValuef())%model.xMax/2;
int seq = int((dis*avgSize*2)/model.xMax);
if (seq>avgSize) seq=avgSize-seq;
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;
}
}
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;
}
}
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;
}
}
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;
}
}
*/
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.*;
lx = glucose.lx;
lx.enableKeyboardTempo();
logTime("Built GLucose engine");
-
+
// Set the patterns
LXEngine engine = lx.engine;
engine.setPatterns(patterns = _leftPatterns(glucose));
}
void drawSimulation(color[] simulationColors) {
- camera(
+ camera(
eyeX, eyeY, eyeZ,
midX, midY, midZ,
0, -1, 0
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);
}
}
}
-class APC40MidiOutput implements LXParameter.Listener, GridOutput {
+class APC40MidiOutput implements LXParameterListener, GridOutput {
private final MidiEngine midiEngine;
private final MidiOutput output;
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);
}
objectIndices[i] = (i < rawObjectIndices.length) ? rawObjectIndices[i] : NO_OBJECT;
}
}
-}
\ No newline at end of file
+}
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) {
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;
}
-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) {
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);
}