Revision 15aa7d94
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/library/effect/Effect.java | ||
|---|---|---|
| 40 | 40 |
public static final int LENGTH = 4; // The number of effect types above. |
| 41 | 41 |
public static final int MASK= (1<<LENGTH)-1; // Needed when we do bitwise operations on Effect Types. |
| 42 | 42 |
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
|
|
| 45 |
public abstract boolean compute(float[] uniforms, int index, long currentDuration, long step ); |
|
| 46 |
|
|
| 43 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 48 |
|
| 45 | 49 |
public static void onDestroy() |
| src/main/java/org/distorted/library/effect/FragmentEffect.java | ||
|---|---|---|
| 29 | 29 |
|
| 30 | 30 |
public abstract class FragmentEffect extends Effect |
| 31 | 31 |
{
|
| 32 |
public static final int NUM_UNIFORMS = 8; |
|
| 33 |
|
|
| 32 | 34 |
public static final int CHROMA = 0; |
| 33 | 35 |
public static final int SMOOTH_CHROMA = 1; |
| 34 | 36 |
public static final int ALPHA = 2; |
| src/main/java/org/distorted/library/effect/FragmentEffectAlpha.java | ||
|---|---|---|
| 66 | 66 |
mStatic0 = (Static1D)alpha; |
| 67 | 67 |
} |
| 68 | 68 |
} |
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 73 |
{
|
|
| 74 |
if( mDynamic0!=null ) |
|
| 75 |
{
|
|
| 76 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 77 |
} |
|
| 78 |
else |
|
| 79 |
{
|
|
| 80 |
uniforms[index] = ((Static1D)mStatic0).getX(); |
|
| 81 |
return false; |
|
| 82 |
} |
|
| 83 |
} |
|
| 69 | 84 |
} |
| src/main/java/org/distorted/library/effect/FragmentEffectBrightness.java | ||
|---|---|---|
| 66 | 66 |
mStatic0 = (Static1D)brightness; |
| 67 | 67 |
} |
| 68 | 68 |
} |
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 73 |
{
|
|
| 74 |
if( mDynamic0!=null ) |
|
| 75 |
{
|
|
| 76 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 77 |
} |
|
| 78 |
else |
|
| 79 |
{
|
|
| 80 |
uniforms[index] = ((Static1D)mStatic0).getX(); |
|
| 81 |
return false; |
|
| 82 |
} |
|
| 83 |
} |
|
| 69 | 84 |
} |
| src/main/java/org/distorted/library/effect/FragmentEffectChroma.java | ||
|---|---|---|
| 87 | 87 |
mStatic1 = (Static3D)color; |
| 88 | 88 |
} |
| 89 | 89 |
} |
| 90 |
|
|
| 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 92 |
|
|
| 93 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 94 |
{
|
|
| 95 |
if( mDynamic1!=null ) |
|
| 96 |
{
|
|
| 97 |
mDynamic1.interpolateMain(uniforms,index+1,currentDuration,step); |
|
| 98 |
} |
|
| 99 |
else |
|
| 100 |
{
|
|
| 101 |
uniforms[index+1] = ((Static3D)mStatic1).getX(); |
|
| 102 |
uniforms[index+2] = ((Static3D)mStatic1).getY(); |
|
| 103 |
uniforms[index+3] = ((Static3D)mStatic1).getZ(); |
|
| 104 |
} |
|
| 105 |
|
|
| 106 |
if( mDynamic0!=null ) |
|
| 107 |
{
|
|
| 108 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 109 |
} |
|
| 110 |
else |
|
| 111 |
{
|
|
| 112 |
uniforms[index ] = ((Static1D)mStatic0).getX(); |
|
| 113 |
return false; |
|
| 114 |
} |
|
| 115 |
} |
|
| 90 | 116 |
} |
| src/main/java/org/distorted/library/effect/FragmentEffectContrast.java | ||
|---|---|---|
| 66 | 66 |
mStatic0 = (Static1D)contrast; |
| 67 | 67 |
} |
| 68 | 68 |
} |
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 73 |
{
|
|
| 74 |
if( mDynamic0!=null ) |
|
| 75 |
{
|
|
| 76 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 77 |
} |
|
| 78 |
else |
|
| 79 |
{
|
|
| 80 |
uniforms[index] = ((Static1D)mStatic0).getX(); |
|
| 81 |
return false; |
|
| 82 |
} |
|
| 83 |
} |
|
| 69 | 84 |
} |
| src/main/java/org/distorted/library/effect/FragmentEffectSaturation.java | ||
|---|---|---|
| 66 | 66 |
mStatic0 = (Static1D)saturation; |
| 67 | 67 |
} |
| 68 | 68 |
} |
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 73 |
{
|
|
| 74 |
if( mDynamic0!=null ) |
|
| 75 |
{
|
|
| 76 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 77 |
} |
|
| 78 |
else |
|
| 79 |
{
|
|
| 80 |
uniforms[index] = ((Static1D)mStatic0).getX(); |
|
| 81 |
return false; |
|
| 82 |
} |
|
| 83 |
} |
|
| 69 | 84 |
} |
| src/main/java/org/distorted/library/effect/MatrixEffect.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
public abstract class MatrixEffect extends Effect |
| 29 | 29 |
{
|
| 30 |
public static final int NUM_UNIFORMS = 7; |
|
| 31 |
|
|
| 30 | 32 |
public static final int MOVE = 0; |
| 31 | 33 |
public static final int SCALE = 1; |
| 32 | 34 |
public static final int ROTATE = 2; |
| ... | ... | |
| 39 | 41 |
|
| 40 | 42 |
Dynamic mDynamic0,mDynamic1; |
| 41 | 43 |
Static mStatic0 , mStatic1; |
| 42 |
Data3D mCenter; |
|
| 44 |
Dynamic3D mDynamicCenter; |
|
| 45 |
Static3D mStaticCenter; |
|
| 43 | 46 |
|
| 44 | 47 |
private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS]; |
| 45 | 48 |
private final static int[] mUnityDim = new int[NUM_EFFECTS]; |
| src/main/java/org/distorted/library/effect/MatrixEffectMove.java | ||
|---|---|---|
| 47 | 47 |
mDynamic0 = (Dynamic3D)vector; |
| 48 | 48 |
} |
| 49 | 49 |
} |
| 50 |
|
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 54 |
{
|
|
| 55 |
if( mDynamic0!=null ) |
|
| 56 |
{
|
|
| 57 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 58 |
} |
|
| 59 |
else |
|
| 60 |
{
|
|
| 61 |
uniforms[index ] = ((Static3D)mStatic0).getX(); |
|
| 62 |
uniforms[index+1] = ((Static3D)mStatic0).getY(); |
|
| 63 |
uniforms[index+2] = ((Static3D)mStatic0).getZ(); |
|
| 64 |
|
|
| 65 |
return false; |
|
| 66 |
} |
|
| 67 |
} |
|
| 50 | 68 |
} |
| src/main/java/org/distorted/library/effect/MatrixEffectQuaternion.java | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
import org.distorted.library.type.Data3D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 24 | 25 |
import org.distorted.library.type.Dynamic4D; |
| 26 |
import org.distorted.library.type.Static3D; |
|
| 25 | 27 |
import org.distorted.library.type.Static4D; |
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 48 | 50 |
mDynamic0 = (Dynamic4D)quaternion; |
| 49 | 51 |
} |
| 50 | 52 |
|
| 51 |
mCenter = center; |
|
| 53 |
if( center instanceof Static3D) |
|
| 54 |
{
|
|
| 55 |
mStaticCenter = (Static3D)center; |
|
| 56 |
} |
|
| 57 |
else if( center instanceof Dynamic3D) |
|
| 58 |
{
|
|
| 59 |
mDynamicCenter = (Dynamic3D)center; |
|
| 60 |
} |
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 64 |
|
|
| 65 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 66 |
{
|
|
| 67 |
if( mDynamicCenter!=null ) |
|
| 68 |
{
|
|
| 69 |
mDynamicCenter.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 70 |
} |
|
| 71 |
else |
|
| 72 |
{
|
|
| 73 |
uniforms[index+4] = mStaticCenter.getX(); |
|
| 74 |
uniforms[index+5] = mStaticCenter.getY(); |
|
| 75 |
uniforms[index+6] = mStaticCenter.getZ(); |
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
if( mDynamic0!=null ) |
|
| 79 |
{
|
|
| 80 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 81 |
} |
|
| 82 |
else |
|
| 83 |
{
|
|
| 84 |
uniforms[index ] = ((Static4D)mStatic0).getX(); |
|
| 85 |
uniforms[index+1] = ((Static4D)mStatic0).getY(); |
|
| 86 |
uniforms[index+2] = ((Static4D)mStatic0).getZ(); |
|
| 87 |
uniforms[index+3] = ((Static4D)mStatic0).getW(); |
|
| 88 |
|
|
| 89 |
return false; |
|
| 90 |
} |
|
| 52 | 91 |
} |
| 53 | 92 |
} |
| src/main/java/org/distorted/library/effect/MatrixEffectRotate.java | ||
|---|---|---|
| 23 | 23 |
import org.distorted.library.type.Data3D; |
| 24 | 24 |
import org.distorted.library.type.Data4D; |
| 25 | 25 |
import org.distorted.library.type.Dynamic1D; |
| 26 |
import org.distorted.library.type.Dynamic3D; |
|
| 26 | 27 |
import org.distorted.library.type.Dynamic4D; |
| 27 | 28 |
import org.distorted.library.type.Static1D; |
| 28 | 29 |
import org.distorted.library.type.Static3D; |
| ... | ... | |
| 53 | 54 |
} |
| 54 | 55 |
|
| 55 | 56 |
mStatic1 = axis; |
| 56 |
mCenter = center; |
|
| 57 |
|
|
| 58 |
if( center instanceof Static3D) |
|
| 59 |
{
|
|
| 60 |
mStaticCenter = (Static3D)center; |
|
| 61 |
} |
|
| 62 |
else if( center instanceof Dynamic3D ) |
|
| 63 |
{
|
|
| 64 |
mDynamicCenter = (Dynamic3D)center; |
|
| 65 |
} |
|
| 57 | 66 |
} |
| 58 | 67 |
|
| 59 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 71 | 80 |
mDynamic0 = (Dynamic4D)angleaxis; |
| 72 | 81 |
} |
| 73 | 82 |
|
| 74 |
mCenter = center; |
|
| 83 |
if( center instanceof Static3D) |
|
| 84 |
{
|
|
| 85 |
mStaticCenter = (Static3D)center; |
|
| 86 |
} |
|
| 87 |
else if( center instanceof Dynamic3D ) |
|
| 88 |
{
|
|
| 89 |
mDynamicCenter = (Dynamic3D)center; |
|
| 90 |
} |
|
| 75 | 91 |
} |
| 76 | 92 |
|
| 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 94 |
|
|
| 95 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 96 |
{
|
|
| 97 |
if( mDynamicCenter!=null ) |
|
| 98 |
{
|
|
| 99 |
mDynamicCenter.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 100 |
} |
|
| 101 |
else |
|
| 102 |
{
|
|
| 103 |
uniforms[index+4] = mStaticCenter.getX(); |
|
| 104 |
uniforms[index+5] = mStaticCenter.getY(); |
|
| 105 |
uniforms[index+6] = mStaticCenter.getZ(); |
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
if( mDynamic0!=null ) |
|
| 109 |
{
|
|
| 110 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 111 |
} |
|
| 112 |
else |
|
| 113 |
{
|
|
| 114 |
if( mStatic1 != null ) |
|
| 115 |
{
|
|
| 116 |
uniforms[index ] = ((Static1D)mStatic0).getX(); |
|
| 117 |
uniforms[index+1] = ((Static3D)mStatic1).getX(); |
|
| 118 |
uniforms[index+2] = ((Static3D)mStatic1).getY(); |
|
| 119 |
uniforms[index+3] = ((Static3D)mStatic1).getZ(); |
|
| 120 |
} |
|
| 121 |
else |
|
| 122 |
{
|
|
| 123 |
uniforms[index ] = ((Static4D)mStatic0).getX(); |
|
| 124 |
uniforms[index+1] = ((Static4D)mStatic0).getY(); |
|
| 125 |
uniforms[index+2] = ((Static4D)mStatic0).getZ(); |
|
| 126 |
uniforms[index+3] = ((Static4D)mStatic0).getW(); |
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
return false; |
|
| 130 |
} |
|
| 131 |
} |
|
| 77 | 132 |
} |
| src/main/java/org/distorted/library/effect/MatrixEffectScale.java | ||
|---|---|---|
| 56 | 56 |
|
| 57 | 57 |
mStatic0 = new Static3D(scale,scale,scale); |
| 58 | 58 |
} |
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 63 |
{
|
|
| 64 |
if( mDynamic0!=null ) |
|
| 65 |
{
|
|
| 66 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 67 |
} |
|
| 68 |
else |
|
| 69 |
{
|
|
| 70 |
uniforms[index ] = ((Static3D)mStatic0).getX(); |
|
| 71 |
uniforms[index+1] = ((Static3D)mStatic0).getY(); |
|
| 72 |
uniforms[index+2] = ((Static3D)mStatic0).getZ(); |
|
| 73 |
|
|
| 74 |
return false; |
|
| 75 |
} |
|
| 76 |
} |
|
| 59 | 77 |
} |
| src/main/java/org/distorted/library/effect/MatrixEffectShear.java | ||
|---|---|---|
| 47 | 47 |
mDynamic0 = (Dynamic3D)shear; |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
mCenter = center; |
|
| 50 |
if( center instanceof Static3D) |
|
| 51 |
{
|
|
| 52 |
mStaticCenter = (Static3D)center; |
|
| 53 |
} |
|
| 54 |
else if( center instanceof Dynamic3D ) |
|
| 55 |
{
|
|
| 56 |
mDynamicCenter = (Dynamic3D)center; |
|
| 57 |
} |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 63 |
{
|
|
| 64 |
if( mDynamicCenter!=null ) |
|
| 65 |
{
|
|
| 66 |
mDynamicCenter.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 67 |
} |
|
| 68 |
else |
|
| 69 |
{
|
|
| 70 |
uniforms[index+4] = mStaticCenter.getX(); |
|
| 71 |
uniforms[index+5] = mStaticCenter.getY(); |
|
| 72 |
uniforms[index+6] = mStaticCenter.getZ(); |
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
if( mDynamic0!=null ) |
|
| 76 |
{
|
|
| 77 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 78 |
} |
|
| 79 |
else |
|
| 80 |
{
|
|
| 81 |
uniforms[index ] = ((Static3D)mStatic0).getX(); |
|
| 82 |
uniforms[index+1] = ((Static3D)mStatic0).getY(); |
|
| 83 |
uniforms[index+2] = ((Static3D)mStatic0).getZ(); |
|
| 84 |
|
|
| 85 |
return false; |
|
| 86 |
} |
|
| 51 | 87 |
} |
| 52 | 88 |
} |
| src/main/java/org/distorted/library/effect/PostprocessEffect.java | ||
|---|---|---|
| 28 | 28 |
|
| 29 | 29 |
public abstract class PostprocessEffect extends Effect |
| 30 | 30 |
{
|
| 31 |
public static final int NUM_UNIFORMS = 5; |
|
| 32 |
|
|
| 31 | 33 |
public static final int BLUR =0; |
| 32 | 34 |
public static final int GLOW =1; |
| 33 | 35 |
public static final int NUM_EFFECTS=2; |
| src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java | ||
|---|---|---|
| 47 | 47 |
mStatic0 = (Static1D)radius; |
| 48 | 48 |
} |
| 49 | 49 |
} |
| 50 |
|
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 54 |
{
|
|
| 55 |
if( mDynamic0!=null ) |
|
| 56 |
{
|
|
| 57 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 58 |
} |
|
| 59 |
else |
|
| 60 |
{
|
|
| 61 |
uniforms[index] = ((Static1D)mStatic0).getX(); |
|
| 62 |
return false; |
|
| 63 |
} |
|
| 64 |
} |
|
| 50 | 65 |
} |
| src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
|---|---|---|
| 59 | 59 |
mStatic1 = (Static4D)color; |
| 60 | 60 |
} |
| 61 | 61 |
} |
| 62 |
|
|
| 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 64 |
|
|
| 65 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 66 |
{
|
|
| 67 |
if( mDynamic1!=null ) |
|
| 68 |
{
|
|
| 69 |
mDynamic1.interpolateMain(uniforms,index+1,currentDuration,step); |
|
| 70 |
} |
|
| 71 |
else |
|
| 72 |
{
|
|
| 73 |
uniforms[index+1] = ((Static4D)mStatic1).getX(); |
|
| 74 |
uniforms[index+2] = ((Static4D)mStatic1).getY(); |
|
| 75 |
uniforms[index+3] = ((Static4D)mStatic1).getZ(); |
|
| 76 |
uniforms[index+4] = ((Static4D)mStatic1).getW(); |
|
| 77 |
} |
|
| 78 |
|
|
| 79 |
if( mDynamic0!=null ) |
|
| 80 |
{
|
|
| 81 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 82 |
} |
|
| 83 |
else |
|
| 84 |
{
|
|
| 85 |
uniforms[index ] = ((Static1D)mStatic0).getX(); |
|
| 86 |
return false; |
|
| 87 |
} |
|
| 88 |
} |
|
| 62 | 89 |
} |
| src/main/java/org/distorted/library/effect/VertexEffect.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.library.effect; |
| 21 | 21 |
|
| 22 |
import org.distorted.library.type.Data3D; |
|
| 23 |
import org.distorted.library.type.Data4D; |
|
| 24 | 22 |
import org.distorted.library.type.Dynamic; |
| 23 |
import org.distorted.library.type.Dynamic3D; |
|
| 24 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 25 |
import org.distorted.library.type.Static; |
| 26 |
import org.distorted.library.type.Static3D; |
|
| 27 |
import org.distorted.library.type.Static4D; |
|
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 30 |
// VERTEX EFFECTS |
| ... | ... | |
| 30 | 32 |
|
| 31 | 33 |
public abstract class VertexEffect extends Effect |
| 32 | 34 |
{
|
| 35 |
public static final int NUM_UNIFORMS = 12; |
|
| 36 |
|
|
| 33 | 37 |
public static final int DISTORT =0; |
| 34 | 38 |
public static final int DEFORM =1; |
| 35 | 39 |
public static final int SINK =2; |
| ... | ... | |
| 43 | 47 |
|
| 44 | 48 |
Dynamic mDynamic0; |
| 45 | 49 |
Static mStatic0; |
| 46 |
Data3D mCenter; |
|
| 47 |
Data4D mRegion; |
|
| 50 |
Dynamic3D mDynamicCenter; |
|
| 51 |
Static3D mStaticCenter; |
|
| 52 |
Dynamic4D mDynamicRegion; |
|
| 53 |
Static4D mStaticRegion; |
|
| 48 | 54 |
|
| 49 | 55 |
private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS]; |
| 50 | 56 |
private final static int[] mUnityDim = new int[NUM_EFFECTS]; |
| src/main/java/org/distorted/library/effect/VertexEffectDeform.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.type.Data3D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 | 24 |
import org.distorted.library.type.Dynamic3D; |
| 25 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 26 |
import org.distorted.library.type.Static3D; |
| 27 |
import org.distorted.library.type.Static4D; |
|
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 30 |
|
| ... | ... | |
| 48 | 50 |
mStatic0 = (Static3D)vector; |
| 49 | 51 |
} |
| 50 | 52 |
|
| 51 |
mCenter = center; |
|
| 52 |
mRegion = region; |
|
| 53 |
if( center instanceof Static3D) |
|
| 54 |
{
|
|
| 55 |
mStaticCenter = (Static3D)center; |
|
| 56 |
} |
|
| 57 |
else if( center instanceof Dynamic3D ) |
|
| 58 |
{
|
|
| 59 |
mDynamicCenter = (Dynamic3D)center; |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
if( region instanceof Static4D) |
|
| 63 |
{
|
|
| 64 |
mStaticRegion = (Static4D)region; |
|
| 65 |
} |
|
| 66 |
else if( region instanceof Dynamic4D) |
|
| 67 |
{
|
|
| 68 |
mDynamicRegion = (Dynamic4D)region; |
|
| 69 |
} |
|
| 53 | 70 |
} |
| 54 | 71 |
|
| 55 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 67 | 84 |
mStatic0 = (Static3D)vector; |
| 68 | 85 |
} |
| 69 | 86 |
|
| 70 |
mCenter = center; |
|
| 87 |
if( center instanceof Static3D) |
|
| 88 |
{
|
|
| 89 |
mStaticCenter = (Static3D)center; |
|
| 90 |
} |
|
| 91 |
else if( center instanceof Dynamic3D ) |
|
| 92 |
{
|
|
| 93 |
mDynamicCenter = (Dynamic3D)center; |
|
| 94 |
} |
|
| 95 |
|
|
| 96 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 100 |
|
|
| 101 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 102 |
{
|
|
| 103 |
boolean ret = false; |
|
| 104 |
|
|
| 105 |
if( mDynamicCenter!=null ) |
|
| 106 |
{
|
|
| 107 |
mDynamicCenter.interpolateMain(uniforms,index+5,currentDuration,step); |
|
| 108 |
} |
|
| 109 |
else |
|
| 110 |
{
|
|
| 111 |
uniforms[index+5] = mStaticCenter.getX(); |
|
| 112 |
uniforms[index+6] = mStaticCenter.getY(); |
|
| 113 |
uniforms[index+7] = mStaticCenter.getZ(); |
|
| 114 |
} |
|
| 115 |
|
|
| 116 |
if( mDynamicRegion!=null ) |
|
| 117 |
{
|
|
| 118 |
mDynamicRegion.interpolateMain(uniforms,index+8,currentDuration,step); |
|
| 119 |
} |
|
| 120 |
else |
|
| 121 |
{
|
|
| 122 |
uniforms[index+ 8] = mStaticRegion.getX(); |
|
| 123 |
uniforms[index+ 9] = mStaticRegion.getY(); |
|
| 124 |
uniforms[index+10] = mStaticRegion.getZ(); |
|
| 125 |
uniforms[index+11] = mStaticRegion.getW(); |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
if( mDynamic0!=null ) |
|
| 129 |
{
|
|
| 130 |
ret = mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 131 |
} |
|
| 132 |
else |
|
| 133 |
{
|
|
| 134 |
uniforms[index ] = ((Static3D)mStatic0).getX(); |
|
| 135 |
uniforms[index+1] = ((Static3D)mStatic0).getY(); |
|
| 136 |
uniforms[index+2] = ((Static3D)mStatic0).getZ(); |
|
| 137 |
} |
|
| 138 |
|
|
| 139 |
return ret; |
|
| 71 | 140 |
} |
| 72 | 141 |
} |
| src/main/java/org/distorted/library/effect/VertexEffectDistort.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.type.Data3D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 | 24 |
import org.distorted.library.type.Dynamic3D; |
| 25 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 26 |
import org.distorted.library.type.Static3D; |
| 27 |
import org.distorted.library.type.Static4D; |
|
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 30 |
|
| ... | ... | |
| 48 | 50 |
mStatic0 = (Static3D)vector; |
| 49 | 51 |
} |
| 50 | 52 |
|
| 51 |
mCenter = center; |
|
| 52 |
mRegion = region; |
|
| 53 |
if( center instanceof Static3D) |
|
| 54 |
{
|
|
| 55 |
mStaticCenter = (Static3D)center; |
|
| 56 |
} |
|
| 57 |
else if( center instanceof Dynamic3D ) |
|
| 58 |
{
|
|
| 59 |
mDynamicCenter = (Dynamic3D)center; |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
if( region instanceof Static4D) |
|
| 63 |
{
|
|
| 64 |
mStaticRegion = (Static4D)region; |
|
| 65 |
} |
|
| 66 |
else if( region instanceof Dynamic4D) |
|
| 67 |
{
|
|
| 68 |
mDynamicRegion = (Dynamic4D)region; |
|
| 69 |
} |
|
| 53 | 70 |
} |
| 54 | 71 |
|
| 55 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 67 | 84 |
mStatic0 = (Static3D)vector; |
| 68 | 85 |
} |
| 69 | 86 |
|
| 70 |
mCenter = center; |
|
| 87 |
if( center instanceof Static3D) |
|
| 88 |
{
|
|
| 89 |
mStaticCenter = (Static3D)center; |
|
| 90 |
} |
|
| 91 |
else if( center instanceof Dynamic3D ) |
|
| 92 |
{
|
|
| 93 |
mDynamicCenter = (Dynamic3D)center; |
|
| 94 |
} |
|
| 95 |
|
|
| 96 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 100 |
|
|
| 101 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 102 |
{
|
|
| 103 |
boolean ret = false; |
|
| 104 |
|
|
| 105 |
if( mDynamicCenter!=null ) |
|
| 106 |
{
|
|
| 107 |
mDynamicCenter.interpolateMain(uniforms,index+5,currentDuration,step); |
|
| 108 |
} |
|
| 109 |
else |
|
| 110 |
{
|
|
| 111 |
uniforms[index+5] = mStaticCenter.getX(); |
|
| 112 |
uniforms[index+6] = mStaticCenter.getY(); |
|
| 113 |
uniforms[index+7] = mStaticCenter.getZ(); |
|
| 114 |
} |
|
| 115 |
|
|
| 116 |
if( mDynamicRegion!=null ) |
|
| 117 |
{
|
|
| 118 |
mDynamicRegion.interpolateMain(uniforms,index+8,currentDuration,step); |
|
| 119 |
} |
|
| 120 |
else |
|
| 121 |
{
|
|
| 122 |
uniforms[index+ 8] = mStaticRegion.getX(); |
|
| 123 |
uniforms[index+ 9] = mStaticRegion.getY(); |
|
| 124 |
uniforms[index+10] = mStaticRegion.getZ(); |
|
| 125 |
uniforms[index+11] = mStaticRegion.getW(); |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
if( mDynamic0!=null ) |
|
| 129 |
{
|
|
| 130 |
ret = mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 131 |
} |
|
| 132 |
else |
|
| 133 |
{
|
|
| 134 |
uniforms[index ] = ((Static3D)mStatic0).getX(); |
|
| 135 |
uniforms[index+1] = ((Static3D)mStatic0).getY(); |
|
| 136 |
uniforms[index+2] = ((Static3D)mStatic0).getZ(); |
|
| 137 |
} |
|
| 138 |
|
|
| 139 |
uniforms[index+1] =-uniforms[index+1]; |
|
| 140 |
|
|
| 141 |
return ret; |
|
| 71 | 142 |
} |
| 72 | 143 |
} |
| 144 |
|
|
| 145 |
|
|
| src/main/java/org/distorted/library/effect/VertexEffectPinch.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.library.effect; |
| 21 | 21 |
|
| 22 |
import org.distorted.library.type.Data1D;
|
|
| 22 |
import org.distorted.library.type.Data2D;
|
|
| 23 | 23 |
import org.distorted.library.type.Data3D; |
| 24 | 24 |
import org.distorted.library.type.Data4D; |
| 25 |
import org.distorted.library.type.Dynamic1D; |
|
| 26 |
import org.distorted.library.type.Static1D; |
|
| 25 |
import org.distorted.library.type.Dynamic2D; |
|
| 26 |
import org.distorted.library.type.Dynamic3D; |
|
| 27 |
import org.distorted.library.type.Dynamic4D; |
|
| 28 |
import org.distorted.library.type.Static2D; |
|
| 29 |
import org.distorted.library.type.Static3D; |
|
| 30 |
import org.distorted.library.type.Static4D; |
|
| 27 | 31 |
|
| 28 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 29 | 33 |
|
| ... | ... | |
| 36 | 40 |
|
| 37 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 38 | 42 |
|
| 39 |
public VertexEffectPinch(Data1D pinch, Data3D center, Data4D region)
|
|
| 43 |
public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region)
|
|
| 40 | 44 |
{
|
| 41 | 45 |
super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
| 42 | 46 |
|
| 43 |
if( pinch instanceof Dynamic1D)
|
|
| 47 |
if( pinch instanceof Dynamic2D)
|
|
| 44 | 48 |
{
|
| 45 |
mDynamic0 = (Dynamic1D)pinch;
|
|
| 49 |
mDynamic0 = (Dynamic2D)pinch;
|
|
| 46 | 50 |
} |
| 47 |
else if ( pinch instanceof Static1D )
|
|
| 51 |
else if ( pinch instanceof Static2D )
|
|
| 48 | 52 |
{
|
| 49 |
mStatic0 = (Static1D)pinch;
|
|
| 53 |
mStatic0 = (Static2D)pinch;
|
|
| 50 | 54 |
} |
| 51 | 55 |
|
| 52 |
mCenter = center; |
|
| 53 |
mRegion = region; |
|
| 56 |
if( center instanceof Static3D) |
|
| 57 |
{
|
|
| 58 |
mStaticCenter = (Static3D)center; |
|
| 59 |
} |
|
| 60 |
else if( center instanceof Dynamic3D) |
|
| 61 |
{
|
|
| 62 |
mDynamicCenter = (Dynamic3D)center; |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
if( region instanceof Static4D) |
|
| 66 |
{
|
|
| 67 |
mStaticRegion = (Static4D)region; |
|
| 68 |
} |
|
| 69 |
else if( region instanceof Dynamic4D) |
|
| 70 |
{
|
|
| 71 |
mDynamicRegion = (Dynamic4D)region; |
|
| 72 |
} |
|
| 54 | 73 |
} |
| 55 | 74 |
|
| 56 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 57 | 76 |
|
| 58 |
public VertexEffectPinch(Data1D pinch, Data3D center)
|
|
| 77 |
public VertexEffectPinch(Data2D pinch, Data3D center)
|
|
| 59 | 78 |
{
|
| 60 | 79 |
super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
| 61 | 80 |
|
| 62 |
if( pinch instanceof Dynamic1D) |
|
| 81 |
if( pinch instanceof Dynamic2D) |
|
| 82 |
{
|
|
| 83 |
mDynamic0 = (Dynamic2D)pinch; |
|
| 84 |
} |
|
| 85 |
else if ( pinch instanceof Static2D ) |
|
| 86 |
{
|
|
| 87 |
mStatic0 = (Static2D)pinch; |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
if( center instanceof Static3D) |
|
| 91 |
{
|
|
| 92 |
mStaticCenter = (Static3D)center; |
|
| 93 |
} |
|
| 94 |
else if( center instanceof Dynamic3D ) |
|
| 95 |
{
|
|
| 96 |
mDynamicCenter = (Dynamic3D)center; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
|
|
| 104 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 105 |
{
|
|
| 106 |
boolean ret= false; |
|
| 107 |
|
|
| 108 |
if( mDynamicCenter!=null ) |
|
| 109 |
{
|
|
| 110 |
mDynamicCenter.interpolateMain(uniforms,index+5,currentDuration,step); |
|
| 111 |
} |
|
| 112 |
else |
|
| 113 |
{
|
|
| 114 |
uniforms[index+5] = mStaticCenter.getX(); |
|
| 115 |
uniforms[index+6] = mStaticCenter.getY(); |
|
| 116 |
uniforms[index+7] = mStaticCenter.getZ(); |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
if( mDynamicRegion!=null ) |
|
| 63 | 120 |
{
|
| 64 |
mDynamic0 = (Dynamic1D)pinch;
|
|
| 121 |
mDynamicRegion.interpolateMain(uniforms,index+8,currentDuration,step);
|
|
| 65 | 122 |
} |
| 66 |
else if ( pinch instanceof Static1D )
|
|
| 123 |
else |
|
| 67 | 124 |
{
|
| 68 |
mStatic0 = (Static1D)pinch; |
|
| 125 |
uniforms[index+ 8] = mStaticRegion.getX(); |
|
| 126 |
uniforms[index+ 9] = mStaticRegion.getY(); |
|
| 127 |
uniforms[index+10] = mStaticRegion.getZ(); |
|
| 128 |
uniforms[index+11] = mStaticRegion.getW(); |
|
| 69 | 129 |
} |
| 70 | 130 |
|
| 71 |
mCenter = center; |
|
| 131 |
if( mDynamic0!=null ) |
|
| 132 |
{
|
|
| 133 |
ret = mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 134 |
} |
|
| 135 |
else |
|
| 136 |
{
|
|
| 137 |
uniforms[index ] = ((Static2D)mStatic0).getX(); |
|
| 138 |
uniforms[index+1] = ((Static2D)mStatic0).getY(); |
|
| 139 |
} |
|
| 140 |
|
|
| 141 |
uniforms[index+1] = (float)(Math.PI*uniforms[index+1]/180); |
|
| 142 |
|
|
| 143 |
return ret; |
|
| 72 | 144 |
} |
| 73 | 145 |
} |
| src/main/java/org/distorted/library/effect/VertexEffectSink.java | ||
|---|---|---|
| 23 | 23 |
import org.distorted.library.type.Data3D; |
| 24 | 24 |
import org.distorted.library.type.Data4D; |
| 25 | 25 |
import org.distorted.library.type.Dynamic1D; |
| 26 |
import org.distorted.library.type.Dynamic3D; |
|
| 27 |
import org.distorted.library.type.Dynamic4D; |
|
| 26 | 28 |
import org.distorted.library.type.Static1D; |
| 29 |
import org.distorted.library.type.Static3D; |
|
| 30 |
import org.distorted.library.type.Static4D; |
|
| 27 | 31 |
|
| 28 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 29 | 33 |
|
| ... | ... | |
| 49 | 53 |
mStatic0 = (Static1D)sink; |
| 50 | 54 |
} |
| 51 | 55 |
|
| 52 |
mCenter = center; |
|
| 53 |
mRegion = region; |
|
| 56 |
if( center instanceof Static3D) |
|
| 57 |
{
|
|
| 58 |
mStaticCenter = (Static3D)center; |
|
| 59 |
} |
|
| 60 |
else if( center instanceof Dynamic3D) |
|
| 61 |
{
|
|
| 62 |
mDynamicCenter = (Dynamic3D)center; |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
if( region instanceof Static4D) |
|
| 66 |
{
|
|
| 67 |
mStaticRegion = (Static4D)region; |
|
| 68 |
} |
|
| 69 |
else if( region instanceof Dynamic4D) |
|
| 70 |
{
|
|
| 71 |
mDynamicRegion = (Dynamic4D)region; |
|
| 72 |
} |
|
| 54 | 73 |
} |
| 55 | 74 |
|
| 56 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 68 | 87 |
mStatic0 = (Static1D)sink; |
| 69 | 88 |
} |
| 70 | 89 |
|
| 71 |
mCenter = center; |
|
| 90 |
if( center instanceof Static3D) |
|
| 91 |
{
|
|
| 92 |
mStaticCenter = (Static3D)center; |
|
| 93 |
} |
|
| 94 |
else if( center instanceof Dynamic3D ) |
|
| 95 |
{
|
|
| 96 |
mDynamicCenter = (Dynamic3D)center; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
|
|
| 104 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 105 |
{
|
|
| 106 |
boolean ret = false; |
|
| 107 |
|
|
| 108 |
if( mDynamicCenter!=null ) |
|
| 109 |
{
|
|
| 110 |
mDynamicCenter.interpolateMain(uniforms,index+5,currentDuration,step); |
|
| 111 |
} |
|
| 112 |
else |
|
| 113 |
{
|
|
| 114 |
uniforms[index+5] = mStaticCenter.getX(); |
|
| 115 |
uniforms[index+6] = mStaticCenter.getY(); |
|
| 116 |
uniforms[index+7] = mStaticCenter.getZ(); |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
if( mDynamicRegion!=null ) |
|
| 120 |
{
|
|
| 121 |
mDynamicRegion.interpolateMain(uniforms,index+8,currentDuration,step); |
|
| 122 |
} |
|
| 123 |
else |
|
| 124 |
{
|
|
| 125 |
uniforms[index+ 8] = mStaticRegion.getX(); |
|
| 126 |
uniforms[index+ 9] = mStaticRegion.getY(); |
|
| 127 |
uniforms[index+10] = mStaticRegion.getZ(); |
|
| 128 |
uniforms[index+11] = mStaticRegion.getW(); |
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
if( mDynamic0!=null ) |
|
| 132 |
{
|
|
| 133 |
ret = mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 134 |
} |
|
| 135 |
else |
|
| 136 |
{
|
|
| 137 |
uniforms[index ] = ((Static1D)mStatic0).getX(); |
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
return ret; |
|
| 72 | 141 |
} |
| 73 | 142 |
} |
| src/main/java/org/distorted/library/effect/VertexEffectSwirl.java | ||
|---|---|---|
| 23 | 23 |
import org.distorted.library.type.Data3D; |
| 24 | 24 |
import org.distorted.library.type.Data4D; |
| 25 | 25 |
import org.distorted.library.type.Dynamic1D; |
| 26 |
import org.distorted.library.type.Dynamic3D; |
|
| 27 |
import org.distorted.library.type.Dynamic4D; |
|
| 26 | 28 |
import org.distorted.library.type.Static1D; |
| 29 |
import org.distorted.library.type.Static3D; |
|
| 30 |
import org.distorted.library.type.Static4D; |
|
| 27 | 31 |
|
| 28 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 29 | 33 |
|
| ... | ... | |
| 49 | 53 |
mStatic0 = (Static1D)swirl; |
| 50 | 54 |
} |
| 51 | 55 |
|
| 52 |
mCenter = center; |
|
| 53 |
mRegion = region; |
|
| 56 |
if( center instanceof Static3D) |
|
| 57 |
{
|
|
| 58 |
mStaticCenter = (Static3D)center; |
|
| 59 |
} |
|
| 60 |
else if( center instanceof Dynamic3D) |
|
| 61 |
{
|
|
| 62 |
mDynamicCenter = (Dynamic3D)center; |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
if( region instanceof Static4D) |
|
| 66 |
{
|
|
| 67 |
mStaticRegion = (Static4D)region; |
|
| 68 |
} |
|
| 69 |
else if( region instanceof Dynamic4D) |
|
| 70 |
{
|
|
| 71 |
mDynamicRegion = (Dynamic4D)region; |
|
| 72 |
} |
|
| 54 | 73 |
} |
| 55 | 74 |
|
| 56 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 68 | 87 |
mStatic0 = (Static1D)swirl; |
| 69 | 88 |
} |
| 70 | 89 |
|
| 71 |
mCenter = center; |
|
| 90 |
if( center instanceof Static3D) |
|
| 91 |
{
|
|
| 92 |
mStaticCenter = (Static3D)center; |
|
| 93 |
} |
|
| 94 |
else if( center instanceof Dynamic3D ) |
|
| 95 |
{
|
|
| 96 |
mDynamicCenter = (Dynamic3D)center; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
|
|
| 104 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 105 |
{
|
|
| 106 |
boolean ret = false; |
|
| 107 |
|
|
| 108 |
if( mDynamicCenter!=null ) |
|
| 109 |
{
|
|
| 110 |
mDynamicCenter.interpolateMain(uniforms,index+5,currentDuration,step); |
|
| 111 |
} |
|
| 112 |
else |
|
| 113 |
{
|
|
| 114 |
uniforms[index+5] = mStaticCenter.getX(); |
|
| 115 |
uniforms[index+6] = mStaticCenter.getY(); |
|
| 116 |
uniforms[index+7] = mStaticCenter.getZ(); |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
if( mDynamicRegion!=null ) |
|
| 120 |
{
|
|
| 121 |
mDynamicRegion.interpolateMain(uniforms,index+8,currentDuration,step); |
|
| 122 |
} |
|
| 123 |
else |
|
| 124 |
{
|
|
| 125 |
uniforms[index+ 8] = mStaticRegion.getX(); |
|
| 126 |
uniforms[index+ 9] = mStaticRegion.getY(); |
|
| 127 |
uniforms[index+10] = mStaticRegion.getZ(); |
|
| 128 |
uniforms[index+11] = mStaticRegion.getW(); |
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
if( mDynamic0!=null ) |
|
| 132 |
{
|
|
| 133 |
ret = mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 134 |
} |
|
| 135 |
else |
|
| 136 |
{
|
|
| 137 |
uniforms[index ] = ((Static1D)mStatic0).getX(); |
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
|
|
| 141 |
uniforms[index] = (float)(Math.PI*uniforms[index]/180); |
|
| 142 |
|
|
| 143 |
return ret; |
|
| 72 | 144 |
} |
| 73 | 145 |
} |
| 146 |
|
|
| src/main/java/org/distorted/library/effect/VertexEffectWave.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.type.Data3D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 | 24 |
import org.distorted.library.type.Data5D; |
| 25 |
import org.distorted.library.type.Dynamic3D; |
|
| 26 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 27 |
import org.distorted.library.type.Dynamic5D; |
| 28 |
import org.distorted.library.type.Static3D; |
|
| 29 |
import org.distorted.library.type.Static4D; |
|
| 26 | 30 |
import org.distorted.library.type.Static5D; |
| 27 | 31 |
|
| 28 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 49 | 53 |
mStatic0 = (Static5D)wave; |
| 50 | 54 |
} |
| 51 | 55 |
|
| 52 |
mCenter = center; |
|
| 53 |
mRegion = region; |
|
| 56 |
if( center instanceof Static3D) |
|
| 57 |
{
|
|
| 58 |
mStaticCenter = (Static3D)center; |
|
| 59 |
} |
|
| 60 |
else if( center instanceof Dynamic3D) |
|
| 61 |
{
|
|
| 62 |
mDynamicCenter = (Dynamic3D)center; |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
if( region instanceof Static4D) |
|
| 66 |
{
|
|
| 67 |
mStaticRegion = (Static4D)region; |
|
| 68 |
} |
|
| 69 |
else if( region instanceof Dynamic4D) |
|
| 70 |
{
|
|
| 71 |
mDynamicRegion = (Dynamic4D)region; |
|
| 72 |
} |
|
| 54 | 73 |
} |
| 55 | 74 |
|
| 56 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 68 | 87 |
mStatic0 = (Static5D)wave; |
| 69 | 88 |
} |
| 70 | 89 |
|
| 71 |
mCenter = center; |
|
| 90 |
if( center instanceof Static3D) |
|
| 91 |
{
|
|
| 92 |
mStaticCenter = (Static3D)center; |
|
| 93 |
} |
|
| 94 |
else if( center instanceof Dynamic3D ) |
|
| 95 |
{
|
|
| 96 |
mDynamicCenter = (Dynamic3D)center; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
|
|
| 104 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
|
| 105 |
{
|
|
| 106 |
boolean ret = false; |
|
| 107 |
|
|
| 108 |
if( mDynamicCenter!=null ) |
|
| 109 |
{
|
|
| 110 |
mDynamicCenter.interpolateMain(uniforms,index+5,currentDuration,step); |
|
| 111 |
} |
|
| 112 |
else |
|
| 113 |
{
|
|
| 114 |
uniforms[index+5] = mStaticCenter.getX(); |
|
| 115 |
uniforms[index+6] = mStaticCenter.getY(); |
|
| 116 |
uniforms[index+7] = mStaticCenter.getZ(); |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
if( mDynamicRegion!=null ) |
|
| 120 |
{
|
|
| 121 |
mDynamicRegion.interpolateMain(uniforms,index+8,currentDuration,step); |
|
| 122 |
} |
|
| 123 |
else |
|
| 124 |
{
|
|
| 125 |
uniforms[index+ 8] = mStaticRegion.getX(); |
|
| 126 |
uniforms[index+ 9] = mStaticRegion.getY(); |
|
| 127 |
uniforms[index+10] = mStaticRegion.getZ(); |
|
| 128 |
uniforms[index+11] = mStaticRegion.getW(); |
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
if( mDynamic0!=null ) |
|
| 132 |
{
|
|
| 133 |
ret = mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 134 |
} |
|
| 135 |
else |
|
| 136 |
{
|
|
| 137 |
uniforms[index ] = ((Static5D)mStatic0).getX(); |
|
| 138 |
uniforms[index+1] = ((Static5D)mStatic0).getY(); |
|
| 139 |
uniforms[index+2] = ((Static5D)mStatic0).getZ(); |
|
| 140 |
uniforms[index+3] = ((Static5D)mStatic0).getW(); |
|
| 141 |
uniforms[index+4] = ((Static5D)mStatic0).getV(); |
|
| 142 |
} |
|
| 143 |
|
|
| 144 |
uniforms[index+2] = (float)(Math.PI*uniforms[index+2]/180); |
|
| 145 |
uniforms[index+3] = (float)(Math.PI*uniforms[index+3]/180); |
|
| 146 |
uniforms[index+4] = (float)(Math.PI*uniforms[index+4]/180); |
|
| 147 |
|
|
| 148 |
return ret; |
|
| 72 | 149 |
} |
| 73 | 150 |
} |
| src/main/java/org/distorted/library/main/EffectMessageSender.java | ||
|---|---|---|
| 33 | 33 |
EffectListener mListener; |
| 34 | 34 |
EffectMessage mMessage; |
| 35 | 35 |
long mEffectID; |
| 36 |
int mEffectName; |
|
| 37 |
long mBitmapID; |
|
| 36 |
long mObjectID; |
|
| 38 | 37 |
|
| 39 |
Message(EffectListener l, EffectMessage m, long id, int name, long bmpID)
|
|
| 38 |
Message(EffectListener l, EffectMessage m, long effID, long objID)
|
|
| 40 | 39 |
{
|
| 41 |
mListener = l; |
|
| 42 |
mMessage = m; |
|
| 43 |
mEffectID = id; |
|
| 44 |
mEffectName = name; |
|
| 45 |
mBitmapID = bmpID; |
|
| 40 |
mListener = l; |
|
| 41 |
mMessage = m; |
|
| 42 |
mEffectID = effID; |
|
| 43 |
mObjectID = objID; |
|
| 46 | 44 |
} |
| 47 | 45 |
} |
| 48 | 46 |
|
| ... | ... | |
| 106 | 104 |
while( mList.size()>0 ) |
| 107 | 105 |
{
|
| 108 | 106 |
tmp = mList.remove(0); |
| 109 |
tmp.mListener.effectMessage(tmp.mMessage, tmp.mEffectID, tmp.mEffectName,tmp.mBitmapID);
|
|
| 107 |
tmp.mListener.effectMessage(tmp.mMessage, tmp.mEffectID, tmp.mObjectID);
|
|
| 110 | 108 |
} |
| 111 | 109 |
|
| 112 | 110 |
synchronized(mThis) |
| ... | ... | |
| 128 | 126 |
|
| 129 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 130 | 128 |
|
| 131 |
static void newMessage(EffectListener l, EffectMessage m, long id, int name, long bmpID)
|
|
| 129 |
static void newMessage(EffectListener l, EffectMessage m, long effID, long objID)
|
|
| 132 | 130 |
{
|
| 133 |
Message msg = mThis.new Message(l,m,id,name,bmpID);
|
|
| 131 |
Message msg = mThis.new Message(l,m,effID,objID);
|
|
| 134 | 132 |
mList.add(msg); |
| 135 | 133 |
|
| 136 | 134 |
synchronized(mThis) |
| ... | ... | |
| 140 | 138 |
} |
| 141 | 139 |
} |
| 142 | 140 |
} |
| 143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| src/main/java/org/distorted/library/main/EffectQueue.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.effect.Effect; |
| 23 | 23 |
import org.distorted.library.message.EffectListener; |
| 24 | 24 |
import org.distorted.library.message.EffectMessage; |
| 25 |
import org.distorted.library.type.Dynamic; |
|
| 26 | 25 |
|
| 27 | 26 |
import java.util.Vector; |
| 28 | 27 |
|
| ... | ... | |
| 30 | 29 |
|
| 31 | 30 |
abstract class EffectQueue |
| 32 | 31 |
{
|
| 33 |
protected byte mNumEffects; // number of effects at the moment |
|
| 34 |
protected long mTotalEffects; // total number of effects ever created |
|
| 35 |
protected int[] mName; |
|
| 36 |
protected int[] mType; |
|
| 32 |
protected byte mNumEffects; |
|
| 37 | 33 |
protected float[] mUniforms; |
| 38 |
protected float[] mCache; |
|
| 39 |
protected Dynamic[][] mInter; |
|
| 40 | 34 |
protected long[] mCurrentDuration; |
| 41 |
protected byte[] mFreeIndexes; |
|
| 42 |
protected byte[] mIDIndex; |
|
| 43 |
protected long[] mID; |
|
| 35 |
protected Effect[] mEffects; |
|
| 36 |
protected int[] mName; |
|
| 44 | 37 |
protected long mTime=0; |
| 45 | 38 |
protected static int[] mMax = new int[Effect.LENGTH]; |
| 46 |
protected int mMaxIndex; |
|
| 47 | 39 |
protected Vector<EffectListener> mListeners =null; |
| 48 | 40 |
protected int mNumListeners=0; // ==mListeners.length(), but we only create mListeners if the first one gets added |
| 49 |
protected long mObjectID;
|
|
| 41 |
protected long mID; |
|
| 50 | 42 |
|
| 51 | 43 |
private static boolean mCreated; |
| 44 |
private int mIndex; |
|
| 45 |
private int mNumUniforms; |
|
| 52 | 46 |
|
| 53 | 47 |
static |
| 54 | 48 |
{
|
| ... | ... | |
| 57 | 51 |
|
| 58 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | 53 |
|
| 60 |
EffectQueue(long id, int numUniforms, int numCache, int index)
|
|
| 54 |
EffectQueue(long id, int numUniforms, int index) |
|
| 61 | 55 |
{
|
| 62 |
mNumEffects = 0;
|
|
| 63 |
mTotalEffects = 0;
|
|
| 64 |
mMaxIndex = index;
|
|
| 65 |
mObjectID = id;
|
|
| 56 |
mNumEffects = 0; |
|
| 57 |
mID = id;
|
|
| 58 |
mIndex = index;
|
|
| 59 |
mNumUniforms = numUniforms;
|
|
| 66 | 60 |
|
| 67 |
int max = mMax[mMaxIndex];
|
|
| 61 |
int max = mMax[mIndex]; |
|
| 68 | 62 |
|
| 69 | 63 |
if( max>0 ) |
| 70 | 64 |
{
|
| 71 |
mName = new int[max]; |
|
| 72 |
mType = new int[max]; |
|
| 73 |
mUniforms = new float[numUniforms*max]; |
|
| 74 |
mInter = new Dynamic[3][max]; |
|
| 65 |
mUniforms = new float[mNumUniforms*max]; |
|
| 75 | 66 |
mCurrentDuration = new long[max]; |
| 76 |
mID = new long[max]; |
|
| 77 |
mIDIndex = new byte[max]; |
|
| 78 |
mFreeIndexes = new byte[max]; |
|
| 79 |
|
|
| 80 |
for(byte i=0; i<max; i++) mFreeIndexes[i] = i; |
|
| 81 |
|
|
| 82 |
if( numCache>0 ) |
|
| 83 |
{
|
|
| 84 |
mCache = new float[numCache*max]; |
|
| 85 |
} |
|
| 67 |
mEffects = new Effect[max]; |
|
| 68 |
mName = new int[max]; |
|
| 86 | 69 |
} |
| 87 | 70 |
|
| 88 | 71 |
mCreated = true; |
| ... | ... | |
| 152 | 135 |
Effect.reset(mMax); |
| 153 | 136 |
mCreated = false; |
| 154 | 137 |
} |
| 155 |
|
|
| 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 157 |
|
|
| 158 |
synchronized int removeByID(long id) |
|
| 159 |
{
|
|
| 160 |
int i = getEffectIndex(id); |
|
| 161 |
|
|
| 162 |
if( i>=0 ) |
|
| 163 |
{
|
|
| 164 |
remove(i); |
|
| 165 |
return 1; |
|
| 166 |
} |
|
| 167 |
|
|
| 168 |
return 0; |
|
| 169 |
} |
|
| 170 | 138 |
|
| 171 | 139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 172 | 140 |
|
| 173 | 141 |
synchronized int removeByType(Effect effect) |
| 174 | 142 |
{
|
| 175 |
int ret = 0; |
|
| 176 |
int name = effect.getName(); |
|
| 177 |
int type = effect.getType(); |
|
| 143 |
int ret = 0; |
|
| 178 | 144 |
|
| 179 | 145 |
for(int i=0; i<mNumEffects; i++) |
| 180 | 146 |
{
|
| 181 |
if( mName[i]==name && mType[i]==type )
|
|
| 147 |
if( mEffects[i]==effect )
|
|
| 182 | 148 |
{
|
| 183 | 149 |
remove(i); |
| 184 | 150 |
i--; |
| ... | ... | |
| 188 | 154 |
|
| 189 | 155 |
return ret; |
| 190 | 156 |
} |
| 191 |
|
|
| 192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 193 |
|
|
| 194 |
private synchronized int getEffectIndex(long id) |
|
| 195 |
{
|
|
| 196 |
int index = mIDIndex[(int)(id%mMax[mMaxIndex])]; |
|
| 197 |
return (index<mNumEffects && mID[index]==id ? index : -1); |
|
| 198 |
} |
|
| 199 | 157 |
|
| 200 | 158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 201 | 159 |
// we do want to notify Listeners if they called 'abortAll' themselves but don't want to notify |
| ... | ... | |
| 204 | 162 |
synchronized int abortAll(boolean notify) |
| 205 | 163 |
{
|
| 206 | 164 |
int ret = mNumEffects; |
| 207 |
long removedID; |
|
| 208 |
int removedName, removedType; |
|
| 209 | 165 |
|
| 210 | 166 |
for(int i=0; i<ret; i++ ) |
| 211 | 167 |
{
|
| 212 |
mInter[0][i] = null; |
|
| 213 |
mInter[1][i] = null; |
|
| 214 |
mInter[2][i] = null; |
|
| 215 |
|
|
| 216 | 168 |
if( notify ) |
| 217 | 169 |
{
|
| 218 |
removedID = mID[i]; |
|
| 219 |
removedName= mName[i]; |
|
| 220 |
removedType= mType[i]; |
|
| 221 |
|
|
| 222 | 170 |
for(int j=0; j<mNumListeners; j++) |
| 223 |
EffectMessageSender.newMessage( mListeners.elementAt(j), |
|
| 224 |
EffectMessage.EFFECT_REMOVED, |
|
| 225 |
(removedID<<Effect.LENGTH)+removedType, |
|
| 226 |
removedName, |
|
| 227 |
mObjectID); |
|
| 171 |
EffectMessageSender.newMessage( mListeners.elementAt(j), EffectMessage.EFFECT_REMOVED, mEffects[i].getID(), mID); |
|
| 228 | 172 |
} |
| 173 |
|
|
| 174 |
mEffects[i] = null; |
|
| 229 | 175 |
} |
| 230 | 176 |
|
| 231 | 177 |
mNumEffects= 0; |
| ... | ... | |
| 239 | 185 |
protected void remove(int effect) |
| 240 | 186 |
{
|
| 241 | 187 |
mNumEffects--; |
| 242 |
|
|
| 243 |
byte removedIndex = (byte)(mID[effect]%mMax[mMaxIndex]); |
|
| 244 |
byte removedPosition = mIDIndex[removedIndex]; |
|
| 245 |
mFreeIndexes[mNumEffects] = removedIndex; |
|
| 246 |
|
|
| 247 |
long removedID = mID[effect]; |
|
| 248 |
int removedName= mName[effect]; |
|
| 249 |
int removedType= mType[effect]; |
|
| 250 |
|
|
| 251 |
for(int j=0; j<mMax[mMaxIndex]; j++) |
|
| 252 |
{
|
|
| 253 |
if( mIDIndex[j] > removedPosition ) mIDIndex[j]--; |
|
| 254 |
} |
|
| 255 |
|
|
| 188 |
|
|
| 189 |
long removedID = mEffects[effect].getID(); |
|
| 190 |
|
|
| 256 | 191 |
for(int j=effect; j<mNumEffects; j++ ) |
| 257 | 192 |
{
|
| 258 |
mName[j] = mName[j+1]; |
|
| 259 |
mType[j] = mType[j+1]; |
|
| 260 |
mInter[0][j] = mInter[0][j+1]; |
|
| 261 |
mInter[1][j] = mInter[1][j+1]; |
|
| 262 |
mInter[2][j] = mInter[2][j+1]; |
|
| 193 |
mEffects[j] = mEffects[j+1]; |
|
| 263 | 194 |
mCurrentDuration[j] = mCurrentDuration[j+1]; |
| 264 |
mID[j] = mID[j+1]; |
|
| 265 |
|
|
| 266 |
moveEffect(j); |
|
| 195 |
mName[j] = mName[j+1]; |
|
| 196 |
|
|
| 197 |
for(int k=0; k<mNumUniforms; k++) |
|
| 198 |
mUniforms[mNumUniforms*j+k] = mUniforms[mNumUniforms*(j+1)+k]; |
|
| 267 | 199 |
} |
| 268 | 200 |
|
| 269 |
mInter[0][mNumEffects] = null; |
|
| 270 |
mInter[1][mNumEffects] = null; |
|
| 271 |
mInter[2][mNumEffects] = null; |
|
| 201 |
mEffects[mNumEffects] = null; |
|
| 272 | 202 |
|
| 273 | 203 |
for(int i=0; i<mNumListeners; i++) |
| 274 |
EffectMessageSender.newMessage( mListeners.elementAt(i), |
|
| 275 |
EffectMessage.EFFECT_REMOVED, |
|
| 276 |
(removedID<<Effect.LENGTH)+removedType, |
|
| 277 |
removedName, |
|
| 278 |
mObjectID); |
|
| 204 |
EffectMessageSender.newMessage( mListeners.elementAt(i), EffectMessage.EFFECT_REMOVED, removedID, mID); |
|
| 279 | 205 |
} |
| 280 | 206 |
|
| 281 | 207 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 282 | 208 |
|
| 283 |
protected long addBase(Effect effect)
|
|
| 209 |
public void add(Effect effect)
|
|
| 284 | 210 |
{
|
| 285 |
int type = effect.getType(); |
|
| 286 |
|
|
| 287 |
mName[mNumEffects] = effect.getName(); |
|
| 288 |
mType[mNumEffects] = type; |
|
| 289 |
mCurrentDuration[mNumEffects] = 0; |
|
| 290 |
|
|
| 291 |
int index = mFreeIndexes[mNumEffects]; |
|
| 292 |
long id = mTotalEffects*mMax[mMaxIndex] + index; |
|
| 293 |
mID[mNumEffects] = id; |
|
| 294 |
mIDIndex[index] = mNumEffects; |
|
| 295 |
|
|
| 296 |
mNumEffects++; |
|
| 297 |
mTotalEffects++; |
|
| 298 |
|
|
| 299 |
return (id<<Effect.LENGTH)+type; |
|
Also available in: Unified diff
Progress with support for Effect classes.