Revision 1585ba24
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
37 | 37 |
import org.distorted.library.effect.VertexEffectSwirl; |
38 | 38 |
import org.distorted.library.main.DistortedEffects; |
39 | 39 |
import org.distorted.library.type.Dynamic3D; |
40 |
import org.distorted.library.type.Dynamic4D; |
|
41 | 40 |
import org.distorted.library.type.Static1D; |
42 | 41 |
import org.distorted.library.type.Static3D; |
43 | 42 |
import org.distorted.library.type.Static4D; |
... | ... | |
58 | 57 |
|
59 | 58 |
private static final Object lock = new Object(); |
60 | 59 |
|
61 |
private Dynamic3D mCenterVertex;
|
|
60 |
private Dynamic3D mCenter; |
|
62 | 61 |
private Static4D mRegionVertex; |
63 |
private Dynamic4D mRegionFragment;
|
|
62 |
private Static3D mRegionFragment;
|
|
64 | 63 |
|
65 | 64 |
private Paint mPaint; |
66 | 65 |
private int moving; |
67 | 66 |
private long mTime = 0; |
68 | 67 |
|
69 | 68 |
private int mCurrEffect; |
70 |
private int mSize1, mSize2, mSizeR;
|
|
69 |
private int mSize1, mSize2; |
|
71 | 70 |
private Static3D mDistort; |
72 | 71 |
|
73 | 72 |
private MovingEffectsRenderer mRenderer; |
... | ... | |
89 | 88 |
mPaint.setStyle(Style.FILL); |
90 | 89 |
moving = -1; |
91 | 90 |
|
92 |
mCenterVertex = new Dynamic3D(LOOP_TIME,0.0f);
|
|
93 |
mRegionFragment = new Dynamic4D(LOOP_TIME,0.0f);
|
|
91 |
mCenter = new Dynamic3D(LOOP_TIME,0.0f);
|
|
92 |
mRegionFragment = new Static3D(0,0,0);
|
|
94 | 93 |
mRegionVertex = new Static4D(0,0,0,0); |
95 | 94 |
mDistort = new Static3D(0,0,0); |
96 | 95 |
|
... | ... | |
105 | 104 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
106 | 105 |
setRenderer(mRenderer); |
107 | 106 |
|
108 |
mEffectDistort = new VertexEffectDistort( mDistort , mCenterVertex, mRegionVertex);
|
|
109 |
mEffectSink = new VertexEffectSink(new Static1D(10), mCenterVertex, mRegionVertex);
|
|
110 |
mEffectSwirl = new VertexEffectSwirl( new Static1D(30), mCenterVertex, mRegionVertex);
|
|
111 |
mEffectAlpha = new FragmentEffectAlpha(new Static1D(0.5f), mRegionFragment, true);
|
|
112 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mRegionFragment, true); |
|
107 |
mEffectDistort = new VertexEffectDistort ( mDistort , mCenter, mRegionVertex);
|
|
108 |
mEffectSink = new VertexEffectSink (new Static1D(10) , mCenter, mRegionVertex);
|
|
109 |
mEffectSwirl = new VertexEffectSwirl (new Static1D(30) , mCenter, mRegionVertex);
|
|
110 |
mEffectAlpha = new FragmentEffectAlpha (new Static1D(0.5f), mCenter, mRegionFragment, true);
|
|
111 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mCenter, mRegionFragment, true);
|
|
113 | 112 |
} |
114 | 113 |
} |
115 | 114 |
|
... | ... | |
121 | 120 |
|
122 | 121 |
mSize1 = max/200; |
123 | 122 |
mSize2 = max/80; |
124 |
mSizeR = max/6;
|
|
123 |
int rad= max/6;
|
|
125 | 124 |
|
126 |
mRegionVertex.set(0,0,0,mSizeR); |
|
125 |
mRegionVertex.set(0,0,0,rad); |
|
126 |
mRegionFragment.set(rad,rad,rad); |
|
127 | 127 |
mDistort.set3(max/10); |
128 | 128 |
} |
129 | 129 |
|
... | ... | |
223 | 223 |
DistortedEffects q = mRenderer.getEffects(); |
224 | 224 |
q.abortByType(EffectType.VERTEX); |
225 | 225 |
q.abortByType(EffectType.FRAGMENT); |
226 |
mCenterVertex.removeAll(); |
|
227 |
mRegionFragment.removeAll(); |
|
226 |
mCenter.removeAll(); |
|
228 | 227 |
mCurrEffect = EFFECT_POINTS; |
229 | 228 |
mRenderer.setRefresh(); |
230 | 229 |
} |
... | ... | |
236 | 235 |
{ |
237 | 236 |
synchronized(lock) |
238 | 237 |
{ |
239 |
int len = mCenterVertex.getNumPoints();
|
|
238 |
int len = mCenter.getNumPoints(); |
|
240 | 239 |
|
241 | 240 |
float[] drawCoord = new float[3]; |
242 | 241 |
Static3D cu; |
... | ... | |
248 | 247 |
for(int i=0; i<NUM_POINTS; i++) |
249 | 248 |
{ |
250 | 249 |
mPaint.setColor( 0xffffffff ); |
251 |
mCenterVertex.get( drawCoord, 0, (long)(i*step) );
|
|
250 |
mCenter.get( drawCoord, 0, (long)(i*step) ); |
|
252 | 251 |
c.drawCircle(drawCoord[0], drawCoord[1], mSize1, mPaint ); |
253 | 252 |
} |
254 | 253 |
} |
... | ... | |
257 | 256 |
|
258 | 257 |
for(int curr=0; curr<len; curr++) |
259 | 258 |
{ |
260 |
cu = mCenterVertex.getPoint(curr);
|
|
259 |
cu = mCenter.getPoint(curr); |
|
261 | 260 |
c.drawCircle(cu.get1(), cu.get2(), mSize2, mPaint); |
262 | 261 |
} |
263 | 262 |
|
... | ... | |
280 | 279 |
|
281 | 280 |
float gx, gy; |
282 | 281 |
Static3D dv; |
283 |
int len = mCenterVertex.getNumPoints();
|
|
282 |
int len = mCenter.getNumPoints(); |
|
284 | 283 |
|
285 | 284 |
for(int g=0; g<len; g++) |
286 | 285 |
{ |
287 |
dv = mCenterVertex.getPoint(g);
|
|
286 |
dv = mCenter.getPoint(g); |
|
288 | 287 |
gx = dv.get1(); |
289 | 288 |
gy = dv.get2(); |
290 | 289 |
|
... | ... | |
300 | 299 |
{ |
301 | 300 |
synchronized(lock) |
302 | 301 |
{ |
303 |
mCenterVertex.add(new Static3D(xDown,yDown,0)); |
|
304 |
mRegionFragment.add(new Static4D(xDown,yDown,mSizeR,mSizeR)); |
|
302 |
mCenter.add(new Static3D(xDown,yDown,0)); |
|
305 | 303 |
} |
306 | 304 |
} |
307 | 305 |
mRenderer.setRefresh(); |
... | ... | |
311 | 309 |
xDown = (int)event.getX(); |
312 | 310 |
yDown = (int)event.getY(); |
313 | 311 |
|
314 |
mCenterVertex.setPoint(moving, xDown, yDown, 0); |
|
315 |
mRegionFragment.setPoint(moving, xDown, yDown, mSizeR, mSizeR); |
|
312 |
mCenter.setPoint(moving, xDown, yDown, 0); |
|
316 | 313 |
} |
317 | 314 |
mRenderer.setRefresh(); |
318 | 315 |
break; |
Also available in: Unified diff
Make the Fragment effects truly 3D: change their 4D 'region' into a 3D 'center' (a point in 3D) and 3D 'region' (which is now a set of 3 radii defining an ellipsoid around the center)
Also corresponding changes to the applications.