Commit | Line | Data |
---|---|---|
0b1785e3 AG |
1 | class SineSphere extends SCPattern { |
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 | ||
55 | public void run(int deltaMs) { | |
56 | float rsv = rs.getValuef(); | |
57 | float noiseyv = noisey.getValuef(); | |
58 | float bandv = band.getValuef(); | |
59 | ||
60 | spherys[1].run(deltaMs); | |
61 | spherys[2].run(deltaMs); | |
62 | ||
63 | for (Point p: model.points) { | |
64 | ||
65 | color c = 0; | |
66 | ||
67 | c = blendColor(c, spherys[2].spheryvalue(p.fx, p.fy, p.fz, .75*model.xMax, model.yMax/2, model.zMax/2), ADD); | |
68 | c = blendColor(c, spherys[1].spheryvalue(p.fx, p.fy, p.fz, model.xMax/4, model.yMax/4, model.zMax/2), ADD); | |
69 | float distfromcenter = dist(p.fx, p.fy, p.fz, model.xMax/2, model.yMax/2, model.zMax/2); | |
70 | int distint = floor(distfromcenter); | |
71 | ||
72 | c = blendColor(c, color( | |
73 | ||
74 | constrain( p.fx , 0, 360), | |
75 | constrain( distfromcenter, 20, 80), | |
76 | max(0, 100 - 10*abs(distfromcenter - noiseyv ) ) | |
77 | ), | |
78 | ADD); | |
79 | ||
80 | ||
81 | colors[p.index]=c; | |
82 | } | |
83 | } | |
84 | } | |
85 |