Commit | Line | Data |
---|---|---|
e28f168c | 1 | class SineSphere extends DPat { |
0b1785e3 AG |
2 | float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax)); |
3 | private final SinLFO rs = new SinLFO(0, 180, 5000); | |
4 | private final SinLFO noisey = new SinLFO(modelrad/8.0, modelrad/4.0, 2300); | |
5 | private final SinLFO band = new SinLFO (0, 10, 2000); | |
6 | PVector modelcenter = new PVector(model.xMax, model.yMax, model.zMax); | |
7 | BasicParameter widthparameter = new BasicParameter("Width", 10); | |
8 | ||
9 | ||
10 | class Sphery { | |
11 | float f1xcenter, f1ycenter, f1zcenter, f2xcenter, f2ycenter, f2zcenter; | |
12 | private SinLFO vibration; | |
13 | private SinLFO surface; | |
14 | private SinLFO vx; | |
15 | float vibration_min, vibration_max, vperiod; | |
16 | ||
17 | Sphery(float f1xcenter, float f1ycenter, float f1zcenter, float vibration_min, float vibration_max, float vperiod) { | |
18 | this.f1xcenter = f1xcenter; | |
19 | this.f1ycenter = f1ycenter; | |
20 | this.f1zcenter = f1zcenter; | |
21 | this.vibration_min = vibration_min; | |
22 | this.vibration_max = vibration_max; | |
23 | this.vperiod = vperiod; | |
24 | addModulator( vibration = new SinLFO(vibration_min , vibration_max, vperiod)).trigger(); vibration.modulateDurationBy(vx); | |
25 | addModulator( vx = new SinLFO(-1000, 1000, 10000)).trigger(); | |
26 | } | |
27 | float distfromcirclecenter(float px, float py, float pz, float f1x, float f1y, float f1z) { | |
28 | return dist(px, py, pz, f1x, f1y, f1z); | |
29 | } | |
30 | ||
31 | color spheryvalue (float px, float py, float pz , float f1xcenter, float f1ycenter, float f1zcenter) { | |
32 | ||
33 | return color(px, dist(px, py, pz, f1xcenter, f1ycenter, f1zcenter) , max(0, 100 - 10*abs(dist(px, py, pz, f1xcenter, f1ycenter, f1zcenter)- vibration.getValuef() ) ) ); | |
34 | ||
35 | } | |
36 | ||
37 | void run(int deltaMS) { | |
38 | final float vv = vibration.getValuef(); | |
39 | final float vvx = vx.getValuef(); | |
40 | } | |
41 | ||
42 | } | |
43 | final int NUM_SPHERES = 5; | |
44 | final Sphery[] spherys; | |
45 | SineSphere(GLucose glucose) { | |
46 | super(glucose); | |
47 | addModulator(rs).trigger(); | |
48 | //addModulator(band).trigger(); | |
49 | addModulator(noisey).trigger(); | |
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 | } | |
54 | ||
e28f168c AG |
55 | |
56 | float rsv, noiseyv, bandv; | |
57 | ||
58 | public void StartRun(int deltaMs) { | |
59 | rsv = rs.getValuef(); | |
60 | noiseyv = noisey.getValuef(); | |
61 | bandv = band.getValuef(); | |
0b1785e3 | 62 | |
e28f168c AG |
63 | spherys[1].run(deltaMs); |
64 | spherys[2].run(deltaMs); | |
65 | } | |
66 | ||
67 | ||
68 | color CalcPoint(xyz Px) { | |
69 | ||
0b1785e3 AG |
70 | color c = 0; |
71 | ||
e28f168c AG |
72 | c = blendColor(c, spherys[2].spheryvalue(Px.x, Px.y, Px.z, .75*model.xMax, model.yMax/2, model.zMax/2), ADD); |
73 | c = blendColor(c, spherys[1].spheryvalue(Px.x, Px.y, Px.z, model.xMax/4, model.yMax/4, model.zMax/2), ADD); | |
74 | float distfromcenter = dist(Px.x, Px.y, Px.z, model.xMax/2, model.yMax/2, model.zMax/2); | |
0b1785e3 AG |
75 | int distint = floor(distfromcenter); |
76 | ||
77 | c = blendColor(c, color( | |
78 | ||
e28f168c | 79 | constrain( Px.x , 0, 360), |
0b1785e3 AG |
80 | constrain( distfromcenter, 20, 80), |
81 | max(0, 100 - 10*abs(distfromcenter - noiseyv ) ) | |
82 | ), | |
83 | ADD); | |
84 | ||
e28f168c | 85 | return c; |
0b1785e3 | 86 | } |
e28f168c AG |
87 | } |
88 | ||
0b1785e3 | 89 |