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 AG |
4 | PVector modelcenter = new PVector(model.xMax, model.yMax, model.zMax); |
5 | BasicParameter widthparameter = new BasicParameter("Width", 10); | |
6 | ||
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 | Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_min, float vibration_max, float vperiod) { | |
16 | this.f1xcenter = f1xcenter; | |
17 | this.f1ycenter = f1ycenter; | |
18 | this.f1zcenter = f1zcenter; | |
19 | this.vibration_min = vibration_min; | |
20 | this.vibration_max = vibration_max; | |
21 | this.vperiod = vperiod; | |
22 | addModulator( vibration = new SinLFO(vibration_min , vibration_max, vperiod)).trigger(); vibration.modulateDurationBy(vx); | |
e27a8652 | 23 | addModulator( vx = new SinLFO(-4000, 10000, 100000)).trigger(); |
0b1785e3 AG |
24 | } |
25 | float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, float f1z) { | |
26 | return dist(px, py, pz, f1x, f1y, f1z); | |
27 | } | |
28 | ||
29 | color spheryvalue (float px, float py, float pz , float f1xcenter, float f1ycenter, float f1zcenter) { | |
30 | ||
31 | return color(px, dist(px, py, pz, f1xcenter, f1ycenter, f1zcenter) , max(0, 100 - 10*abs(dist(px, py, pz, f1xcenter, f1ycenter, f1zcenter)- vibration.getValuef() ) ) ); | |
32 | ||
33 | } | |
34 | ||
35 | void run(int deltaMS) { | |
36 | final float vv = vibration.getValuef(); | |
37 | final float vvx = vx.getValuef(); | |
38 | } | |
39 | ||
40 | } | |
41 | final int NUM_SPHERES = 5; | |
42 | final Sphery[] spherys; | |
43 | SineSphere(GLucose glucose) { | |
44 | super(glucose); | |
e27a8652 | 45 | |
0b1785e3 AG |
46 | spherys = new Sphery[NUM_SPHERES]; |
47 | spherys[1] = new Sphery(model.xMax/4, model.yMax/2, model.zMax/2, modelrad/16, modelrad/8, 2500) ; | |
48 | spherys[2] = new Sphery(.75*model.xMax, model.yMax/2, model.zMax/2, modelrad/20, modelrad/10, 2000); | |
e27a8652 | 49 | spherys[3] = new Sphery(model.xMax/2, model.yMax/2, model.zMax/2, modelrad/4, modelrad/8, 5000); |
0b1785e3 AG |
50 | } |
51 | ||
e28f168c AG |
52 | |
53 | float rsv, noiseyv, bandv; | |
54 | ||
55 | public void StartRun(int deltaMs) { | |
e27a8652 | 56 | |
e28f168c AG |
57 | spherys[1].run(deltaMs); |
58 | spherys[2].run(deltaMs); | |
e27a8652 | 59 | spherys[3].run(deltaMs); |
e28f168c AG |
60 | } |
61 | ||
62 | ||
63 | color CalcPoint(xyz Px) { | |
64 | ||
0b1785e3 AG |
65 | color c = 0; |
66 | ||
e28f168c AG |
67 | c = blendColor(c, spherys[2].spheryvalue(Px.x, Px.y, Px.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD); |
68 | c = blendColor(c, spherys[1].spheryvalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD); | |
e27a8652 | 69 | c = blendColor(c, spherys[3].spheryvalue(Px.x, Px.y, Px.z, model.xMax/2, model.yMax/2, model.zMax/2),ADD); |
0b1785e3 | 70 | |
e27a8652 AG |
71 | |
72 | ||
0b1785e3 | 73 | |
e28f168c | 74 | return c; |
0b1785e3 | 75 | } |
e28f168c AG |
76 | } |
77 | ||
0b1785e3 | 78 |