Commit | Line | Data |
---|---|---|
e28f168c | 1 | class SineSphere extends DPat { |
0b1785e3 | 2 | float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax)); |
e27a8652 | 3 | |
0b1785e3 | 4 | PVector modelcenter = new PVector(model.xMax, model.yMax, model.zMax); |
a316cb97 AG |
5 | public BasicParameter widthparameter = new BasicParameter("Width", .1); |
6 | public BasicParameter huespread = new BasicParameter("Hue", .5); | |
0b1785e3 AG |
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 | ||
a316cb97 AG |
15 | |
16 | float hsv = huespread.getValuef(); | |
17 | float wpv = widthparameter.getValuef(); | |
0b1785e3 AG |
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); | |
e27a8652 | 26 | addModulator( vx = new SinLFO(-4000, 10000, 100000)).trigger(); |
0b1785e3 AG |
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 | ||
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(); | |
a316cb97 | 41 | |
0b1785e3 AG |
42 | } |
43 | ||
44 | } | |
45 | final int NUM_SPHERES = 5; | |
46 | final Sphery[] spherys; | |
47 | SineSphere(GLucose glucose) { | |
48 | super(glucose); | |
e27a8652 | 49 | |
0b1785e3 AG |
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); | |
e27a8652 | 53 | spherys[3] = new Sphery(model.xMax/2, model.yMax/2, model.zMax/2, modelrad/4, modelrad/8, 5000); |
0b1785e3 AG |
54 | } |
55 | ||
e28f168c | 56 | |
e28f168c AG |
57 | |
58 | public void StartRun(int deltaMs) { | |
e27a8652 | 59 | |
e28f168c AG |
60 | spherys[1].run(deltaMs); |
61 | spherys[2].run(deltaMs); | |
e27a8652 | 62 | spherys[3].run(deltaMs); |
e28f168c AG |
63 | } |
64 | ||
65 | ||
66 | color CalcPoint(xyz Px) { | |
67 | ||
0b1785e3 AG |
68 | color c = 0; |
69 | ||
e28f168c AG |
70 | c = blendColor(c, spherys[2].spheryvalue(Px.x, Px.y, Px.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD); |
71 | c = blendColor(c, spherys[1].spheryvalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD); | |
e27a8652 | 72 | c = blendColor(c, spherys[3].spheryvalue(Px.x, Px.y, Px.z, model.xMax/2, model.yMax/2, model.zMax/2),ADD); |
0b1785e3 | 73 | |
e27a8652 AG |
74 | |
75 | ||
0b1785e3 | 76 | |
e28f168c | 77 | return c; |
0b1785e3 | 78 | } |
e28f168c AG |
79 | } |
80 | ||
0b1785e3 | 81 |