sinesphere
[SugarCubes.git] / AlexGreen.pde
1 class SineSphere extends DPat {
2 float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax));
3
4 PVector modelcenter = new PVector(model.xMax, model.yMax, model.zMax);
5 public BasicParameter widthparameter = new BasicParameter("Width", .1);
6 public BasicParameter huespread = new BasicParameter("Hue", .5);
7
8 class Sphery {
9 float f1xcenter, f1ycenter, f1zcenter, f2xcenter, f2ycenter, f2zcenter;
10 private SinLFO vibration;
11 private SinLFO surface;
12 private SinLFO vx;
13 float vibration_min, vibration_max, vperiod;
14
15
16 float hsv = huespread.getValuef();
17 float wpv = widthparameter.getValuef();
18 Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_min, float vibration_max, float vperiod) {
19 this.f1xcenter = f1xcenter;
20 this.f1ycenter = f1ycenter;
21 this.f1zcenter = f1zcenter;
22 this.vibration_min = vibration_min;
23 this.vibration_max = vibration_max;
24 this.vperiod = vperiod;
25 addModulator( vibration = new SinLFO(vibration_min , vibration_max, vperiod)).trigger(); vibration.modulateDurationBy(vx);
26 addModulator( vx = new SinLFO(-4000, 10000, 100000)).trigger();
27 }
28 float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, float f1z) {
29 return dist(px, py, pz, f1x, f1y, f1z);
30 }
31 //void updatespherey(deltaMs, )
32 color spheryvalue (float px, float py, float pz , float f1xcenter, float f1ycenter, float f1zcenter) {
33
34 return color(px, dist(px, py, pz, f1xcenter, f1ycenter, f1zcenter) , max(0, 100 - 10*abs(dist(px, py, pz, f1xcenter, f1ycenter, f1zcenter)- vibration.getValuef() ) ) );
35
36 }
37
38 void run(int deltaMS) {
39 final float vv = vibration.getValuef();
40 final float vvx = vx.getValuef();
41
42 }
43
44 }
45 final int NUM_SPHERES = 5;
46 final Sphery[] spherys;
47 SineSphere(GLucose glucose) {
48 super(glucose);
49
50 spherys = new Sphery[NUM_SPHERES];
51 spherys[1] = new Sphery(model.xMax/4, model.yMax/2, model.zMax/2, modelrad/16, modelrad/8, 2500) ;
52 spherys[2] = new Sphery(.75*model.xMax, model.yMax/2, model.zMax/2, modelrad/20, modelrad/10, 2000);
53 spherys[3] = new Sphery(model.xMax/2, model.yMax/2, model.zMax/2, modelrad/4, modelrad/8, 2500);
54
55 }
56
57
58
59 public void StartRun(int deltaMs) {
60
61 spherys[1].run(deltaMs);
62 spherys[2].run(deltaMs);
63 spherys[3].run(deltaMs);
64 }
65
66
67 color CalcPoint(xyz Px) {
68
69 color c = 0;
70
71 c = blendColor(c, spherys[2].spheryvalue(Px.x, Px.y, Px.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD);
72 c = blendColor(c, spherys[1].spheryvalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD);
73 c = blendColor(c, spherys[3].spheryvalue(Px.x, Px.y, Px.z, model.xMax/2, model.yMax/2, model.zMax/2),ADD);
74
75
76
77
78 return c;
79 }
80 }
81
82