Revision 0dd98279
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/library/effect/FragmentEffect.java | ||
|---|---|---|
| 21 | 21 |  | 
| 22 | 22 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 23 | 23 | // FRAGMENT EFFECTS | 
| 24 | // 8 Uniforms: 4-per effect interpolated values, 4 dimensional Region. | |
| 24 |  | |
| 25 | 25 |  | 
| 26 | 26 | public abstract class FragmentEffect extends Effect | 
| 27 | 27 |   {
 | 
| 28 | public static final int NUM_UNIFORMS = 8; | |
| 28 |   public static final int NUM_UNIFORMS = 8; // 4-per effect interpolated values, 4 dimensional Region.
 | |
| 29 | 29 |  | 
| 30 | 30 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 31 | 31 |  | 
| src/main/java/org/distorted/library/effect/MatrixEffect.java | ||
|---|---|---|
| 19 | 19 |  | 
| 20 | 20 | package org.distorted.library.effect; | 
| 21 | 21 |  | 
| 22 | import org.distorted.library.type.*; | |
| 23 |  | |
| 24 | 22 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 25 | 23 | // MATRIX EFFECTS. | 
| 26 | // 7 Uniforms: 4 per-effect interpolated values + 3 dimensional center. | |
| 27 | 24 |  | 
| 28 | 25 | public abstract class MatrixEffect extends Effect | 
| 29 | 26 |   {
 | 
| 30 | public static final int NUM_UNIFORMS = 7; | |
| 31 |  | |
| 32 | Dynamic mDynamic0; | |
| 33 | Static mStatic0 , mStatic1; | |
| 34 | Dynamic3D mDynamicCenter; | |
| 35 | Static3D mStaticCenter; | |
| 27 | public static final int NUM_UNIFORMS = 7; // 4 per-effect interpolated values + 3 dimensional center. | |
| 36 | 28 |  | 
| 37 | 29 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 38 | 30 |  | 
| src/main/java/org/distorted/library/effect/MatrixEffectMove.java | ||
|---|---|---|
| 27 | 27 |  | 
| 28 | 28 | public class MatrixEffectMove extends MatrixEffect | 
| 29 | 29 |   {
 | 
| 30 | private Data3D mVector; | |
| 31 |  | |
| 30 | 32 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 31 | 33 | /** | 
| 32 | 34 | * Moves the Object by a (possibly changing in time) vector. | 
| ... | ... | |
| 37 | 39 | public MatrixEffectMove(Data3D vector) | 
| 38 | 40 |     {
 | 
| 39 | 41 | super(EffectName.MOVE); | 
| 40 |  | |
| 41 | if( vector instanceof Static3D) | |
| 42 |       {
 | |
| 43 | mStatic0 = (Static3D)vector; | |
| 44 | } | |
| 45 | else if ( vector instanceof Dynamic3D ) | |
| 46 |       {
 | |
| 47 | mDynamic0 = (Dynamic3D)vector; | |
| 48 | } | |
| 42 | mVector = vector; | |
| 49 | 43 | } | 
| 50 | 44 |  | 
| 51 | 45 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 52 | 46 |  | 
| 53 | 47 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 54 | 48 |     {
 | 
| 55 | if( mDynamic0!=null ) | |
| 56 |       {
 | |
| 57 | return mDynamic0.get(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 | } | |
| 49 | return mVector.get(uniforms,index,currentDuration,step); | |
| 67 | 50 | } | 
| 68 | 51 | } | 
| src/main/java/org/distorted/library/effect/MatrixEffectQuaternion.java | ||
|---|---|---|
| 30 | 30 |  | 
| 31 | 31 | public class MatrixEffectQuaternion extends MatrixEffect | 
| 32 | 32 |   {
 | 
| 33 | private Data4D mQuaternion; | |
| 34 | private Data3D mCenter; | |
| 35 |  | |
| 33 | 36 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 34 | 37 | /** | 
| 35 | 38 | * Rotates the Object by quaternion. | 
| ... | ... | |
| 40 | 43 | public MatrixEffectQuaternion(Data4D quaternion, Data3D center ) | 
| 41 | 44 |     {
 | 
| 42 | 45 | super(EffectName.QUATERNION); | 
| 43 |  | |
| 44 | if( quaternion instanceof Static4D) | |
| 45 |       {
 | |
| 46 | mStatic0 = (Static4D)quaternion; | |
| 47 | } | |
| 48 | else if( quaternion instanceof DynamicQuat) | |
| 49 |       {
 | |
| 50 | mDynamic0 = (DynamicQuat)quaternion; | |
| 51 | } | |
| 52 |  | |
| 53 | if( center instanceof Static3D) | |
| 54 |       {
 | |
| 55 | mStaticCenter = (Static3D)center; | |
| 56 | } | |
| 57 | else if( center instanceof Dynamic3D) | |
| 58 |       {
 | |
| 59 | mDynamicCenter = (Dynamic3D)center; | |
| 60 | } | |
| 46 | mQuaternion = quaternion; | |
| 47 | mCenter = center; | |
| 61 | 48 | } | 
| 62 | 49 |  | 
| 63 | 50 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 64 | 51 |  | 
| 65 | 52 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 66 | 53 |     {
 | 
| 67 | if( mDynamicCenter!=null ) | |
| 68 |       {
 | |
| 69 | mDynamicCenter.get(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.get(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 | } | |
| 54 | mCenter.get(uniforms,index+4,currentDuration,step); | |
| 55 | return mQuaternion.get(uniforms,index,currentDuration,step); | |
| 91 | 56 | } | 
| 92 | 57 | } | 
| src/main/java/org/distorted/library/effect/MatrixEffectRotate.java | ||
|---|---|---|
| 33 | 33 |  | 
| 34 | 34 | public class MatrixEffectRotate extends MatrixEffect | 
| 35 | 35 |   {
 | 
| 36 | private Data1D mAngle; | |
| 37 | private Data3D mAxis, mCenter; | |
| 38 |  | |
| 36 | 39 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 37 | 40 | /** | 
| 38 | 41 | * Rotates the Object by 'angle' degrees around the center. | 
| ... | ... | |
| 42 | 45 | * @param axis Axis of rotation | 
| 43 | 46 | * @param center Coordinates of the Point we are rotating around. | 
| 44 | 47 | */ | 
| 45 | public MatrixEffectRotate(Data1D angle, Static3D axis, Data3D center) | |
| 46 |     {
 | |
| 47 | super(EffectName.ROTATE); | |
| 48 |  | |
| 49 | if( angle instanceof Static1D ) | |
| 50 |       {
 | |
| 51 | mStatic0 = (Static1D)angle; | |
| 52 | } | |
| 53 | else if( angle instanceof Dynamic1D ) | |
| 54 |       {
 | |
| 55 | mDynamic0 = (Dynamic1D)angle; | |
| 56 | } | |
| 57 |  | |
| 58 | mStatic1 = axis; | |
| 59 |  | |
| 60 | if( center instanceof Static3D) | |
| 61 |       {
 | |
| 62 | mStaticCenter = (Static3D)center; | |
| 63 | } | |
| 64 | else if( center instanceof Dynamic3D ) | |
| 65 |       {
 | |
| 66 | mDynamicCenter = (Dynamic3D)center; | |
| 67 | } | |
| 68 | } | |
| 69 |  | |
| 70 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 71 | /** | |
| 72 | * Rotates the Object by 'angle' degrees around the center. | |
| 73 | * Here both angle and axis can dynamically change. | |
| 74 | * | |
| 75 | * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ). | |
| 76 | * @param center Coordinates of the Point we are rotating around. | |
| 77 | */ | |
| 78 | public MatrixEffectRotate(Data4D angleaxis, Data3D center) | |
| 48 | public MatrixEffectRotate(Data1D angle, Data3D axis, Data3D center) | |
| 79 | 49 |     {
 | 
| 80 | 50 | super(EffectName.ROTATE); | 
| 81 |  | |
| 82 | if( angleaxis instanceof Static4D) | |
| 83 |       {
 | |
| 84 | mStatic0 = (Static4D)angleaxis; | |
| 85 | } | |
| 86 | else if( angleaxis instanceof Dynamic4D) | |
| 87 |       {
 | |
| 88 | mDynamic0 = (Dynamic4D)angleaxis; | |
| 89 | } | |
| 90 |  | |
| 91 | if( center instanceof Static3D) | |
| 92 |       {
 | |
| 93 | mStaticCenter = (Static3D)center; | |
| 94 | } | |
| 95 | else if( center instanceof Dynamic3D ) | |
| 96 |       {
 | |
| 97 | mDynamicCenter = (Dynamic3D)center; | |
| 98 | } | |
| 51 | mAngle = angle; | |
| 52 | mAxis = axis; | |
| 53 | mCenter = center; | |
| 99 | 54 | } | 
| 100 | 55 |  | 
| 101 | 56 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 102 | 57 |  | 
| 103 | 58 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 104 | 59 |     {
 | 
| 105 | if( mDynamicCenter!=null ) | |
| 106 |       {
 | |
| 107 | mDynamicCenter.get(uniforms,index+4,currentDuration,step); | |
| 108 | } | |
| 109 | else | |
| 110 |       {
 | |
| 111 | uniforms[index+4] = mStaticCenter.getX(); | |
| 112 | uniforms[index+5] = mStaticCenter.getY(); | |
| 113 | uniforms[index+6] = mStaticCenter.getZ(); | |
| 114 | } | |
| 115 |  | |
| 116 | if( mStatic1 != null ) | |
| 117 |       {
 | |
| 118 | uniforms[index+1] = ((Static3D)mStatic1).getX(); | |
| 119 | uniforms[index+2] = ((Static3D)mStatic1).getY(); | |
| 120 | uniforms[index+3] = ((Static3D)mStatic1).getZ(); | |
| 121 | } | |
| 122 |  | |
| 123 | if( mDynamic0!=null ) | |
| 124 |       {
 | |
| 125 | return mDynamic0.get(uniforms,index,currentDuration,step); | |
| 126 | } | |
| 127 | else | |
| 128 |       {
 | |
| 129 | if( mStatic1 != null ) | |
| 130 |         {
 | |
| 131 | uniforms[index ] = ((Static1D)mStatic0).getX(); | |
| 132 | } | |
| 133 | else | |
| 134 |         {
 | |
| 135 | uniforms[index ] = ((Static4D)mStatic0).getX(); | |
| 136 | uniforms[index+1] = ((Static4D)mStatic0).getY(); | |
| 137 | uniforms[index+2] = ((Static4D)mStatic0).getZ(); | |
| 138 | uniforms[index+3] = ((Static4D)mStatic0).getW(); | |
| 139 | } | |
| 140 |  | |
| 141 | return false; | |
| 142 | } | |
| 60 | mCenter.get(uniforms,index+4,currentDuration,step); | |
| 61 | mAxis.get(uniforms,index+1,currentDuration,step); | |
| 62 | return mAngle.get(uniforms,index,currentDuration,step); | |
| 143 | 63 | } | 
| 144 | 64 | } | 
| src/main/java/org/distorted/library/effect/MatrixEffectScale.java | ||
|---|---|---|
| 27 | 27 |  | 
| 28 | 28 | public class MatrixEffectScale extends MatrixEffect | 
| 29 | 29 |   {
 | 
| 30 | private Data3D mScale; | |
| 31 |  | |
| 30 | 32 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 31 | 33 | /** | 
| 32 | 34 | * Scales the Object by (possibly changing in time) 3D scale factors. | 
| ... | ... | |
| 37 | 39 | public MatrixEffectScale(Data3D scale) | 
| 38 | 40 |     {
 | 
| 39 | 41 | super(EffectName.SCALE); | 
| 40 |  | |
| 41 | if( scale instanceof Static3D) | |
| 42 |       {
 | |
| 43 | mStatic0 = (Static3D)scale; | |
| 44 | } | |
| 45 | else if ( scale instanceof Dynamic3D) | |
| 46 |       {
 | |
| 47 | mDynamic0 = (Dynamic3D)scale; | |
| 48 | } | |
| 42 | mScale = scale; | |
| 49 | 43 | } | 
| 50 | 44 |  | 
| 51 | 45 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 57 | 51 | public MatrixEffectScale(float scale) | 
| 58 | 52 |     {
 | 
| 59 | 53 | super(EffectName.SCALE); | 
| 60 |  | |
| 61 | mStatic0 = new Static3D(scale,scale,scale); | |
| 54 | mScale = new Static3D(scale,scale,scale); | |
| 62 | 55 | } | 
| 63 | 56 |  | 
| 64 | 57 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 65 | 58 |  | 
| 66 | 59 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 67 | 60 |     {
 | 
| 68 | if( mDynamic0!=null ) | |
| 69 |       {
 | |
| 70 | return mDynamic0.get(uniforms,index,currentDuration,step); | |
| 71 | } | |
| 72 | else | |
| 73 |       {
 | |
| 74 | uniforms[index ] = ((Static3D)mStatic0).getX(); | |
| 75 | uniforms[index+1] = ((Static3D)mStatic0).getY(); | |
| 76 | uniforms[index+2] = ((Static3D)mStatic0).getZ(); | |
| 77 |  | |
| 78 | return false; | |
| 79 | } | |
| 61 | return mScale.get(uniforms,index,currentDuration,step); | |
| 80 | 62 | } | 
| 81 | 63 | } | 
| src/main/java/org/distorted/library/effect/MatrixEffectShear.java | ||
|---|---|---|
| 27 | 27 |  | 
| 28 | 28 | public class MatrixEffectShear extends MatrixEffect | 
| 29 | 29 |   {
 | 
| 30 | private Data3D mShear, mCenter; | |
| 31 |  | |
| 30 | 32 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 31 | 33 | /** | 
| 32 | 34 | * Shears the Object. | 
| ... | ... | |
| 40 | 42 | public MatrixEffectShear(Data3D shear, Data3D center) | 
| 41 | 43 |     {
 | 
| 42 | 44 | super(EffectName.SHEAR); | 
| 43 |  | |
| 44 | if( shear instanceof Static3D) | |
| 45 |       {
 | |
| 46 | mStatic0 = (Static3D)shear; | |
| 47 | } | |
| 48 | else if ( shear instanceof Dynamic3D) | |
| 49 |       {
 | |
| 50 | mDynamic0 = (Dynamic3D)shear; | |
| 51 | } | |
| 52 |  | |
| 53 | if( center instanceof Static3D) | |
| 54 |       {
 | |
| 55 | mStaticCenter = (Static3D)center; | |
| 56 | } | |
| 57 | else if( center instanceof Dynamic3D ) | |
| 58 |       {
 | |
| 59 | mDynamicCenter = (Dynamic3D)center; | |
| 60 | } | |
| 45 | mShear = shear; | |
| 46 | mCenter = center; | |
| 61 | 47 | } | 
| 62 | 48 |  | 
| 63 | 49 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 64 | 50 |  | 
| 65 | 51 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 66 | 52 |     {
 | 
| 67 | if( mDynamicCenter!=null ) | |
| 68 |       {
 | |
| 69 | mDynamicCenter.get(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.get(uniforms,index,currentDuration,step); | |
| 81 | } | |
| 82 | else | |
| 83 |       {
 | |
| 84 | uniforms[index ] = ((Static3D)mStatic0).getX(); | |
| 85 | uniforms[index+1] = ((Static3D)mStatic0).getY(); | |
| 86 | uniforms[index+2] = ((Static3D)mStatic0).getZ(); | |
| 87 |  | |
| 88 | return false; | |
| 89 | } | |
| 53 | mCenter.get(uniforms,index+4,currentDuration,step); | |
| 54 | return mShear.get(uniforms,index,currentDuration,step); | |
| 90 | 55 | } | 
| 91 | 56 | } | 
| src/main/java/org/distorted/library/effect/PostprocessEffect.java | ||
|---|---|---|
| 19 | 19 |  | 
| 20 | 20 | package org.distorted.library.effect; | 
| 21 | 21 |  | 
| 22 | import org.distorted.library.type.Dynamic; | |
| 23 | import org.distorted.library.type.Static; | |
| 24 |  | |
| 25 | 22 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 26 | 23 | // POSTPROCESSING EFFECTS. | 
| 27 | // 5 Uniforms: 5 per-effect interpolated values. | |
| 24 |  | |
| 28 | 25 |  | 
| 29 | 26 | public abstract class PostprocessEffect extends Effect | 
| 30 | 27 |   {
 | 
| 31 | public static final int NUM_UNIFORMS = 5; | |
| 32 |  | |
| 33 | Dynamic mDynamic0, mDynamic1; | |
| 34 | Static mStatic0, mStatic1; | |
| 28 | public static final int NUM_UNIFORMS = 5; // 5 per-effect interpolated values. | |
| 35 | 29 |  | 
| 36 | 30 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 37 | 31 |  | 
| src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java | ||
|---|---|---|
| 27 | 27 |  | 
| 28 | 28 | public class PostprocessEffectBlur extends PostprocessEffect | 
| 29 | 29 |   {
 | 
| 30 | private Data1D mBlurRadius; | |
| 31 |  | |
| 30 | 32 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 31 | 33 | /** | 
| 32 | 34 | * Blur the object. | 
| 33 | 35 | * | 
| 34 |  * @param radius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
 | |
| 35 | * take into account 10 pixels in each direction. | |
| 36 |  * @param blurRadius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
 | |
| 37 |  *                   take into account 10 pixels in each direction.
 | |
| 36 | 38 | */ | 
| 37 |   public PostprocessEffectBlur(Data1D radius)
 | |
| 39 |   public PostprocessEffectBlur(Data1D blurRadius)
 | |
| 38 | 40 |     {
 | 
| 39 | 41 | super(EffectName.BLUR); | 
| 40 |  | |
| 41 | if( radius instanceof Dynamic1D) | |
| 42 |       {
 | |
| 43 | mDynamic0 = (Dynamic1D)radius; | |
| 44 | } | |
| 45 | else if ( radius instanceof Static1D ) | |
| 46 |       {
 | |
| 47 | mStatic0 = (Static1D)radius; | |
| 48 | } | |
| 42 | mBlurRadius = blurRadius; | |
| 49 | 43 | } | 
| 50 | 44 |  | 
| 51 | 45 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 52 | 46 |  | 
| 53 | 47 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 54 | 48 |     {
 | 
| 55 | if( mDynamic0!=null ) | |
| 56 |       {
 | |
| 57 | return mDynamic0.get(uniforms,index,currentDuration,step); | |
| 58 | } | |
| 59 | else | |
| 60 |       {
 | |
| 61 | uniforms[index] = ((Static1D)mStatic0).getX(); | |
| 62 | return false; | |
| 63 | } | |
| 49 | return mBlurRadius.get(uniforms,index,currentDuration,step); | |
| 64 | 50 | } | 
| 65 | 51 | } | 
| src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
|---|---|---|
| 30 | 30 |  | 
| 31 | 31 | public class PostprocessEffectGlow extends PostprocessEffect | 
| 32 | 32 |   {
 | 
| 33 | private Data1D mGlowRadius; | |
| 34 | private Data4D mColor; | |
| 35 |  | |
| 33 | 36 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 34 | 37 | /** | 
| 35 | 38 | * Make the object glow with a specific color and a halo of specific radius. | 
| 36 | 39 | * | 
| 37 |  * @param radius The 'strength' if the effect, in pixels. 0 = no halo, 10 = halo of roughly 10 pixels
 | |
| 38 | * around the whole object. | |
| 39 | * @param color RGBA of the color with which to draw the glow. | |
| 40 |  * @param glowRadius The 'strength' if the effect, in pixels. 0 = no halo, 10 = halo of roughly 10 pixels
 | |
| 41 |  *                   around the whole object.
 | |
| 42 |  * @param color      RGBA of the color with which to draw the glow.
 | |
| 40 | 43 | */ | 
| 41 |   public PostprocessEffectGlow(Data1D radius, Data4D color)
 | |
| 44 |   public PostprocessEffectGlow(Data1D glowRadius, Data4D color)
 | |
| 42 | 45 |     {
 | 
| 43 | 46 | super(EffectName.GLOW); | 
| 44 |  | |
| 45 | if( radius instanceof Dynamic1D) | |
| 46 |       {
 | |
| 47 | mDynamic0 = (Dynamic1D)radius; | |
| 48 | } | |
| 49 | else if ( radius instanceof Static1D ) | |
| 50 |       {
 | |
| 51 | mStatic0 = (Static1D)radius; | |
| 52 | } | |
| 53 |  | |
| 54 | if( color instanceof Dynamic4D) | |
| 55 |       {
 | |
| 56 | mDynamic1 = (Dynamic4D)color; | |
| 57 | } | |
| 58 | else if ( color instanceof Static4D) | |
| 59 |       {
 | |
| 60 | mStatic1 = (Static4D)color; | |
| 61 | } | |
| 47 | mGlowRadius = glowRadius; | |
| 48 | mColor = color; | |
| 62 | 49 | } | 
| 63 | 50 |  | 
| 64 | 51 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 65 | 52 |  | 
| 66 | 53 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 67 | 54 |     {
 | 
| 68 | if( mDynamic1!=null ) | |
| 69 |       {
 | |
| 70 | mDynamic1.get(uniforms,index+1,currentDuration,step); | |
| 71 | } | |
| 72 | else | |
| 73 |       {
 | |
| 74 | uniforms[index+1] = ((Static4D)mStatic1).getX(); | |
| 75 | uniforms[index+2] = ((Static4D)mStatic1).getY(); | |
| 76 | uniforms[index+3] = ((Static4D)mStatic1).getZ(); | |
| 77 | uniforms[index+4] = ((Static4D)mStatic1).getW(); | |
| 78 | } | |
| 79 |  | |
| 80 | if( mDynamic0!=null ) | |
| 81 |       {
 | |
| 82 | return mDynamic0.get(uniforms,index,currentDuration,step); | |
| 83 | } | |
| 84 | else | |
| 85 |       {
 | |
| 86 | uniforms[index ] = ((Static1D)mStatic0).getX(); | |
| 87 | return false; | |
| 88 | } | |
| 55 | mColor.get(uniforms,index+1,currentDuration,step); | |
| 56 | return mGlowRadius.get(uniforms,index,currentDuration,step); | |
| 89 | 57 | } | 
| 90 | 58 | } | 
| 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.Dynamic; | |
| 23 | import org.distorted.library.type.Dynamic3D; | |
| 24 | import org.distorted.library.type.Dynamic4D; | |
| 25 | import org.distorted.library.type.Static; | |
| 26 | import org.distorted.library.type.Static3D; | |
| 27 | import org.distorted.library.type.Static4D; | |
| 28 |  | |
| 29 | 22 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 30 | 23 | // VERTEX EFFECTS | 
| 31 | // 12 Uniforms: 5 per-effect interpolated values, 3-dimensional center, 4-dimensional Region | |
| 32 | 24 |  | 
| 33 | 25 | public abstract class VertexEffect extends Effect | 
| 34 | 26 |   {
 | 
| 35 | public static final int NUM_UNIFORMS = 12; | |
| 27 |   public static final int NUM_UNIFORMS = 12; // 5 per-effect interpolated values, 3-dimensional center, 4-dimensional Region
 | |
| 36 | 28 |  | 
| 37 | Dynamic mDynamic0; | |
| 38 | Static mStatic0; | |
| 39 | Dynamic3D mDynamicCenter; | |
| 40 | Static3D mStaticCenter; | |
| 41 | Dynamic4D mDynamicRegion; | |
| 42 | Static4D mStaticRegion; | |
| 43 | 29 |  | 
| 44 | 30 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 45 | 31 |  | 
| src/main/java/org/distorted/library/effect/VertexEffectDeform.java | ||
|---|---|---|
| 30 | 30 |  | 
| 31 | 31 | public class VertexEffectDeform extends VertexEffect | 
| 32 | 32 |   {
 | 
| 33 | private Data3D mVector, mCenter; | |
| 34 | private Data4D mRegion; | |
| 35 |  | |
| 33 | 36 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 34 | 37 | /** | 
| 35 | 38 | * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to | 
| ... | ... | |
| 42 | 45 | public VertexEffectDeform(Data3D vector, Data3D center, Data4D region) | 
| 43 | 46 |     {
 | 
| 44 | 47 | super(EffectName.DEFORM); | 
| 45 |  | |
| 46 | if( vector instanceof Dynamic3D ) | |
| 47 |       {
 | |
| 48 | mDynamic0 = (Dynamic3D)vector; | |
| 49 | } | |
| 50 | else if ( vector instanceof Static3D ) | |
| 51 |       {
 | |
| 52 | mStatic0 = (Static3D)vector; | |
| 53 | } | |
| 54 |  | |
| 55 | if( center instanceof Static3D) | |
| 56 |       {
 | |
| 57 | mStaticCenter = (Static3D)center; | |
| 58 | } | |
| 59 | else if( center instanceof Dynamic3D ) | |
| 60 |       {
 | |
| 61 | mDynamicCenter = (Dynamic3D)center; | |
| 62 | } | |
| 63 |  | |
| 64 | if( region == null ) | |
| 65 |       {
 | |
| 66 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 67 | } | |
| 68 | else | |
| 69 |       {
 | |
| 70 | if (region instanceof Static4D) | |
| 71 |         {
 | |
| 72 | mStaticRegion = (Static4D) region; | |
| 73 | } | |
| 74 | else if (region instanceof Dynamic4D) | |
| 75 |         {
 | |
| 76 | mDynamicRegion = (Dynamic4D) region; | |
| 77 | } | |
| 78 | } | |
| 48 | mVector = vector; | |
| 49 | mCenter = center; | |
| 50 | mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); | |
| 79 | 51 | } | 
| 80 | 52 |  | 
| 81 | 53 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 89 | 61 | public VertexEffectDeform(Data3D vector, Data3D center) | 
| 90 | 62 |     {
 | 
| 91 | 63 | super(EffectName.DEFORM); | 
| 92 |  | |
| 93 | if( vector instanceof Dynamic3D ) | |
| 94 |       {
 | |
| 95 | mDynamic0 = (Dynamic3D)vector; | |
| 96 | } | |
| 97 | else if ( vector instanceof Static3D ) | |
| 98 |       {
 | |
| 99 | mStatic0 = (Static3D)vector; | |
| 100 | } | |
| 101 |  | |
| 102 | if( center instanceof Static3D) | |
| 103 |       {
 | |
| 104 | mStaticCenter = (Static3D)center; | |
| 105 | } | |
| 106 | else if( center instanceof Dynamic3D ) | |
| 107 |       {
 | |
| 108 | mDynamicCenter = (Dynamic3D)center; | |
| 109 | } | |
| 110 |  | |
| 111 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 64 | mVector = vector; | |
| 65 | mCenter = center; | |
| 66 | mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 112 | 67 | } | 
| 113 | 68 |  | 
| 114 | 69 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 115 | 70 |  | 
| 116 | 71 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 117 | 72 |     {
 | 
| 118 | boolean ret = false; | |
| 119 |  | |
| 120 | if( mDynamicCenter!=null ) | |
| 121 |       {
 | |
| 122 | mDynamicCenter.get(uniforms,index+5,currentDuration,step); | |
| 123 | } | |
| 124 | else | |
| 125 |       {
 | |
| 126 | uniforms[index+5] = mStaticCenter.getX(); | |
| 127 | uniforms[index+6] = mStaticCenter.getY(); | |
| 128 | uniforms[index+7] = mStaticCenter.getZ(); | |
| 129 | } | |
| 130 |  | |
| 131 | if( mDynamicRegion!=null ) | |
| 132 |       {
 | |
| 133 | mDynamicRegion.get(uniforms,index+8,currentDuration,step); | |
| 134 | } | |
| 135 | else | |
| 136 |       {
 | |
| 137 | uniforms[index+ 8] = mStaticRegion.getX(); | |
| 138 | uniforms[index+ 9] = mStaticRegion.getY(); | |
| 139 | uniforms[index+10] = mStaticRegion.getZ(); | |
| 140 | uniforms[index+11] = mStaticRegion.getW(); | |
| 141 | } | |
| 142 |  | |
| 143 | if( mDynamic0!=null ) | |
| 144 |       {
 | |
| 145 | ret = mDynamic0.get(uniforms,index,currentDuration,step); | |
| 146 | } | |
| 147 | else | |
| 148 |       {
 | |
| 149 | uniforms[index ] = ((Static3D)mStatic0).getX(); | |
| 150 | uniforms[index+1] = ((Static3D)mStatic0).getY(); | |
| 151 | uniforms[index+2] = ((Static3D)mStatic0).getZ(); | |
| 152 | } | |
| 73 | mCenter.get(uniforms,index+5,currentDuration,step); | |
| 74 | mRegion.get(uniforms,index+8,currentDuration,step); | |
| 75 | boolean ret = mVector.get(uniforms,index,currentDuration,step); | |
| 153 | 76 |  | 
| 154 | 77 | uniforms[index+9] =-uniforms[index+9]; | 
| 155 | 78 |  | 
| src/main/java/org/distorted/library/effect/VertexEffectDistort.java | ||
|---|---|---|
| 30 | 30 |  | 
| 31 | 31 | public class VertexEffectDistort extends VertexEffect | 
| 32 | 32 |   {
 | 
| 33 | private Data3D mVector, mCenter; | |
| 34 | private Data4D mRegion; | |
| 35 |  | |
| 33 | 36 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 34 | 37 | /** | 
| 35 | 38 | * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force. | 
| ... | ... | |
| 42 | 45 | public VertexEffectDistort(Data3D vector, Data3D center, Data4D region) | 
| 43 | 46 |     {
 | 
| 44 | 47 | super(EffectName.DISTORT); | 
| 45 |  | |
| 46 | if( vector instanceof Dynamic3D ) | |
| 47 |       {
 | |
| 48 | mDynamic0 = (Dynamic3D)vector; | |
| 49 | } | |
| 50 | else if ( vector instanceof Static3D ) | |
| 51 |       {
 | |
| 52 | mStatic0 = (Static3D)vector; | |
| 53 | } | |
| 54 |  | |
| 55 | if( center instanceof Static3D) | |
| 56 |       {
 | |
| 57 | mStaticCenter = (Static3D)center; | |
| 58 | } | |
| 59 | else if( center instanceof Dynamic3D ) | |
| 60 |       {
 | |
| 61 | mDynamicCenter = (Dynamic3D)center; | |
| 62 | } | |
| 63 |  | |
| 64 | if( region == null ) | |
| 65 |       {
 | |
| 66 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 67 | } | |
| 68 | else | |
| 69 |       {
 | |
| 70 | if (region instanceof Static4D) | |
| 71 |         {
 | |
| 72 | mStaticRegion = (Static4D) region; | |
| 73 | } | |
| 74 | else if (region instanceof Dynamic4D) | |
| 75 |         {
 | |
| 76 | mDynamicRegion = (Dynamic4D) region; | |
| 77 | } | |
| 78 | } | |
| 48 | mVector = vector; | |
| 49 | mCenter = center; | |
| 50 | mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); | |
| 79 | 51 | } | 
| 80 | 52 |  | 
| 81 | 53 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 89 | 61 | public VertexEffectDistort(Data3D vector, Data3D center) | 
| 90 | 62 |     {
 | 
| 91 | 63 | super(EffectName.DISTORT); | 
| 92 |  | |
| 93 | if( vector instanceof Dynamic3D ) | |
| 94 |       {
 | |
| 95 | mDynamic0 = (Dynamic3D)vector; | |
| 96 | } | |
| 97 | else if ( vector instanceof Static3D ) | |
| 98 |       {
 | |
| 99 | mStatic0 = (Static3D)vector; | |
| 100 | } | |
| 101 |  | |
| 102 | if( center instanceof Static3D) | |
| 103 |       {
 | |
| 104 | mStaticCenter = (Static3D)center; | |
| 105 | } | |
| 106 | else if( center instanceof Dynamic3D ) | |
| 107 |       {
 | |
| 108 | mDynamicCenter = (Dynamic3D)center; | |
| 109 | } | |
| 110 |  | |
| 111 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 64 | mVector = vector; | |
| 65 | mCenter = center; | |
| 66 | mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 112 | 67 | } | 
| 113 | 68 |  | 
| 114 | 69 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 115 | 70 |  | 
| 116 | 71 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 117 | 72 |     {
 | 
| 118 | boolean ret = false; | |
| 119 |  | |
| 120 | if( mDynamicCenter!=null ) | |
| 121 |       {
 | |
| 122 | mDynamicCenter.get(uniforms,index+5,currentDuration,step); | |
| 123 | } | |
| 124 | else | |
| 125 |       {
 | |
| 126 | uniforms[index+5] = mStaticCenter.getX(); | |
| 127 | uniforms[index+6] = mStaticCenter.getY(); | |
| 128 | uniforms[index+7] = mStaticCenter.getZ(); | |
| 129 | } | |
| 130 |  | |
| 131 | if( mDynamicRegion!=null ) | |
| 132 |       {
 | |
| 133 | mDynamicRegion.get(uniforms,index+8,currentDuration,step); | |
| 134 | } | |
| 135 | else | |
| 136 |       {
 | |
| 137 | uniforms[index+ 8] = mStaticRegion.getX(); | |
| 138 | uniforms[index+ 9] = mStaticRegion.getY(); | |
| 139 | uniforms[index+10] = mStaticRegion.getZ(); | |
| 140 | uniforms[index+11] = mStaticRegion.getW(); | |
| 141 | } | |
| 142 |  | |
| 143 | if( mDynamic0!=null ) | |
| 144 |       {
 | |
| 145 | ret = mDynamic0.get(uniforms,index,currentDuration,step); | |
| 146 | } | |
| 147 | else | |
| 148 |       {
 | |
| 149 | uniforms[index ] = ((Static3D)mStatic0).getX(); | |
| 150 | uniforms[index+1] = ((Static3D)mStatic0).getY(); | |
| 151 | uniforms[index+2] = ((Static3D)mStatic0).getZ(); | |
| 152 | } | |
| 73 | mCenter.get(uniforms,index+5,currentDuration,step); | |
| 74 | mRegion.get(uniforms,index+8,currentDuration,step); | |
| 75 | boolean ret = mVector.get(uniforms,index,currentDuration,step); | |
| 153 | 76 |  | 
| 154 | 77 | uniforms[index+1] =-uniforms[index+1]; | 
| 155 | 78 | uniforms[index+9] =-uniforms[index+9]; | 
| src/main/java/org/distorted/library/effect/VertexEffectPinch.java | ||
|---|---|---|
| 33 | 33 |  | 
| 34 | 34 | public class VertexEffectPinch extends VertexEffect | 
| 35 | 35 |   {
 | 
| 36 | private Data2D mPinch; | |
| 37 | private Data3D mCenter; | |
| 38 | private Data4D mRegion; | |
| 39 |  | |
| 36 | 40 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 37 | 41 | /** | 
| 38 | 42 | * Pull all points around the center of the Effect towards a line passing through the center | 
| ... | ... | |
| 45 | 49 | public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region) | 
| 46 | 50 |     {
 | 
| 47 | 51 | super(EffectName.PINCH); | 
| 48 |  | |
| 49 | if( pinch instanceof Dynamic2D) | |
| 50 |       {
 | |
| 51 | mDynamic0 = (Dynamic2D)pinch; | |
| 52 | } | |
| 53 | else if ( pinch instanceof Static2D ) | |
| 54 |       {
 | |
| 55 | mStatic0 = (Static2D)pinch; | |
| 56 | } | |
| 57 |  | |
| 58 | if( center instanceof Static3D) | |
| 59 |       {
 | |
| 60 | mStaticCenter = (Static3D)center; | |
| 61 | } | |
| 62 | else if( center instanceof Dynamic3D) | |
| 63 |       {
 | |
| 64 | mDynamicCenter = (Dynamic3D)center; | |
| 65 | } | |
| 66 |  | |
| 67 | if( region == null ) | |
| 68 |       {
 | |
| 69 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 70 | } | |
| 71 | else | |
| 72 |       {
 | |
| 73 | if (region instanceof Static4D) | |
| 74 |         {
 | |
| 75 | mStaticRegion = (Static4D) region; | |
| 76 | } | |
| 77 | else if (region instanceof Dynamic4D) | |
| 78 |         {
 | |
| 79 | mDynamicRegion = (Dynamic4D) region; | |
| 80 | } | |
| 81 | } | |
| 52 | mPinch = pinch; | |
| 53 | mCenter = center; | |
| 54 | mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); | |
| 82 | 55 | } | 
| 83 | 56 |  | 
| 84 | 57 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 92 | 65 | public VertexEffectPinch(Data2D pinch, Data3D center) | 
| 93 | 66 |     {
 | 
| 94 | 67 | super(EffectName.PINCH); | 
| 95 |  | |
| 96 | if( pinch instanceof Dynamic2D) | |
| 97 |       {
 | |
| 98 | mDynamic0 = (Dynamic2D)pinch; | |
| 99 | } | |
| 100 | else if ( pinch instanceof Static2D ) | |
| 101 |       {
 | |
| 102 | mStatic0 = (Static2D)pinch; | |
| 103 | } | |
| 104 |  | |
| 105 | if( center instanceof Static3D) | |
| 106 |       {
 | |
| 107 | mStaticCenter = (Static3D)center; | |
| 108 | } | |
| 109 | else if( center instanceof Dynamic3D ) | |
| 110 |       {
 | |
| 111 | mDynamicCenter = (Dynamic3D)center; | |
| 112 | } | |
| 113 |  | |
| 114 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 68 | mPinch = pinch; | |
| 69 | mCenter = center; | |
| 70 | mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 115 | 71 | } | 
| 116 | 72 |  | 
| 117 | 73 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 118 | 74 |  | 
| 119 | 75 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 120 | 76 |     {
 | 
| 121 | boolean ret= false; | |
| 122 |  | |
| 123 | if( mDynamicCenter!=null ) | |
| 124 |       {
 | |
| 125 | mDynamicCenter.get(uniforms,index+5,currentDuration,step); | |
| 126 | } | |
| 127 | else | |
| 128 |       {
 | |
| 129 | uniforms[index+5] = mStaticCenter.getX(); | |
| 130 | uniforms[index+6] = mStaticCenter.getY(); | |
| 131 | uniforms[index+7] = mStaticCenter.getZ(); | |
| 132 | } | |
| 133 |  | |
| 134 | if( mDynamicRegion!=null ) | |
| 135 |       {
 | |
| 136 | mDynamicRegion.get(uniforms,index+8,currentDuration,step); | |
| 137 | } | |
| 138 | else | |
| 139 |       {
 | |
| 140 | uniforms[index+ 8] = mStaticRegion.getX(); | |
| 141 | uniforms[index+ 9] = mStaticRegion.getY(); | |
| 142 | uniforms[index+10] = mStaticRegion.getZ(); | |
| 143 | uniforms[index+11] = mStaticRegion.getW(); | |
| 144 | } | |
| 145 |  | |
| 146 | if( mDynamic0!=null ) | |
| 147 |       {
 | |
| 148 | ret = mDynamic0.get(uniforms,index,currentDuration,step); | |
| 149 | } | |
| 150 | else | |
| 151 |       {
 | |
| 152 | uniforms[index ] = ((Static2D)mStatic0).getX(); | |
| 153 | uniforms[index+1] = ((Static2D)mStatic0).getY(); | |
| 154 | } | |
| 77 | mCenter.get(uniforms,index+5,currentDuration,step); | |
| 78 | mRegion.get(uniforms,index+8,currentDuration,step); | |
| 79 | boolean ret = mPinch.get(uniforms,index,currentDuration,step); | |
| 155 | 80 |  | 
| 156 | 81 | uniforms[index+1] = (float)(Math.PI*uniforms[index+1]/180); | 
| 157 | 82 | uniforms[index+9] =-uniforms[index+9]; | 
| src/main/java/org/distorted/library/effect/VertexEffectSink.java | ||
|---|---|---|
| 33 | 33 |  | 
| 34 | 34 | public class VertexEffectSink extends VertexEffect | 
| 35 | 35 |   {
 | 
| 36 | private Data1D mSink; | |
| 37 | private Data3D mCenter; | |
| 38 | private Data4D mRegion; | |
| 39 |  | |
| 36 | 40 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 37 | 41 | /** | 
| 38 | 42 | * Pull all points around the center of the Effect towards the center (if degree>=1) or push them | 
| ... | ... | |
| 45 | 49 | public VertexEffectSink(Data1D sink, Data3D center, Data4D region) | 
| 46 | 50 |     {
 | 
| 47 | 51 | super(EffectName.SINK); | 
| 48 |  | |
| 49 | if( sink instanceof Dynamic1D) | |
| 50 |       {
 | |
| 51 | mDynamic0 = (Dynamic1D)sink; | |
| 52 | } | |
| 53 | else if ( sink instanceof Static1D ) | |
| 54 |       {
 | |
| 55 | mStatic0 = (Static1D)sink; | |
| 56 | } | |
| 57 |  | |
| 58 | if( center instanceof Static3D) | |
| 59 |       {
 | |
| 60 | mStaticCenter = (Static3D)center; | |
| 61 | } | |
| 62 | else if( center instanceof Dynamic3D) | |
| 63 |       {
 | |
| 64 | mDynamicCenter = (Dynamic3D)center; | |
| 65 | } | |
| 66 |  | |
| 67 | if( region == null ) | |
| 68 |       {
 | |
| 69 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 70 | } | |
| 71 | else | |
| 72 |       {
 | |
| 73 | if (region instanceof Static4D) | |
| 74 |         {
 | |
| 75 | mStaticRegion = (Static4D) region; | |
| 76 | } | |
| 77 | else if (region instanceof Dynamic4D) | |
| 78 |         {
 | |
| 79 | mDynamicRegion = (Dynamic4D) region; | |
| 80 | } | |
| 81 | } | |
| 52 | mSink = sink; | |
| 53 | mCenter = center; | |
| 54 | mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); | |
| 82 | 55 | } | 
| 83 | 56 |  | 
| 84 | 57 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 92 | 65 | public VertexEffectSink(Data1D sink, Data3D center) | 
| 93 | 66 |     {
 | 
| 94 | 67 | super(EffectName.SINK); | 
| 95 |  | |
| 96 | if( sink instanceof Dynamic1D) | |
| 97 |       {
 | |
| 98 | mDynamic0 = (Dynamic1D)sink; | |
| 99 | } | |
| 100 | else if ( sink instanceof Static1D ) | |
| 101 |       {
 | |
| 102 | mStatic0 = (Static1D)sink; | |
| 103 | } | |
| 104 |  | |
| 105 | if( center instanceof Static3D) | |
| 106 |       {
 | |
| 107 | mStaticCenter = (Static3D)center; | |
| 108 | } | |
| 109 | else if( center instanceof Dynamic3D ) | |
| 110 |       {
 | |
| 111 | mDynamicCenter = (Dynamic3D)center; | |
| 112 | } | |
| 113 |  | |
| 114 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 68 | mSink = sink; | |
| 69 | mCenter = center; | |
| 70 | mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 115 | 71 | } | 
| 116 | 72 |  | 
| 117 | 73 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 118 | 74 |  | 
| 119 | 75 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 120 | 76 |     {
 | 
| 121 | boolean ret = false; | |
| 122 |  | |
| 123 | if( mDynamicCenter!=null ) | |
| 124 |       {
 | |
| 125 | mDynamicCenter.get(uniforms,index+5,currentDuration,step); | |
| 126 | } | |
| 127 | else | |
| 128 |       {
 | |
| 129 | uniforms[index+5] = mStaticCenter.getX(); | |
| 130 | uniforms[index+6] = mStaticCenter.getY(); | |
| 131 | uniforms[index+7] = mStaticCenter.getZ(); | |
| 132 | } | |
| 133 |  | |
| 134 | if( mDynamicRegion!=null ) | |
| 135 |       {
 | |
| 136 | mDynamicRegion.get(uniforms,index+8,currentDuration,step); | |
| 137 | } | |
| 138 | else | |
| 139 |       {
 | |
| 140 | uniforms[index+ 8] = mStaticRegion.getX(); | |
| 141 | uniforms[index+ 9] = mStaticRegion.getY(); | |
| 142 | uniforms[index+10] = mStaticRegion.getZ(); | |
| 143 | uniforms[index+11] = mStaticRegion.getW(); | |
| 144 | } | |
| 145 |  | |
| 146 | if( mDynamic0!=null ) | |
| 147 |       {
 | |
| 148 | ret = mDynamic0.get(uniforms,index,currentDuration,step); | |
| 149 | } | |
| 150 | else | |
| 151 |       {
 | |
| 152 | uniforms[index ] = ((Static1D)mStatic0).getX(); | |
| 153 | } | |
| 77 | mCenter.get(uniforms,index+5,currentDuration,step); | |
| 78 | mRegion.get(uniforms,index+8,currentDuration,step); | |
| 79 | boolean ret = mSink.get(uniforms,index,currentDuration,step); | |
| 154 | 80 |  | 
| 155 | 81 | uniforms[index+9] =-uniforms[index+9]; | 
| 156 | 82 |  | 
| src/main/java/org/distorted/library/effect/VertexEffectSwirl.java | ||
|---|---|---|
| 33 | 33 |  | 
| 34 | 34 | public class VertexEffectSwirl extends VertexEffect | 
| 35 | 35 |   {
 | 
| 36 | private Data1D mSwirl; | |
| 37 | private Data3D mCenter; | |
| 38 | private Data4D mRegion; | |
| 39 |  | |
| 36 | 40 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 37 | 41 | /** | 
| 38 | 42 | * Rotate part of the Object around the Center of the Effect by a certain angle. | 
| ... | ... | |
| 44 | 48 | public VertexEffectSwirl(Data1D swirl, Data3D center, Data4D region) | 
| 45 | 49 |     {
 | 
| 46 | 50 | super(EffectName.SWIRL); | 
| 47 |  | |
| 48 | if( swirl instanceof Dynamic1D) | |
| 49 |       {
 | |
| 50 | mDynamic0 = (Dynamic1D)swirl; | |
| 51 | } | |
| 52 | else if ( swirl instanceof Static1D ) | |
| 53 |       {
 | |
| 54 | mStatic0 = (Static1D)swirl; | |
| 55 | } | |
| 56 |  | |
| 57 | if( center instanceof Static3D) | |
| 58 |       {
 | |
| 59 | mStaticCenter = (Static3D)center; | |
| 60 | } | |
| 61 | else if( center instanceof Dynamic3D) | |
| 62 |       {
 | |
| 63 | mDynamicCenter = (Dynamic3D)center; | |
| 64 | } | |
| 65 |  | |
| 66 | if( region == null ) | |
| 67 |       {
 | |
| 68 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 69 | } | |
| 70 | else | |
| 71 |       {
 | |
| 72 | if (region instanceof Static4D) | |
| 73 |         {
 | |
| 74 | mStaticRegion = (Static4D) region; | |
| 75 | } | |
| 76 | else if (region instanceof Dynamic4D) | |
| 77 |         {
 | |
| 78 | mDynamicRegion = (Dynamic4D) region; | |
| 79 | } | |
| 80 | } | |
| 51 | mSwirl = swirl; | |
| 52 | mCenter = center; | |
| 53 | mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); | |
| 81 | 54 | } | 
| 82 | 55 |  | 
| 83 | 56 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 90 | 63 | public VertexEffectSwirl(Data1D swirl, Data3D center) | 
| 91 | 64 |     {
 | 
| 92 | 65 | super(EffectName.SWIRL); | 
| 93 |  | |
| 94 | if( swirl instanceof Dynamic1D) | |
| 95 |       {
 | |
| 96 | mDynamic0 = (Dynamic1D)swirl; | |
| 97 | } | |
| 98 | else if ( swirl instanceof Static1D ) | |
| 99 |       {
 | |
| 100 | mStatic0 = (Static1D)swirl; | |
| 101 | } | |
| 102 |  | |
| 103 | if( center instanceof Static3D) | |
| 104 |       {
 | |
| 105 | mStaticCenter = (Static3D)center; | |
| 106 | } | |
| 107 | else if( center instanceof Dynamic3D ) | |
| 108 |       {
 | |
| 109 | mDynamicCenter = (Dynamic3D)center; | |
| 110 | } | |
| 111 |  | |
| 112 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 66 | mSwirl = swirl; | |
| 67 | mCenter = center; | |
| 68 | mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 113 | 69 | } | 
| 114 | 70 |  | 
| 115 | 71 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 116 | 72 |  | 
| 117 | 73 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 118 | 74 |     {
 | 
| 119 | boolean ret = false; | |
| 120 |  | |
| 121 | if( mDynamicCenter!=null ) | |
| 122 |       {
 | |
| 123 | mDynamicCenter.get(uniforms,index+5,currentDuration,step); | |
| 124 | } | |
| 125 | else | |
| 126 |       {
 | |
| 127 | uniforms[index+5] = mStaticCenter.getX(); | |
| 128 | uniforms[index+6] = mStaticCenter.getY(); | |
| 129 | uniforms[index+7] = mStaticCenter.getZ(); | |
| 130 | } | |
| 131 |  | |
| 132 | if( mDynamicRegion!=null ) | |
| 133 |       {
 | |
| 134 | mDynamicRegion.get(uniforms,index+8,currentDuration,step); | |
| 135 | } | |
| 136 | else | |
| 137 |       {
 | |
| 138 | uniforms[index+ 8] = mStaticRegion.getX(); | |
| 139 | uniforms[index+ 9] = mStaticRegion.getY(); | |
| 140 | uniforms[index+10] = mStaticRegion.getZ(); | |
| 141 | uniforms[index+11] = mStaticRegion.getW(); | |
| 142 | } | |
| 143 |  | |
| 144 | if( mDynamic0!=null ) | |
| 145 |       {
 | |
| 146 | ret = mDynamic0.get(uniforms,index,currentDuration,step); | |
| 147 | } | |
| 148 | else | |
| 149 |       {
 | |
| 150 | uniforms[index ] = ((Static1D)mStatic0).getX(); | |
| 151 | } | |
| 75 | mCenter.get(uniforms,index+5,currentDuration,step); | |
| 76 | mRegion.get(uniforms,index+8,currentDuration,step); | |
| 77 | boolean ret = mSwirl.get(uniforms,index,currentDuration,step); | |
| 152 | 78 |  | 
| 153 | 79 | uniforms[index ] = (float)(Math.PI*uniforms[index]/180); | 
| 154 | 80 | uniforms[index+9] =-uniforms[index+9]; | 
| src/main/java/org/distorted/library/effect/VertexEffectWave.java | ||
|---|---|---|
| 33 | 33 |  | 
| 34 | 34 | public class VertexEffectWave extends VertexEffect | 
| 35 | 35 |   {
 | 
| 36 | private Data5D mWave; | |
| 37 | private Data3D mCenter; | |
| 38 | private Data4D mRegion; | |
| 39 |  | |
| 36 | 40 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 37 | 41 | /** | 
| 38 | 42 | * Directional, sinusoidal wave effect. | 
| ... | ... | |
| 60 | 64 | * is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the | 
| 61 | 65 | * value if sin at this point. | 
| 62 | 66 | * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. | 
| 67 | * @param region Region that masks the Effect. | |
| 63 | 68 | */ | 
| 64 | public VertexEffectWave(Data5D wave, Data3D center) | |
| 69 |   public VertexEffectWave(Data5D wave, Data3D center, Data4D region)
 | |
| 65 | 70 |     {
 | 
| 66 | 71 | super(EffectName.WAVE); | 
| 67 |  | |
| 68 | if( wave instanceof Dynamic5D) | |
| 69 |       {
 | |
| 70 | mDynamic0 = (Dynamic5D)wave; | |
| 71 | } | |
| 72 | else if ( wave instanceof Static5D) | |
| 73 |       {
 | |
| 74 | mStatic0 = (Static5D)wave; | |
| 75 | } | |
| 76 |  | |
| 77 | if( center instanceof Static3D) | |
| 78 |       {
 | |
| 79 | mStaticCenter = (Static3D)center; | |
| 80 | } | |
| 81 | else if( center instanceof Dynamic3D ) | |
| 82 |       {
 | |
| 83 | mDynamicCenter = (Dynamic3D)center; | |
| 84 | } | |
| 85 |  | |
| 86 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 72 | mWave = wave; | |
| 73 | mCenter = center; | |
| 74 | mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); | |
| 87 | 75 | } | 
| 88 | 76 |  | 
| 89 | 77 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 92 | 80 | * | 
| 93 | 81 |  * @param wave   see {@link VertexEffectWave(Data5D,Data3D)}
 | 
| 94 | 82 | * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. | 
| 95 | * @param region Region that masks the Effect. | |
| 96 | 83 | */ | 
| 97 |   public VertexEffectWave(Data5D wave, Data3D center, Data4D region)
 | |
| 84 | public VertexEffectWave(Data5D wave, Data3D center) | |
| 98 | 85 |     {
 | 
| 99 | 86 | super(EffectName.WAVE); | 
| 100 |  | |
| 101 | if( wave instanceof Dynamic5D) | |
| 102 |       {
 | |
| 103 | mDynamic0 = (Dynamic5D)wave; | |
| 104 | } | |
| 105 | else if ( wave instanceof Static5D) | |
| 106 |       {
 | |
| 107 | mStatic0 = (Static5D)wave; | |
| 108 | } | |
| 109 |  | |
| 110 | if( center instanceof Static3D) | |
| 111 |       {
 | |
| 112 | mStaticCenter = (Static3D)center; | |
| 113 | } | |
| 114 | else if( center instanceof Dynamic3D) | |
| 115 |       {
 | |
| 116 | mDynamicCenter = (Dynamic3D)center; | |
| 117 | } | |
| 118 |  | |
| 119 | if( region == null ) | |
| 120 |       {
 | |
| 121 | mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 122 | } | |
| 123 | else | |
| 124 |       {
 | |
| 125 | if (region instanceof Static4D) | |
| 126 |         {
 | |
| 127 | mStaticRegion = (Static4D) region; | |
| 128 | } | |
| 129 | else if (region instanceof Dynamic4D) | |
| 130 |         {
 | |
| 131 | mDynamicRegion = (Dynamic4D) region; | |
| 132 | } | |
| 133 | } | |
| 87 | mWave = wave; | |
| 88 | mCenter = center; | |
| 89 | mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); | |
| 134 | 90 | } | 
| 135 | 91 |  | 
| 136 | 92 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 137 | 93 |  | 
| 138 | 94 | public boolean compute(float[] uniforms, int index, long currentDuration, long step ) | 
| 139 | 95 |     {
 | 
| 140 | boolean ret = false; | |
| 141 |  | |
| 142 | if( mDynamicCenter!=null ) | |
| 143 |       {
 | |
| 144 | mDynamicCenter.get(uniforms,index+5,currentDuration,step); | |
| 145 | } | |
| 146 | else | |
| 147 |       {
 | |
| 148 | uniforms[index+5] = mStaticCenter.getX(); | |
| 149 | uniforms[index+6] = mStaticCenter.getY(); | |
| 150 | uniforms[index+7] = mStaticCenter.getZ(); | |
| 151 | } | |
| 152 |  | |
| 153 | if( mDynamicRegion!=null ) | |
| 154 |       {
 | |
| 155 | mDynamicRegion.get(uniforms,index+8,currentDuration,step); | |
| 156 | } | |
| 157 | else | |
| 158 |       {
 | |
| 159 | uniforms[index+ 8] = mStaticRegion.getX(); | |
| 160 | uniforms[index+ 9] = mStaticRegion.getY(); | |
| 161 | uniforms[index+10] = mStaticRegion.getZ(); | |
| 162 | uniforms[index+11] = mStaticRegion.getW(); | |
| 163 | } | |
| 164 |  | |
| 165 | if( mDynamic0!=null ) | |
| 166 |       {
 | |
| 167 | ret = mDynamic0.get(uniforms,index,currentDuration,step); | |
| 168 | } | |
| 169 | else | |
| 170 |       {
 | |
| 171 | uniforms[index ] = ((Static5D)mStatic0).getX(); | |
| 172 | uniforms[index+1] = ((Static5D)mStatic0).getY(); | |
| 173 | uniforms[index+2] = ((Static5D)mStatic0).getZ(); | |
| 174 | uniforms[index+3] = ((Static5D)mStatic0).getW(); | |
| 175 | uniforms[index+4] = ((Static5D)mStatic0).getV(); | |
| 176 | } | |
| 96 | mCenter.get(uniforms,index+5,currentDuration,step); | |
| 97 | mRegion.get(uniforms,index+8,currentDuration,step); | |
| 98 | boolean ret = mWave.get(uniforms,index,currentDuration,step); | |
| 177 | 99 |  | 
| 178 | 100 | uniforms[index+2] = (float)(Math.PI*uniforms[index+2]/180); | 
| 179 | 101 | uniforms[index+3] = (float)(Math.PI*uniforms[index+3]/180); | 
Also available in: Unified diff
Simplify Effect classes.