Revision 8c893ffc
Added by Leszek Koltunski over 8 years ago
src/main/java/org/distorted/library/Distorted.java | ||
---|---|---|
353 | 353 |
GLES20.glDepthFunc(GLES20.GL_LEQUAL); |
354 | 354 |
GLES20.glEnable(GLES20.GL_BLEND); |
355 | 355 |
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); |
356 |
|
|
356 |
|
|
357 | 357 |
mTextureUniformH = GLES20.glGetUniformLocation(mProgramH, "u_Texture"); |
358 | 358 |
|
359 | 359 |
mPositionH = GLES20.glGetAttribLocation( mProgramH, "a_Position"); |
src/main/java/org/distorted/library/DistortedObject.java | ||
---|---|---|
587 | 587 |
* @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region. |
588 | 588 |
* @return ID of the effect added, or -1 if we failed to add one. |
589 | 589 |
*/ |
590 |
public long chroma(Data1D blend, Static3D color, Data4D region, boolean smooth)
|
|
590 |
public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
|
|
591 | 591 |
{ |
592 | 592 |
return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region); |
593 | 593 |
} |
... | ... | |
601 | 601 |
* @param color Color to mix. (1,0,0) is RED. |
602 | 602 |
* @return ID of the effect added, or -1 if we failed to add one. |
603 | 603 |
*/ |
604 |
public long chroma(Data1D blend, Static3D color)
|
|
604 |
public long chroma(Data1D blend, Data3D color)
|
|
605 | 605 |
{ |
606 | 606 |
return mF.add(EffectNames.CHROMA, blend, color); |
607 | 607 |
} |
608 | 608 |
|
609 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
610 |
/** |
|
611 |
* Makes a certain sub-region of the Object smoothly change all three of its RGB components. |
|
612 |
* |
|
613 |
* @param blendcolor 4-dimensional Data returning the 4-tuple (blend,R,G,B). |
|
614 |
* Level of blend a given pixel will be mixed with the next parameter 'color': |
|
615 |
* pixel = (1-t)*pixel + t*color |
|
616 |
* @param region Region this Effect is limited to. |
|
617 |
* @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region. |
|
618 |
* @return ID of the effect added, or -1 if we failed to add one. |
|
619 |
*/ |
|
620 |
public long chroma(Data4D blendcolor, Data4D region, boolean smooth ) |
|
621 |
{ |
|
622 |
return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blendcolor, region ); |
|
623 |
} |
|
624 |
|
|
625 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
626 |
/** |
|
627 |
* Makes the whole Object smoothly change all three of its RGB components. |
|
628 |
* |
|
629 |
* @param blendcolor 4-dimensional Data returning the 4-tuple (blend,R,G,B). |
|
630 |
* Level of blend a given pixel will be mixed with the next parameter 'color': |
|
631 |
* pixel = (1-t)*pixel + t*color |
|
632 |
* @return ID of the effect added, or -1 if we failed to add one. |
|
633 |
*/ |
|
634 |
public long chroma(Data4D blendcolor) |
|
635 |
{ |
|
636 |
return mF.add(EffectNames.CHROMA, blendcolor); |
|
637 |
} |
|
638 |
|
|
639 | 609 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
640 | 610 |
/** |
641 | 611 |
* Makes a certain sub-region of the Object smoothly change its transparency level. |
src/main/java/org/distorted/library/EffectQueueFragment.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.distorted.library.message.EffectMessage; |
25 | 25 |
import org.distorted.library.type.Data1D; |
26 |
import org.distorted.library.type.Data3D; |
|
26 | 27 |
import org.distorted.library.type.Data4D; |
27 | 28 |
import org.distorted.library.type.Dynamic1D; |
29 |
import org.distorted.library.type.Dynamic3D; |
|
28 | 30 |
import org.distorted.library.type.Dynamic4D; |
29 | 31 |
import org.distorted.library.type.Static1D; |
30 | 32 |
import org.distorted.library.type.Static3D; |
... | ... | |
90 | 92 |
} |
91 | 93 |
} |
92 | 94 |
|
93 |
if( mInter[1][i]!=null ) mInter[1][i].interpolateMain(mBuf, 4*i, mCurrentDuration[i]); |
|
95 |
if( mInter[1][i]!=null ) mInter[1][i].interpolateMain( mBuf, 4*i , mCurrentDuration[i]); |
|
96 |
|
|
97 |
if( mInter[2][i]!=null ) mInter[2][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+1, mCurrentDuration[i]); |
|
94 | 98 |
|
95 | 99 |
mCurrentDuration[i] += step; |
96 | 100 |
} |
... | ... | |
187 | 191 |
mBuf[4*mNumEffects+2] = 1000*mObjHalfX; |
188 | 192 |
mBuf[4*mNumEffects+3] = 1000*mObjHalfY; |
189 | 193 |
|
194 |
mInter[2][mNumEffects] = null; |
|
195 |
|
|
190 | 196 |
return addBase(eln); |
191 | 197 |
} |
192 | 198 |
|
... | ... | |
223 | 229 |
} |
224 | 230 |
else return -1; |
225 | 231 |
|
232 |
mInter[2][mNumEffects] = null; |
|
233 |
|
|
226 | 234 |
return addBase(eln); |
227 | 235 |
} |
228 | 236 |
|
... | ... | |
232 | 240 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
233 | 241 |
// chroma |
234 | 242 |
|
235 |
synchronized long add(EffectNames eln, Data1D level, Static3D color, Data4D region)
|
|
243 |
synchronized long add(EffectNames eln, Data1D level, Data3D color, Data4D region)
|
|
236 | 244 |
{ |
237 | 245 |
if( mMax[INDEX]>mNumEffects ) |
238 | 246 |
{ |
... | ... | |
247 | 255 |
} |
248 | 256 |
else return -1; |
249 | 257 |
|
250 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = color.getX(); |
|
251 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = color.getY(); |
|
252 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = color.getZ(); |
|
258 |
if( color instanceof Dynamic3D) |
|
259 |
{ |
|
260 |
mInter[2][mNumEffects] = (Dynamic3D)color; |
|
261 |
} |
|
262 |
else if( color instanceof Static3D ) |
|
263 |
{ |
|
264 |
mInter[2][mNumEffects] = null; |
|
265 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)color).getX(); |
|
266 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)color).getY(); |
|
267 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static3D)color).getZ(); |
|
268 |
} |
|
269 |
else return -1; |
|
253 | 270 |
|
254 | 271 |
if( region instanceof Dynamic4D) |
255 | 272 |
mInter[1][mNumEffects] = (Dynamic4D)region; |
... | ... | |
272 | 289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
273 | 290 |
// chroma |
274 | 291 |
|
275 |
synchronized long add(EffectNames eln, Data1D level, Static3D color)
|
|
292 |
synchronized long add(EffectNames eln, Data1D level, Data3D color)
|
|
276 | 293 |
{ |
277 | 294 |
if( mMax[INDEX]>mNumEffects ) |
278 | 295 |
{ |
... | ... | |
287 | 304 |
} |
288 | 305 |
else return -1; |
289 | 306 |
|
290 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = color.getX(); |
|
291 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = color.getY(); |
|
292 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = color.getZ(); |
|
293 |
|
|
294 |
mInter[1][mNumEffects] = null; // |
|
295 |
mBuf[4*mNumEffects+2] = 1000*mObjHalfX; // i.e. null region |
|
296 |
mBuf[4*mNumEffects+3] = 1000*mObjHalfY; // |
|
297 |
|
|
298 |
return addBase(eln); |
|
299 |
} |
|
300 |
|
|
301 |
return -1; |
|
302 |
} |
|
303 |
|
|
304 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
305 |
// chroma |
|
306 |
|
|
307 |
synchronized long add(EffectNames eln, Data4D chroma, Data4D region) |
|
308 |
{ |
|
309 |
if( mMax[INDEX]>mNumEffects ) |
|
310 |
{ |
|
311 |
EffectNames.fillWithUnities(eln.ordinal(), mUniforms, NUM_UNIFORMS*mNumEffects); |
|
312 |
|
|
313 |
if( chroma instanceof Dynamic4D) |
|
314 |
mInter[0][mNumEffects] = (Dynamic4D)chroma; |
|
315 |
else if( chroma instanceof Static4D ) |
|
307 |
if( color instanceof Dynamic3D) |
|
316 | 308 |
{ |
317 |
mInter[0][mNumEffects] = null; |
|
318 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static4D)chroma).getX(); |
|
319 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static4D)chroma).getY(); |
|
320 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static4D)chroma).getZ(); |
|
321 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static4D)chroma).getW(); |
|
309 |
mInter[2][mNumEffects] = (Dynamic3D)color; |
|
322 | 310 |
} |
323 |
else return -1; |
|
324 |
|
|
325 |
if( region instanceof Dynamic4D) |
|
326 |
mInter[1][mNumEffects] = (Dynamic4D)region; |
|
327 |
else if( region instanceof Static4D ) |
|
328 |
{ |
|
329 |
mInter[1][mNumEffects] = null; |
|
330 |
mBuf[4*mNumEffects ] = ((Static4D)region).getX(); |
|
331 |
mBuf[4*mNumEffects+1] = ((Static4D)region).getY(); |
|
332 |
mBuf[4*mNumEffects+2] = ((Static4D)region).getZ(); |
|
333 |
mBuf[4*mNumEffects+3] = ((Static4D)region).getW(); |
|
334 |
} |
|
335 |
else return -1; |
|
336 |
|
|
337 |
return addBase(eln); |
|
338 |
} |
|
339 |
|
|
340 |
return -1; |
|
341 |
} |
|
342 |
|
|
343 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
344 |
// chroma |
|
345 |
|
|
346 |
synchronized long add(EffectNames eln, Data4D chroma) |
|
347 |
{ |
|
348 |
if( mMax[INDEX]>mNumEffects ) |
|
349 |
{ |
|
350 |
EffectNames.fillWithUnities(eln.ordinal(), mUniforms, NUM_UNIFORMS*mNumEffects); |
|
351 |
|
|
352 |
if( chroma instanceof Dynamic4D) |
|
353 |
mInter[0][mNumEffects] = (Dynamic4D)chroma; |
|
354 |
else if( chroma instanceof Static4D ) |
|
311 |
else if( color instanceof Static3D ) |
|
355 | 312 |
{ |
356 |
mInter[0][mNumEffects] = null; |
|
357 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static4D)chroma).getX(); |
|
358 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static4D)chroma).getY(); |
|
359 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static4D)chroma).getZ(); |
|
360 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static4D)chroma).getW(); |
|
313 |
mInter[2][mNumEffects] = null; |
|
314 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)color).getX(); |
|
315 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)color).getY(); |
|
316 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static3D)color).getZ(); |
|
361 | 317 |
} |
362 | 318 |
else return -1; |
363 | 319 |
|
... | ... | |
367 | 323 |
|
368 | 324 |
return addBase(eln); |
369 | 325 |
} |
370 |
|
|
326 |
|
|
371 | 327 |
return -1; |
372 | 328 |
} |
373 |
|
|
329 |
|
|
374 | 330 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
375 | 331 |
// end of FragmentEffect |
376 | 332 |
} |
src/main/java/org/distorted/library/type/Dynamic.java | ||
---|---|---|
73 | 73 |
protected int mVecCurr; |
74 | 74 |
protected boolean cacheDirty; // VectorCache not up to date |
75 | 75 |
protected int mMode; // LOOP, PATH or JUMP |
76 |
protected long mDuration; // number of miliseconds it takes to do a full loop/path from first vector to the last and back to the first
|
|
76 |
protected long mDuration; // number of milliseconds it takes to do a full loop/path from first vector to the last and back to the first
|
|
77 | 77 |
protected float mCount; // number of loops/paths we will do; mCount = 1.5 means we go from the first vector to the last, back to first, and to the last again. |
78 | 78 |
protected float mNoise; // how 'smooth' our path form each vector to the next is. mNoise = 0.0 (min) --> completely smooth; mNoise==1.0 (max) --> very uneven |
79 | 79 |
|
... | ... | |
83 | 83 |
Dynamic() |
84 | 84 |
{ |
85 | 85 |
} |
86 |
|
|
86 |
|
|
87 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
88 | 88 |
|
89 | 89 |
public void interpolateMain(float[] buffer, int offset, long currentDuration) |
... | ... | |
145 | 145 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
146 | 146 |
// PUBLIC API |
147 | 147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
148 |
|
|
148 | 149 |
/** |
149 | 150 |
* Sets the mode of the interpolation to Loop, Path or Jump. |
150 | 151 |
* <ul> |
src/main/java/org/distorted/library/type/Dynamic1D.java | ||
---|---|---|
212 | 212 |
*/ |
213 | 213 |
public Dynamic1D() |
214 | 214 |
{ |
215 |
vv = new Vector<Static1D>();
|
|
216 |
vc = new Vector<VectorCache>();
|
|
215 |
vv = new Vector<>(); |
|
216 |
vc = new Vector<>(); |
|
217 | 217 |
vn = null; |
218 | 218 |
numPoints = 0; |
219 | 219 |
cacheDirty = false; |
... | ... | |
221 | 221 |
mDuration = 0; |
222 | 222 |
mCount = 0.5f; |
223 | 223 |
} |
224 |
|
|
224 |
|
|
225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
226 |
|
|
227 |
/** |
|
228 |
* Default constructor. |
|
229 |
* |
|
230 |
* @param duration number of milliseconds it takes to do a full loop/path from first vector to the |
|
231 |
* last and back to the first |
|
232 |
* @param count number of loops/paths we will do; mCount = 1.5 means we go from the first vector |
|
233 |
* to the last, back to first, and to the last again. |
|
234 |
*/ |
|
235 |
public Dynamic1D(int duration, float count) |
|
236 |
{ |
|
237 |
vv = new Vector<>(); |
|
238 |
vc = new Vector<>(); |
|
239 |
vn = null; |
|
240 |
numPoints = 0; |
|
241 |
cacheDirty = false; |
|
242 |
mMode = MODE_LOOP; |
|
243 |
mDuration = duration; |
|
244 |
mCount = count; |
|
245 |
} |
|
246 |
|
|
225 | 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
226 | 248 |
/** |
227 | 249 |
* Returns the location'th Static1D. |
src/main/java/org/distorted/library/type/Dynamic2D.java | ||
---|---|---|
239 | 239 |
*/ |
240 | 240 |
public Dynamic2D() |
241 | 241 |
{ |
242 |
vv = new Vector<Static2D>();
|
|
243 |
vc = new Vector<VectorCache>();
|
|
242 |
vv = new Vector<>(); |
|
243 |
vc = new Vector<>(); |
|
244 | 244 |
vn = null; |
245 | 245 |
numPoints = 0; |
246 | 246 |
cacheDirty = false; |
... | ... | |
249 | 249 |
mCount = 0.5f; |
250 | 250 |
mNoise = 0.0f; |
251 | 251 |
} |
252 |
|
|
252 |
|
|
253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
254 |
|
|
255 |
/** |
|
256 |
* Default constructor. |
|
257 |
* |
|
258 |
* @param duration number of milliseconds it takes to do a full loop/path from first vector to the |
|
259 |
* last and back to the first |
|
260 |
* @param count number of loops/paths we will do; mCount = 1.5 means we go from the first vector |
|
261 |
* to the last, back to first, and to the last again. |
|
262 |
*/ |
|
263 |
public Dynamic2D(int duration, float count) |
|
264 |
{ |
|
265 |
vv = new Vector<>(); |
|
266 |
vc = new Vector<>(); |
|
267 |
vn = null; |
|
268 |
numPoints = 0; |
|
269 |
cacheDirty = false; |
|
270 |
mMode = MODE_LOOP; |
|
271 |
mDuration = duration; |
|
272 |
mCount = count; |
|
273 |
} |
|
274 |
|
|
253 | 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
254 | 276 |
/** |
255 | 277 |
* Returns the location'th Static2D. |
src/main/java/org/distorted/library/type/Dynamic3D.java | ||
---|---|---|
350 | 350 |
*/ |
351 | 351 |
public Dynamic3D() |
352 | 352 |
{ |
353 |
vv = new Vector<Static3D>();
|
|
354 |
vc = new Vector<VectorCache>();
|
|
353 |
vv = new Vector<>(); |
|
354 |
vc = new Vector<>(); |
|
355 | 355 |
vn = null; |
356 | 356 |
numPoints = 0; |
357 | 357 |
cacheDirty = false; |
... | ... | |
360 | 360 |
mCount = 0.5f; |
361 | 361 |
mNoise = 0.0f; |
362 | 362 |
} |
363 |
|
|
363 |
|
|
364 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
365 |
|
|
366 |
/** |
|
367 |
* Default constructor. |
|
368 |
* |
|
369 |
* @param duration number of milliseconds it takes to do a full loop/path from first vector to the |
|
370 |
* last and back to the first |
|
371 |
* @param count number of loops/paths we will do; mCount = 1.5 means we go from the first vector |
|
372 |
* to the last, back to first, and to the last again. |
|
373 |
*/ |
|
374 |
public Dynamic3D(int duration, float count) |
|
375 |
{ |
|
376 |
vv = new Vector<>(); |
|
377 |
vc = new Vector<>(); |
|
378 |
vn = null; |
|
379 |
numPoints = 0; |
|
380 |
cacheDirty = false; |
|
381 |
mMode = MODE_LOOP; |
|
382 |
mDuration = duration; |
|
383 |
mCount = count; |
|
384 |
} |
|
385 |
|
|
364 | 386 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
365 | 387 |
/** |
366 | 388 |
* Returns the location'th Static3D. |
src/main/java/org/distorted/library/type/Dynamic4D.java | ||
---|---|---|
446 | 446 |
*/ |
447 | 447 |
public Dynamic4D() |
448 | 448 |
{ |
449 |
vv = new Vector<Static4D>();
|
|
450 |
vc = new Vector<VectorCache>();
|
|
449 |
vv = new Vector<>(); |
|
450 |
vc = new Vector<>(); |
|
451 | 451 |
vn = null; |
452 | 452 |
numPoints = 0; |
453 | 453 |
cacheDirty = false; |
... | ... | |
456 | 456 |
mCount = 0.5f; |
457 | 457 |
mNoise = 0.0f; |
458 | 458 |
} |
459 |
|
|
459 |
|
|
460 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
461 |
|
|
462 |
/** |
|
463 |
* Default constructor. |
|
464 |
* |
|
465 |
* @param duration number of milliseconds it takes to do a full loop/path from first vector to the |
|
466 |
* last and back to the first |
|
467 |
* @param count number of loops/paths we will do; mCount = 1.5 means we go from the first vector |
|
468 |
* to the last, back to first, and to the last again. |
|
469 |
*/ |
|
470 |
public Dynamic4D(int duration, float count) |
|
471 |
{ |
|
472 |
vv = new Vector<>(); |
|
473 |
vc = new Vector<>(); |
|
474 |
vn = null; |
|
475 |
numPoints = 0; |
|
476 |
cacheDirty = false; |
|
477 |
mMode = MODE_LOOP; |
|
478 |
mDuration = duration; |
|
479 |
mCount = count; |
|
480 |
} |
|
481 |
|
|
460 | 482 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
461 | 483 |
/** |
462 | 484 |
* Returns the location'th Static4D. |
src/main/java/org/distorted/library/type/DynamicQuat.java | ||
---|---|---|
118 | 118 |
*/ |
119 | 119 |
public DynamicQuat() |
120 | 120 |
{ |
121 |
vv = new Vector<Static4D>();
|
|
122 |
vc = new Vector<VectorCache>();
|
|
121 |
vv = new Vector<>(); |
|
122 |
vc = new Vector<>(); |
|
123 | 123 |
numPoints = 0; |
124 | 124 |
cacheDirty = false; |
125 | 125 |
mMode = MODE_LOOP; |
... | ... | |
127 | 127 |
mCount = 0.5f; |
128 | 128 |
mNoise = 0.0f; |
129 | 129 |
} |
130 |
|
|
130 |
|
|
131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
132 |
|
|
133 |
/** |
|
134 |
* Default constructor. |
|
135 |
* |
|
136 |
* @param duration number of milliseconds it takes to do a full loop/path from first vector to the |
|
137 |
* last and back to the first |
|
138 |
* @param count number of loops/paths we will do; mCount = 1.5 means we go from the first vector |
|
139 |
* to the last, back to first, and to the last again. |
|
140 |
*/ |
|
141 |
public DynamicQuat(int duration, float count) |
|
142 |
{ |
|
143 |
vv = new Vector<>(); |
|
144 |
vc = new Vector<>(); |
|
145 |
numPoints = 0; |
|
146 |
cacheDirty = false; |
|
147 |
mMode = MODE_LOOP; |
|
148 |
mDuration = duration; |
|
149 |
mCount = count; |
|
150 |
mNoise = 0.0f; |
|
151 |
} |
|
152 |
|
|
131 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
132 | 154 |
/** |
133 | 155 |
* Returns the location'th Static4D. |
Also available in: Unified diff
Further reduce the distortedObject's API - now only 26 methods, 1/4 of the 104 before the reorganization.