Revision 0273ef2a
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java | ||
|---|---|---|
| 183 | 183 |
|
| 184 | 184 |
int radius = (int)(uniforms[index+1]*mQualityScale); |
| 185 | 185 |
if( radius>=MAX_RADIUS ) radius = MAX_RADIUS-1; |
| 186 |
if( radius<=0 ) radius = 1; |
|
| 186 | 187 |
computeGaussianKernel(radius); |
| 187 | 188 |
|
| 188 | 189 |
int offset = radius + radius*radius/4; |
| src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
|---|---|---|
| 186 | 186 |
|
| 187 | 187 |
int radius = (int)(uniforms[index+1]*mQualityScale); |
| 188 | 188 |
if( radius>=MAX_RADIUS ) radius = MAX_RADIUS-1; |
| 189 |
if( radius<=0 ) radius = 1; |
|
| 189 | 190 |
computeGaussianKernel(radius); |
| 190 | 191 |
|
| 191 | 192 |
int offset = radius + radius*radius/4; |
| src/main/java/org/distorted/library/effect/VertexEffectWave.java | ||
|---|---|---|
| 51 | 51 |
mRegion.get(uniforms,index+REGION_OFFSET,currentDuration,step); |
| 52 | 52 |
boolean ret = mWave.get(uniforms,index+VALUES_OFFSET,currentDuration,step); |
| 53 | 53 |
|
| 54 |
uniforms[index+VALUES_OFFSET+2] = (float)(Math.PI*uniforms[index+2]/180); |
|
| 55 |
uniforms[index+VALUES_OFFSET+3] = (float)(Math.PI*uniforms[index+3]/180); |
|
| 56 |
uniforms[index+VALUES_OFFSET+4] = (float)(Math.PI*uniforms[index+4]/180); |
|
| 54 |
uniforms[index+VALUES_OFFSET+2] = (float)(Math.PI*uniforms[index+VALUES_OFFSET+2]/180);
|
|
| 55 |
uniforms[index+VALUES_OFFSET+3] = (float)(Math.PI*uniforms[index+VALUES_OFFSET+3]/180);
|
|
| 56 |
uniforms[index+VALUES_OFFSET+4] = (float)(Math.PI*uniforms[index+VALUES_OFFSET+4]/180);
|
|
| 57 | 57 |
|
| 58 | 58 |
return ret; |
| 59 | 59 |
} |
| src/main/java/org/distorted/library/effectqueue/EffectQueue.java | ||
|---|---|---|
| 48 | 48 |
private int mNumEffectsToBe; // added them yet (or less if it hasn't removed some yet) |
| 49 | 49 |
float[] mUniforms; |
| 50 | 50 |
private int mNumUniforms; |
| 51 |
long[] mCurrentDuration; |
|
| 52 | 51 |
Effect[] mEffects; |
| 53 | 52 |
int[] mName; |
| 54 | 53 |
int[] mAndAssociation; |
| ... | ... | |
| 141 | 140 |
if( max>0 ) |
| 142 | 141 |
{
|
| 143 | 142 |
mUniforms = new float[max*source.mNumUniforms]; |
| 144 |
mCurrentDuration = new long[max]; |
|
| 145 | 143 |
mEffects = new Effect[max]; |
| 146 | 144 |
mName = new int[max]; |
| 147 | 145 |
mAndAssociation = new int[max]; |
| ... | ... | |
| 151 | 149 |
for(int i=0; i<mNumEffects; i++ ) |
| 152 | 150 |
{
|
| 153 | 151 |
mEffects[i] = source.mEffects[i]; |
| 154 |
mCurrentDuration[i] = source.mCurrentDuration[i]; |
|
| 155 | 152 |
mName[i] = source.mName[i]; |
| 156 | 153 |
mAndAssociation[i] = source.mAndAssociation[i]; |
| 157 | 154 |
mEquAssociation[i] = source.mEquAssociation[i]; |
| ... | ... | |
| 281 | 278 |
for(int j=effect; j<mNumEffects; j++ ) |
| 282 | 279 |
{
|
| 283 | 280 |
mEffects[j] = mEffects[j+1]; |
| 284 |
mCurrentDuration[j] = mCurrentDuration[j+1]; |
|
| 285 | 281 |
mName[j] = mName[j+1]; |
| 286 | 282 |
mAndAssociation[j] = mAndAssociation[j+1]; |
| 287 | 283 |
mEquAssociation[j] = mEquAssociation[j+1]; |
| ... | ... | |
| 439 | 435 |
if( max>0 ) |
| 440 | 436 |
{
|
| 441 | 437 |
mUniforms = new float[max*job.num]; |
| 442 |
mCurrentDuration = new long[max]; |
|
| 443 | 438 |
mEffects = new Effect[max]; |
| 444 | 439 |
mName = new int[max]; |
| 445 | 440 |
mAndAssociation = new int[max]; |
| ... | ... | |
| 454 | 449 |
|
| 455 | 450 |
if( position==-1 ) |
| 456 | 451 |
{
|
| 457 |
mCurrentDuration[mNumEffects]= 0; |
|
| 458 | 452 |
mEffects[mNumEffects] = job.effect; |
| 459 | 453 |
mName[mNumEffects] = job.effect.getName().ordinal(); |
| 460 | 454 |
mAndAssociation[mNumEffects] = job.effect.getAndAssociation(); |
| ... | ... | |
| 467 | 461 |
{
|
| 468 | 462 |
for(int j=mNumEffects; j>position; j--) |
| 469 | 463 |
{
|
| 470 |
mCurrentDuration[j] = mCurrentDuration[j-1]; |
|
| 471 | 464 |
mEffects[j] = mEffects[j-1]; |
| 472 | 465 |
mName[j] = mName[j-1]; |
| 473 | 466 |
mAndAssociation[j] = mAndAssociation[j-1]; |
| 474 | 467 |
mEquAssociation[j] = mEquAssociation[j-1]; |
| 475 | 468 |
} |
| 476 | 469 |
|
| 477 |
mCurrentDuration[position]= 0; |
|
| 478 | 470 |
mEffects[position] = job.effect; |
| 479 | 471 |
mName[position] = job.effect.getName().ordinal(); |
| 480 | 472 |
mAndAssociation[position] = job.effect.getAndAssociation(); |
| src/main/java/org/distorted/library/effectqueue/EffectQueueFragment.java | ||
|---|---|---|
| 69 | 69 |
|
| 70 | 70 |
for(int i=0; i<mNumEffects; i++) |
| 71 | 71 |
{
|
| 72 |
mCurrentDuration[i] += step; |
|
| 73 |
|
|
| 74 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) ) |
|
| 72 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, currTime, step) ) |
|
| 75 | 73 |
{
|
| 76 | 74 |
EffectMessageSender.newMessage(mEffects[i]); |
| 77 | 75 |
} |
| src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java | ||
|---|---|---|
| 72 | 72 |
|
| 73 | 73 |
for(int i=0; i<mNumEffects; i++) |
| 74 | 74 |
{
|
| 75 |
mCurrentDuration[i] += step; |
|
| 76 |
|
|
| 77 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) ) |
|
| 75 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, currTime, step) ) |
|
| 78 | 76 |
{
|
| 79 | 77 |
EffectMessageSender.newMessage(mEffects[i]); |
| 80 | 78 |
} |
| src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java | ||
|---|---|---|
| 85 | 85 |
|
| 86 | 86 |
for(int i=0; i<mNumEffects; i++) |
| 87 | 87 |
{
|
| 88 |
mCurrentDuration[i] += step; |
|
| 89 |
|
|
| 90 | 88 |
// first zero out the 'alpha' because BLUR effect will not overwrite this (it is a 1D effect) |
| 91 | 89 |
// and if previously there was a GLOW effect here then mA would be non-zero and we don't want |
| 92 | 90 |
// that (see preprocess()) |
| 93 | 91 |
mUniforms[NUM_UNIFORMS*i+5]=0.0f; |
| 94 | 92 |
|
| 95 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) )
|
|
| 93 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, currTime, step) )
|
|
| 96 | 94 |
{
|
| 97 | 95 |
EffectMessageSender.newMessage(mEffects[i]); |
| 98 | 96 |
} |
| src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java | ||
|---|---|---|
| 83 | 83 |
|
| 84 | 84 |
for(int i=0; i<mNumEffects; i++) |
| 85 | 85 |
{
|
| 86 |
mCurrentDuration[i] += step; |
|
| 87 | 86 |
mAndAssociation[i] = mEffects[i].getAndAssociation(); |
| 88 | 87 |
mEquAssociation[i] = mEffects[i].getEquAssociation(); |
| 89 | 88 |
|
| 90 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) )
|
|
| 89 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, currTime, step) )
|
|
| 91 | 90 |
{
|
| 92 | 91 |
EffectMessageSender.newMessage(mEffects[i]); |
| 93 | 92 |
} |
| src/main/java/org/distorted/library/main/DistortedLibrary.java | ||
|---|---|---|
| 41 | 41 |
import org.distorted.library.message.EffectMessageSender; |
| 42 | 42 |
import org.distorted.library.program.DistortedProgram; |
| 43 | 43 |
import org.distorted.library.program.VertexCompilationException; |
| 44 |
import org.distorted.library.type.Dynamic; |
|
| 44 | 45 |
|
| 45 | 46 |
import java.io.InputStream; |
| 46 | 47 |
import java.nio.ByteBuffer; |
| ... | ... | |
| 1032 | 1033 |
public static void onPause() |
| 1033 | 1034 |
{
|
| 1034 | 1035 |
InternalObject.onPause(); |
| 1035 |
|
|
| 1036 |
Dynamic.onPause(); |
|
| 1036 | 1037 |
mLinkedListSSBO[0]= -1; |
| 1037 | 1038 |
mAtomicCounter = null; |
| 1038 | 1039 |
} |
| src/main/java/org/distorted/library/type/Dynamic.java | ||
|---|---|---|
| 157 | 157 |
private static Random mRnd = new Random(); |
| 158 | 158 |
private static final int NUM_NOISE = 5; // used iff mNoise>0.0. Number of intermediary points between each pair of adjacent vectors |
| 159 | 159 |
// where we randomize noise factors to make the way between the two vectors not so smooth. |
| 160 |
private long mTimeOffset;
|
|
| 161 |
private boolean mSetOffset;
|
|
| 160 |
private long mStartTime;
|
|
| 161 |
private static long mPausedTime;
|
|
| 162 | 162 |
|
| 163 | 163 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 164 | 164 |
// hide this from Javadoc |
| ... | ... | |
| 184 | 184 |
mLastPos = -1; |
| 185 | 185 |
mAccessType= ACCESS_TYPE_RANDOM; |
| 186 | 186 |
mConvexity = 1.0f; |
| 187 |
|
|
| 188 |
mTimeOffset= 0; |
|
| 189 |
mSetOffset = true; |
|
| 187 |
mStartTime = 0; |
|
| 190 | 188 |
|
| 191 | 189 |
baseV = new float[mDimension][mDimension]; |
| 192 | 190 |
buf = new float[mDimension]; |
| 193 | 191 |
old = new float[mDimension]; |
| 194 | 192 |
} |
| 195 | 193 |
|
| 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 195 |
|
|
| 196 |
public static void onPause() |
|
| 197 |
{
|
|
| 198 |
mPausedTime = System.currentTimeMillis(); |
|
| 199 |
} |
|
| 200 |
|
|
| 196 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 197 | 202 |
|
| 198 | 203 |
protected float noise(float time,int vecNum) |
| ... | ... | |
| 580 | 585 |
*/ |
| 581 | 586 |
public void resetToBeginning() |
| 582 | 587 |
{
|
| 583 |
mSetOffset = true;
|
|
| 588 |
mStartTime = 0;
|
|
| 584 | 589 |
} |
| 585 | 590 |
|
| 586 | 591 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 655 | 660 |
return mDimension; |
| 656 | 661 |
} |
| 657 | 662 |
|
| 658 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 659 |
/** |
|
| 660 |
* Writes the results of interpolation between the Points at time 'time' to the passed float buffer. |
|
| 661 |
* |
|
| 662 |
* @param buffer Float buffer we will write the results to. |
|
| 663 |
* @param offset Offset in the buffer where to write the result. |
|
| 664 |
* @param time Time of interpolation. Time=0.0 is the beginning of the first revolution, time=1.0 - the end |
|
| 665 |
* of the first revolution, time=2.5 - the middle of the third revolution. |
|
| 666 |
* What constitutes 'one revolution' depends on the MODE: |
|
| 667 |
* {@link Dynamic#MODE_LOOP}, {@link Dynamic#MODE_PATH} or {@link Dynamic#MODE_JUMP}.
|
|
| 668 |
*/ |
|
| 669 |
public void get(float[] buffer, int offset, long time) |
|
| 670 |
{
|
|
| 671 |
if( mDuration<=0.0f ) |
|
| 672 |
{
|
|
| 673 |
interpolate(buffer,offset,mCount-(int)mCount); |
|
| 674 |
} |
|
| 675 |
else |
|
| 676 |
{
|
|
| 677 |
if( mSetOffset ) |
|
| 678 |
{
|
|
| 679 |
mSetOffset = false; |
|
| 680 |
mTimeOffset= time; |
|
| 681 |
mLastPos = -1; |
|
| 682 |
} |
|
| 683 |
|
|
| 684 |
time -= mTimeOffset; |
|
| 685 |
|
|
| 686 |
double pos = (double)time/mDuration; |
|
| 687 |
|
|
| 688 |
if( pos<=mCount || mCount<=0.0f ) |
|
| 689 |
{
|
|
| 690 |
interpolate(buffer,offset, (float)(pos-(int)pos) ); |
|
| 691 |
} |
|
| 692 |
} |
|
| 693 |
} |
|
| 694 |
|
|
| 695 | 663 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 696 | 664 |
/** |
| 697 | 665 |
* Writes the results of interpolation between the Points at time 'time' to the passed float buffer. |
| ... | ... | |
| 717 | 685 |
return false; |
| 718 | 686 |
} |
| 719 | 687 |
|
| 720 |
if( mSetOffset )
|
|
| 688 |
if( mStartTime==0 )
|
|
| 721 | 689 |
{
|
| 722 |
mSetOffset = false; |
|
| 723 |
mTimeOffset= time; |
|
| 690 |
mStartTime = time; |
|
| 724 | 691 |
mLastPos = -1; |
| 725 | 692 |
} |
| 726 | 693 |
|
| 727 |
time -= mTimeOffset; |
|
| 694 |
long diff = time-mPausedTime; |
|
| 695 |
|
|
| 696 |
if( diff>=0 && diff<=step ) |
|
| 697 |
{
|
|
| 698 |
mStartTime += diff; |
|
| 699 |
step -= diff; |
|
| 700 |
} |
|
| 701 |
|
|
| 702 |
time -= mStartTime; |
|
| 728 | 703 |
|
| 729 | 704 |
if( time+step > mDuration*mCount && mCount>0.0f ) |
| 730 | 705 |
{
|
Also available in: Unified diff
Fixes for pausing and restarting.