1 class SineSphere extends DPat {
2 float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax));
3 //PVector modelcenter = new PVector(model.xMax, model.yMax, model.zMax);
7 float f1xcenter, f1ycenter, f1zcenter, f2xcenter , f2ycenter, f2zcenter; //second three are for an ellipse with two foci
8 private SinLFO vibration;
9 private SinLFO surface;
11 private SinLFO xbounce;
12 public SinLFO ybounce;
13 private SinLFO zbounce;
14 float vibration_min, vibration_max, vperiod;
15 public BasicParameter widthparameter;
16 public BasicParameter huespread;
17 public BasicParameter bouncerate;
18 public BasicParameter bounceamp;
22 public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_min, float vibration_max, float vperiod)
24 this.f1xcenter = f1xcenter;
25 this.f1ycenter = f1ycenter;
26 this.f1zcenter = f1zcenter;
27 this.vibration_min = vibration_min;
28 this.vibration_max = vibration_max;
29 this.vperiod = vperiod;
30 addParameter(bounceamp = new BasicParameter("Amp", .5));
31 addParameter(bouncerate = new BasicParameter("Rate", .5)); //ybounce.modulateDurationBy(bouncerate);
32 addParameter(widthparameter = new BasicParameter("Width", .1));
33 addParameter(huespread = new BasicParameter("Hue", .2));
35 addModulator( vx = new SinLFO(-4000, 10000, 100000)).trigger() ;
36 //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger();
37 addModulator(ybounce= new SinLFO(model.yMax/3, 2*model.yMax/3, 240000./lx.tempo.bpm())).trigger(); //ybounce.modulateDurationBy
39 //addModulator(bounceamp); //ybounce.setMagnitude(bouncerate);
40 addModulator( vibration = new SinLFO(vibration_min , vibration_max, 240000./lx.tempo.bpm())).trigger(); //vibration.modulateDurationBy(vx);
43 public Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float f2xcenter, float f2ycenter, float f2zcenter,
44 float vibration_min, float vibration_max, float vperiod)
46 this.f1xcenter = f1xcenter;
47 this.f1ycenter = f1ycenter;
48 this.f1zcenter = f1zcenter;
49 this.f2xcenter = f2xcenter;
50 this.f2ycenter = f2ycenter;
51 this.f2zcenter = f2zcenter;
52 this.vibration_min = vibration_min;
53 this.vibration_max = vibration_max;
54 this.vperiod = vperiod;
55 //addModulator(xbounce = new SinLFO(model.xMax/3, 2*model.yMax/3, 2000)).trigger();
56 addModulator(ybounce).trigger();
57 addModulator( vibration = new SinLFO(vibration_min , vibration_max, lx.tempo.rampf())).trigger(); //vibration.modulateDurationBy(vx);
58 addParameter(widthparameter = new BasicParameter("Width", .1));
59 addParameter(huespread = new BasicParameter("Hue", .2));
67 float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, float f1z)
69 return dist(px, py, pz, f1x, f1y, f1z);
71 //void updatespherey(deltaMs, )
72 color spheryvalue (float px, float py, float pz , float f1xc, float f1yc, float f1zc)
74 //switch(sShpape.cur() ) {}
75 return color(constrain(huespread.getValuef()*5*px, 0, 360) , dist(px, py, pz, f1xc, f1yc, f1zc) ,
76 max(0, 100 - 100*widthparameter.getValuef()*abs(dist(px, py, pz, f1xcenter, ybounce.getValuef(), f1zcenter)
77 - vibration.getValuef() ) ) );
79 color ellipsevalue(float px, float py, float pz , float f1xc, float f1yc, float f1zc, float f2xc, float f2yc, float f2zc)
81 //switch(sShpape.cur() ) {}
82 return color(huespread.getValuef()*5*px, dist(model.xMax-px, model.yMax-py, model.zMax-pz, f1xc, f1yc, f1zc) ,
83 max(0, 100 - 100*widthparameter.getValuef() *
84 abs( (dist(px, py, pz, f1xc, ybounce.getValuef(), f1zc) +
85 (dist(px, py , pz, f2xc, ybounce.getValuef(), f2zc) ) )/2
86 - 1.2*vibration.getValuef() ) ) ) ;
90 void run(int deltaMS) { };
95 final Sphery[] spherys;
96 SineSphere(GLucose glucose)
99 //Sshape = addPick("Shape", 0, 1);
100 spherys = new Sphery[] {
101 new Sphery(model.xMax/4, model.yMax/2, model.zMax/2, modelrad/16, modelrad/8, 3000),
102 new Sphery(.75*model.xMax, model.yMax/2, model.zMax/2, modelrad/20, modelrad/10, 2000),
103 new Sphery(model.xMax/2, model.yMax/2, model.zMax/2, modelrad/4, modelrad/8, 2300),
108 // public void onParameterChanged(LXParameter parameter)
112 // for (Sphery s : spherys) {
113 // if (s == null) continue;
114 // double bampv = s.bounceamp.getValue();
115 // double brv = s.bouncerate.getValue();
116 // double tempobounce = lx.tempo.bpm();
117 // if (parameter == s.bounceamp)
119 // s.ybounce.setRange(bampv*model.yMax/3 , bampv*2*model.yMax/3, brv);
121 // else if ( parameter == s.bouncerate )
123 // s.ybounce.setDuration(120000./tempobounce);
128 void StartRun(int deltaMs) {
129 float t = lx.tempo.rampf();
130 float bpm = lx.tempo.bpmf();
131 //spherys[1].run(deltaMs);
132 //spherys[2].run(deltaMs);
133 //spherys[3].run(deltaMs);
141 // void keyPressed() {
145 color CalcPoint(xyz Px)
147 // if (spheremode == 0 )
150 c = blendColor(c, spherys[1].spheryvalue(Px.x, Px.y, Px.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD);
151 c = blendColor(c, spherys[0].spheryvalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD);
152 c = blendColor(c, spherys[2].spheryvalue(Px.x, Px.y, Px.z, model.xMax/2, model.yMax/2, model.zMax/2),ADD);
155 // else if (spheremode == 1)
159 // c = blendColor(c, spherys[3].ellipsevalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/4, 3*model.xMax/4, 3*model.yMax/4, 3*model.zMax/4),ADD);
162 // return color(0,0,0);
163 // // else if(spheremode ==2)
165 // return color(CalcCone( (xyz by = new xyz(0,spherys[2].ybounce.getValuef(),0) ), Px, mid) );
174 class CubeCurl extends SCPattern{
176 private SinLFO curl = new SinLFO(0, Cube.EDGE_HEIGHT, 5000 );
178 private SinLFO bg = new SinLFO(180, 220, 3000);
180 CubeCurl(GLucose glucose){
182 addModulator(curl).trigger();
183 addModulator(bg).trigger();
184 this.CH = Cube.EDGE_HEIGHT;
185 this.CW = Cube.EDGE_WIDTH;
186 final float diag = sqrt(CH*CH + CW*CW + CW*CW);
187 ArrayList<PVector> centerlist = new ArrayList<PVector>();
189 for (int i = 0; i < model.cubes.size(); i++){
190 centerlist.add(centerofcube(i));
194 //there is definitely a better way of doing this!
195 PVector centerofcube(int i) {
196 Cube c = model.cubes.get(i);
197 PVector cubeorigin = new PVector(c.x, c.y, c.z);
198 PVector cubecenter = new PVector(c.x+ CW/2, c.y + CH/2, c.z + CW/2);
199 PVector cubeangle = new PVector(c.rx, c.ry, c.rz);
200 cubeangle.normalize();
201 println( cubeangle.x + cubeangle.y + cubeangle.z);
202 PVector cubecenterf = new PVector(cubecenter.x + tan(c.rx)*CW/2, cubecenter.y + tan(c.ry)*CH/2, cubecenter.z + tan(c.rz)*CW/2);
208 void run(double deltaMs){
209 for (int i =0; i < model.cubes.size(); i++) {
210 Cube c = model.cubes.get(i);
215 for (Point p : c.points ){
216 // colors[p.index]=color(0,0,0);
217 //float dif = (p.y - c.y);
218 //colors[p.index] = color( bg.getValuef() , 80 , dif < curl.getValuef() ? 80 : 0, ADD);
224 for (Point p: c.points){
225 colors[p.index]=color(0,0,0);
226 float dif = (p.y - c.y);
228 // color(bg.getValuef(),
229 // map(curl.getValuef(), 0, Cube.EDGE_HEIGHT, 20, 100),
230 // 100 - 10*abs(dif - curl.getValuef()), ADD );
234 for (Point p: c.points) {
247 class HueTestHSB extends SCPattern{
248 BasicParameter HueT = new BasicParameter("Hue", .5);
249 BasicParameter SatT = new BasicParameter("Sat", .5);
250 BasicParameter BriT = new BasicParameter("Bright", .5);
252 HueTestHSB(GLucose glucose) {
258 void run(double deltaMs){
260 for (Point p : model.points) {
262 c = blendColor(c, color(360*HueT.getValuef(), 100*SatT.getValuef(), 100*BriT.getValuef()), ADD);
266 if (now % 1000 <= 20)
268 println("Hue: " + 360*HueT.getValuef() + "Sat: " + 100*SatT.getValuef() + "Bright: " + 100*BriT.getValuef());