Revision faa3ff56
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/effect/VertexEffectSink.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
|
27 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 |
|
|
28 |
/** |
|
29 |
* Pull all points around the center of the Effect towards the center point (if degree>=1) or push them |
|
30 |
* away from it (degree<=1). |
|
31 |
*/ |
|
29 | 32 |
public class VertexEffectSink extends VertexEffect |
30 | 33 |
{ |
31 | 34 |
private Data1D mSink; |
... | ... | |
34 | 37 |
|
35 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 39 |
/** |
37 |
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them |
|
38 |
* away from the center (degree<=1) |
|
39 |
* |
|
40 |
* @param sink The current degree of the Effect. |
|
41 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
42 |
* @param region Region that masks the Effect. |
|
43 |
*/ |
|
44 |
public VertexEffectSink(Data1D sink, Data3D center, Data4D region) |
|
45 |
{ |
|
46 |
super(EffectName.SINK); |
|
47 |
mSink = sink; |
|
48 |
mCenter = center; |
|
49 |
mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); |
|
50 |
} |
|
51 |
|
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
/** |
|
54 |
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them |
|
55 |
* away from the center (degree<=1) |
|
40 |
* Only for use by the library itself. |
|
56 | 41 |
* |
57 |
* @param sink The current degree of the Effect. |
|
58 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
42 |
* @y.exclude |
|
59 | 43 |
*/ |
60 |
public VertexEffectSink(Data1D sink, Data3D center) |
|
61 |
{ |
|
62 |
super(EffectName.SINK); |
|
63 |
mSink = sink; |
|
64 |
mCenter = center; |
|
65 |
mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
66 |
} |
|
67 |
|
|
68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
69 |
|
|
70 | 44 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
71 | 45 |
{ |
72 | 46 |
mCenter.get(uniforms,index+5,currentDuration,step); |
... | ... | |
78 | 52 |
return ret; |
79 | 53 |
} |
80 | 54 |
|
55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
56 |
// PUBLIC API |
|
81 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
82 | 58 |
// Pull P=(v.x,v.y) towards center of the effect with P' = P + (1-h)*dist(S-P) |
83 | 59 |
// when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(S-P) |
84 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
/** |
|
62 |
* Have to call this before the shaders get compiled (i.e before Distorted.onCreate()) for the Effect to work. |
|
63 |
*/ |
|
85 | 64 |
public static void enable() |
86 | 65 |
{ |
87 | 66 |
addEffect(EffectName.SINK, |
... | ... | |
94 | 73 |
+ "v.xy += t*ps;" |
95 | 74 |
); |
96 | 75 |
} |
76 |
|
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
/** |
|
79 |
* Pull all points around the center of the Effect towards the center point (if degree>=1) or push them |
|
80 |
* away from it (degree<=1) |
|
81 |
* |
|
82 |
* @param sink The current degree of the Effect. |
|
83 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
84 |
* @param region Region that masks the Effect. |
|
85 |
*/ |
|
86 |
public VertexEffectSink(Data1D sink, Data3D center, Data4D region) |
|
87 |
{ |
|
88 |
super(EffectName.SINK); |
|
89 |
mSink = sink; |
|
90 |
mCenter = center; |
|
91 |
mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); |
|
92 |
} |
|
93 |
|
|
94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
95 |
/** |
|
96 |
* Pull all points around the center of the Effect towards the center point(if degree>=1) or push them |
|
97 |
* away from it (degree<=1) |
|
98 |
* |
|
99 |
* @param sink The current degree of the Effect. |
|
100 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
101 |
*/ |
|
102 |
public VertexEffectSink(Data1D sink, Data3D center) |
|
103 |
{ |
|
104 |
super(EffectName.SINK); |
|
105 |
mSink = sink; |
|
106 |
mCenter = center; |
|
107 |
mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
108 |
} |
|
97 | 109 |
} |
Also available in: Unified diff
Javadoc.