Revision 6bb59aad
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/library/effect/Effect.java | ||
|---|---|---|
| 29 | 29 |
private final int mDimension; |
| 30 | 30 |
private final boolean mSupportsR; |
| 31 | 31 |
private final boolean mSupportsC; |
| 32 |
private final String mStr; |
|
| 32 | 33 |
|
| 33 | 34 |
private static long mNextID = 0; |
| 34 | 35 |
|
| ... | ... | |
| 39 | 40 |
|
| 40 | 41 |
public static final int LENGTH = 4; // The number of effect types above. |
| 41 | 42 |
public static final int MASK= (1<<LENGTH)-1; // Needed when we do bitwise operations on Effect Types. |
| 43 |
static final int MAX_EFFECTS = 1000; // The can be no more than MAX_EFFECTS effects of a given type. |
|
| 42 | 44 |
|
| 43 | 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 46 |
|
| ... | ... | |
| 61 | 63 |
maxtable[3] = PostprocessEffect.MAX; |
| 62 | 64 |
} |
| 63 | 65 |
|
| 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 67 |
|
|
| 68 |
public static int getType(int name) |
|
| 69 |
{
|
|
| 70 |
return name/MAX_EFFECTS; |
|
| 71 |
} |
|
| 72 |
|
|
| 64 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 65 | 74 |
|
| 66 | 75 |
public int getType() |
| ... | ... | |
| 82 | 91 |
return mID; |
| 83 | 92 |
} |
| 84 | 93 |
|
| 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 95 |
|
|
| 96 |
public String getString() |
|
| 97 |
{
|
|
| 98 |
return mStr; |
|
| 99 |
} |
|
| 100 |
|
|
| 85 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 86 | 102 |
|
| 87 | 103 |
public boolean supportsCenter() |
| ... | ... | |
| 105 | 121 |
|
| 106 | 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 107 | 123 |
|
| 108 |
Effect(int type, int name, int dimension, boolean center, boolean region) |
|
| 124 |
Effect(int type, int name, int dimension, boolean center, boolean region, final String str)
|
|
| 109 | 125 |
{
|
| 110 | 126 |
mID = mNextID++; |
| 111 | 127 |
|
| ... | ... | |
| 114 | 130 |
mDimension = dimension; |
| 115 | 131 |
mSupportsC = center; |
| 116 | 132 |
mSupportsR = region; |
| 133 |
mStr = str; |
|
| 117 | 134 |
} |
| 118 | 135 |
} |
| src/main/java/org/distorted/library/effect/FragmentEffect.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.library.effect; |
| 21 | 21 |
|
| 22 |
import org.distorted.library.type.Data4D; |
|
| 23 | 22 |
import org.distorted.library.type.Dynamic; |
| 23 |
import org.distorted.library.type.Dynamic4D; |
|
| 24 | 24 |
import org.distorted.library.type.Static; |
| 25 |
import org.distorted.library.type.Static4D; |
|
| 25 | 26 |
|
| 26 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 27 | 28 |
// FRAGMENT EFFECTS |
| ... | ... | |
| 31 | 32 |
{
|
| 32 | 33 |
public static final int NUM_UNIFORMS = 8; |
| 33 | 34 |
|
| 34 |
public static final int CHROMA = 0;
|
|
| 35 |
public static final int SMOOTH_CHROMA = 1; |
|
| 36 |
public static final int ALPHA = 2; |
|
| 37 |
public static final int SMOOTH_ALPHA = 3; |
|
| 38 |
public static final int BRIGHTNESS = 4; |
|
| 39 |
public static final int SMOOTH_BRIGHTNESS = 5; |
|
| 40 |
public static final int CONTRAST = 6; |
|
| 41 |
public static final int SMOOTH_CONTRAST = 7; |
|
| 42 |
public static final int SATURATION = 8; |
|
| 43 |
public static final int SMOOTH_SATURATION = 9; |
|
| 44 |
public static final int NUM_EFFECTS =10; |
|
| 35 |
public static final int CHROMA = MAX_EFFECTS*FRAGMENT ;
|
|
| 36 |
public static final int SMOOTH_CHROMA = MAX_EFFECTS*FRAGMENT + 1;
|
|
| 37 |
public static final int ALPHA = MAX_EFFECTS*FRAGMENT + 2;
|
|
| 38 |
public static final int SMOOTH_ALPHA = MAX_EFFECTS*FRAGMENT + 3;
|
|
| 39 |
public static final int BRIGHTNESS = MAX_EFFECTS*FRAGMENT + 4;
|
|
| 40 |
public static final int SMOOTH_BRIGHTNESS = MAX_EFFECTS*FRAGMENT + 5;
|
|
| 41 |
public static final int CONTRAST = MAX_EFFECTS*FRAGMENT + 6;
|
|
| 42 |
public static final int SMOOTH_CONTRAST = MAX_EFFECTS*FRAGMENT + 7;
|
|
| 43 |
public static final int SATURATION = MAX_EFFECTS*FRAGMENT + 8;
|
|
| 44 |
public static final int SMOOTH_SATURATION = MAX_EFFECTS*FRAGMENT + 9;
|
|
| 45 |
public static final int NUM_EFFECTS = 10;
|
|
| 45 | 46 |
|
| 46 | 47 |
static final int MAX = 5; |
| 47 | 48 |
private static final int MAX_UNITY_DIM = 1; |
| 48 | 49 |
|
| 49 | 50 |
Dynamic mDynamic0, mDynamic1; |
| 50 | 51 |
Static mStatic0, mStatic1; |
| 51 |
Data4D mRegion; |
|
| 52 |
Dynamic4D mDynamicRegion; |
|
| 53 |
Static4D mStaticRegion; |
|
| 52 | 54 |
|
| 53 | 55 |
private final static float[] mUnity = new float[MAX_UNITY_DIM*NUM_EFFECTS]; |
| 54 | 56 |
private final static int[] mUnityDim = new int[NUM_EFFECTS]; |
| 55 | 57 |
|
| 56 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 57 | 59 |
|
| 58 |
public FragmentEffect(int name,float[] unity, int dimension, boolean center, boolean region) |
|
| 60 |
public FragmentEffect(int name,float[] unity, int dimension, boolean center, boolean region, final String str)
|
|
| 59 | 61 |
{
|
| 60 |
super(FRAGMENT,name,dimension,center,region); |
|
| 62 |
super(FRAGMENT,name,dimension,center,region,str);
|
|
| 61 | 63 |
|
| 62 | 64 |
for(int i=0; i<unity.length; i++) |
| 63 | 65 |
{
|
| src/main/java/org/distorted/library/effect/FragmentEffectAlpha.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.type.Data1D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 | 24 |
import org.distorted.library.type.Dynamic1D; |
| 25 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 26 |
import org.distorted.library.type.Static1D; |
| 27 |
import org.distorted.library.type.Static4D; |
|
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 30 |
|
| 29 | 31 |
public class FragmentEffectAlpha extends FragmentEffect |
| 30 | 32 |
{
|
| 33 |
private static final String NAME = "ALPHA"; |
|
| 31 | 34 |
private static final float[] UNITIES = new float[] {1.0f};
|
| 32 | 35 |
private static final int DIMENSION = 1; |
| 33 | 36 |
private static final boolean SUPPORTS_CENTER = false; |
| 34 | 37 |
private static final boolean SUPPORTS_REGION = true; |
| 35 | 38 |
|
| 36 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 37 |
|
|
| 40 |
/** |
|
| 41 |
* Makes a certain sub-region of the Object smoothly change its transparency level. |
|
| 42 |
* |
|
| 43 |
* @param alpha 1-dimensional Data that returns the level of transparency we want to have at any given |
|
| 44 |
* moment: pixel.a *= alpha. |
|
| 45 |
* Valid range: <0,1> |
|
| 46 |
* @param region Region this Effect is limited to. |
|
| 47 |
* @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region. |
|
| 48 |
*/ |
|
| 38 | 49 |
public FragmentEffectAlpha(Data1D alpha, Data4D region, boolean smooth) |
| 39 | 50 |
{
|
| 40 |
super(smooth?SMOOTH_ALPHA:ALPHA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 51 |
super(smooth?SMOOTH_ALPHA:ALPHA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 41 | 52 |
|
| 42 | 53 |
if( alpha instanceof Dynamic1D ) |
| 43 | 54 |
{
|
| ... | ... | |
| 48 | 59 |
mStatic0 = (Static1D)alpha; |
| 49 | 60 |
} |
| 50 | 61 |
|
| 51 |
mRegion = region; |
|
| 62 |
if( region instanceof Static4D) |
|
| 63 |
{
|
|
| 64 |
mStaticRegion = (Static4D)region; |
|
| 65 |
} |
|
| 66 |
else if( region instanceof Dynamic4D) |
|
| 67 |
{
|
|
| 68 |
mDynamicRegion = (Dynamic4D)region; |
|
| 69 |
} |
|
| 52 | 70 |
} |
| 53 | 71 |
|
| 54 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 |
|
|
| 73 |
/** |
|
| 74 |
* Makes the whole Object smoothly change its transparency level. |
|
| 75 |
* |
|
| 76 |
* @param alpha 1-dimensional Data that returns the level of transparency we want to have at any |
|
| 77 |
* given moment: pixel.a *= alpha. |
|
| 78 |
* Valid range: <0,1> |
|
| 79 |
*/ |
|
| 56 | 80 |
public FragmentEffectAlpha(Data1D alpha) |
| 57 | 81 |
{
|
| 58 |
super(ALPHA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 82 |
super(ALPHA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 59 | 83 |
|
| 60 | 84 |
if( alpha instanceof Dynamic1D ) |
| 61 | 85 |
{
|
| ... | ... | |
| 65 | 89 |
{
|
| 66 | 90 |
mStatic0 = (Static1D)alpha; |
| 67 | 91 |
} |
| 92 |
|
|
| 93 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 68 | 94 |
} |
| 69 | 95 |
|
| 70 | 96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 71 | 97 |
|
| 72 | 98 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
| 73 | 99 |
{
|
| 100 |
if( mDynamicRegion!=null ) |
|
| 101 |
{
|
|
| 102 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 103 |
} |
|
| 104 |
else |
|
| 105 |
{
|
|
| 106 |
uniforms[index+4] = mStaticRegion.getX(); |
|
| 107 |
uniforms[index+5] = mStaticRegion.getY(); |
|
| 108 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
| 109 |
uniforms[index+7] = mStaticRegion.getW(); |
|
| 110 |
} |
|
| 111 |
|
|
| 74 | 112 |
if( mDynamic0!=null ) |
| 75 | 113 |
{
|
| 76 | 114 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
| src/main/java/org/distorted/library/effect/FragmentEffectBrightness.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.type.Data1D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 | 24 |
import org.distorted.library.type.Dynamic1D; |
| 25 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 26 |
import org.distorted.library.type.Static1D; |
| 27 |
import org.distorted.library.type.Static4D; |
|
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 30 |
|
| 29 | 31 |
public class FragmentEffectBrightness extends FragmentEffect |
| 30 | 32 |
{
|
| 33 |
private static final String NAME = "BRIGHTNESS"; |
|
| 31 | 34 |
private static final float[] UNITIES = new float[] {1.0f};
|
| 32 | 35 |
private static final int DIMENSION = 1; |
| 33 | 36 |
private static final boolean SUPPORTS_CENTER = false; |
| 34 | 37 |
private static final boolean SUPPORTS_REGION = true; |
| 35 | 38 |
|
| 36 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 37 |
|
|
| 40 |
/** |
|
| 41 |
* Makes a certain sub-region of the Object smoothly change its brightness level. |
|
| 42 |
* |
|
| 43 |
* @param brightness 1-dimensional Data that returns the level of brightness we want to have |
|
| 44 |
* at any given moment. Valid range: <0,infinity) |
|
| 45 |
* @param region Region this Effect is limited to. |
|
| 46 |
* @param smooth If true, the level of 'brightness' will smoothly fade out towards the edges of the region. |
|
| 47 |
*/ |
|
| 38 | 48 |
public FragmentEffectBrightness(Data1D brightness, Data4D region, boolean smooth) |
| 39 | 49 |
{
|
| 40 |
super(smooth?SMOOTH_BRIGHTNESS:BRIGHTNESS ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 50 |
super(smooth?SMOOTH_BRIGHTNESS:BRIGHTNESS ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 41 | 51 |
|
| 42 | 52 |
if( brightness instanceof Dynamic1D ) |
| 43 | 53 |
{
|
| ... | ... | |
| 48 | 58 |
mStatic0 = (Static1D)brightness; |
| 49 | 59 |
} |
| 50 | 60 |
|
| 51 |
mRegion = region; |
|
| 61 |
if( region instanceof Static4D) |
|
| 62 |
{
|
|
| 63 |
mStaticRegion = (Static4D)region; |
|
| 64 |
} |
|
| 65 |
else if( region instanceof Dynamic4D) |
|
| 66 |
{
|
|
| 67 |
mDynamicRegion = (Dynamic4D)region; |
|
| 68 |
} |
|
| 52 | 69 |
} |
| 53 | 70 |
|
| 54 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 |
|
|
| 72 |
/** |
|
| 73 |
* Makes the whole Object smoothly change its brightness level. |
|
| 74 |
* |
|
| 75 |
* @param brightness 1-dimensional Data that returns the level of brightness we want to have |
|
| 76 |
* at any given moment. Valid range: <0,infinity) |
|
| 77 |
*/ |
|
| 56 | 78 |
public FragmentEffectBrightness(Data1D brightness) |
| 57 | 79 |
{
|
| 58 |
super(BRIGHTNESS,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 80 |
super(BRIGHTNESS,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 59 | 81 |
|
| 60 | 82 |
if( brightness instanceof Dynamic1D ) |
| 61 | 83 |
{
|
| ... | ... | |
| 65 | 87 |
{
|
| 66 | 88 |
mStatic0 = (Static1D)brightness; |
| 67 | 89 |
} |
| 90 |
|
|
| 91 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 68 | 92 |
} |
| 69 | 93 |
|
| 70 | 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 71 | 95 |
|
| 72 | 96 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
| 73 | 97 |
{
|
| 98 |
if( mDynamicRegion!=null ) |
|
| 99 |
{
|
|
| 100 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 101 |
} |
|
| 102 |
else |
|
| 103 |
{
|
|
| 104 |
uniforms[index+4] = mStaticRegion.getX(); |
|
| 105 |
uniforms[index+5] = mStaticRegion.getY(); |
|
| 106 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
| 107 |
uniforms[index+7] = mStaticRegion.getW(); |
|
| 108 |
} |
|
| 109 |
|
|
| 74 | 110 |
if( mDynamic0!=null ) |
| 75 | 111 |
{
|
| 76 | 112 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
| src/main/java/org/distorted/library/effect/FragmentEffectChroma.java | ||
|---|---|---|
| 24 | 24 |
import org.distorted.library.type.Data4D; |
| 25 | 25 |
import org.distorted.library.type.Dynamic1D; |
| 26 | 26 |
import org.distorted.library.type.Dynamic3D; |
| 27 |
import org.distorted.library.type.Dynamic4D; |
|
| 27 | 28 |
import org.distorted.library.type.Static1D; |
| 28 | 29 |
import org.distorted.library.type.Static3D; |
| 30 |
import org.distorted.library.type.Static4D; |
|
| 29 | 31 |
|
| 30 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 31 | 33 |
|
| 32 | 34 |
public class FragmentEffectChroma extends FragmentEffect |
| 33 | 35 |
{
|
| 36 |
private static final String NAME = "CHROMA"; |
|
| 34 | 37 |
private static final float[] UNITIES = new float[] {0.0f};
|
| 35 | 38 |
private static final int DIMENSION = 4; |
| 36 | 39 |
private static final boolean SUPPORTS_CENTER = false; |
| 37 | 40 |
private static final boolean SUPPORTS_REGION = true; |
| 38 | 41 |
|
| 39 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 |
|
|
| 43 |
/** |
|
| 44 |
* Makes a certain sub-region of the Object smoothly change all three of its RGB components. |
|
| 45 |
* |
|
| 46 |
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be |
|
| 47 |
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color. |
|
| 48 |
* Valid range: <0,1> |
|
| 49 |
* @param color Color to mix. (1,0,0) is RED. |
|
| 50 |
* @param region Region this Effect is limited to. |
|
| 51 |
* @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region. |
|
| 52 |
*/ |
|
| 41 | 53 |
public FragmentEffectChroma(Data1D blend, Data3D color, Data4D region, boolean smooth) |
| 42 | 54 |
{
|
| 43 |
super(smooth?SMOOTH_CHROMA:CHROMA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 55 |
super(smooth?SMOOTH_CHROMA:CHROMA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 44 | 56 |
|
| 45 | 57 |
if( blend instanceof Dynamic1D ) |
| 46 | 58 |
{
|
| ... | ... | |
| 60 | 72 |
mStatic1 = (Static3D)color; |
| 61 | 73 |
} |
| 62 | 74 |
|
| 63 |
mRegion = region; |
|
| 75 |
if( region instanceof Static4D) |
|
| 76 |
{
|
|
| 77 |
mStaticRegion = (Static4D)region; |
|
| 78 |
} |
|
| 79 |
else if( region instanceof Dynamic4D) |
|
| 80 |
{
|
|
| 81 |
mDynamicRegion = (Dynamic4D)region; |
|
| 82 |
} |
|
| 64 | 83 |
} |
| 65 | 84 |
|
| 66 | 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 67 |
|
|
| 86 |
/** |
|
| 87 |
* Makes the whole Object smoothly change all three of its RGB components. |
|
| 88 |
* |
|
| 89 |
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be |
|
| 90 |
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color. |
|
| 91 |
* Valid range: <0,1> |
|
| 92 |
* @param color Color to mix. (1,0,0) is RED. |
|
| 93 |
*/ |
|
| 68 | 94 |
public FragmentEffectChroma(Data1D blend, Data3D color) |
| 69 | 95 |
{
|
| 70 |
super(CHROMA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 96 |
super(CHROMA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 71 | 97 |
|
| 72 | 98 |
if( blend instanceof Dynamic1D ) |
| 73 | 99 |
{
|
| ... | ... | |
| 86 | 112 |
{
|
| 87 | 113 |
mStatic1 = (Static3D)color; |
| 88 | 114 |
} |
| 115 |
|
|
| 116 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 89 | 117 |
} |
| 90 | 118 |
|
| 91 | 119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 92 | 120 |
|
| 93 | 121 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
| 94 | 122 |
{
|
| 123 |
if( mDynamicRegion!=null ) |
|
| 124 |
{
|
|
| 125 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 126 |
} |
|
| 127 |
else |
|
| 128 |
{
|
|
| 129 |
uniforms[index+4] = mStaticRegion.getX(); |
|
| 130 |
uniforms[index+5] = mStaticRegion.getY(); |
|
| 131 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
| 132 |
uniforms[index+7] = mStaticRegion.getW(); |
|
| 133 |
} |
|
| 134 |
|
|
| 95 | 135 |
if( mDynamic1!=null ) |
| 96 | 136 |
{
|
| 97 | 137 |
mDynamic1.interpolateMain(uniforms,index+1,currentDuration,step); |
| src/main/java/org/distorted/library/effect/FragmentEffectContrast.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.type.Data1D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 | 24 |
import org.distorted.library.type.Dynamic1D; |
| 25 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 26 |
import org.distorted.library.type.Static1D; |
| 27 |
import org.distorted.library.type.Static4D; |
|
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 30 |
|
| 29 | 31 |
public class FragmentEffectContrast extends FragmentEffect |
| 30 | 32 |
{
|
| 33 |
private static final String NAME = "CONTRAST"; |
|
| 31 | 34 |
private static final float[] UNITIES = new float[] {1.0f};
|
| 32 | 35 |
private static final int DIMENSION = 1; |
| 33 | 36 |
private static final boolean SUPPORTS_CENTER = false; |
| 34 | 37 |
private static final boolean SUPPORTS_REGION = true; |
| 35 | 38 |
|
| 36 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 37 |
|
|
| 40 |
/** |
|
| 41 |
* Makes a certain sub-region of the Object smoothly change its contrast level. |
|
| 42 |
* |
|
| 43 |
* @param contrast 1-dimensional Data that returns the level of contrast we want to have |
|
| 44 |
* at any given moment. Valid range: <0,infinity) |
|
| 45 |
* @param region Region this Effect is limited to. |
|
| 46 |
* @param smooth If true, the level of 'contrast' will smoothly fade out towards the edges of the region. |
|
| 47 |
*/ |
|
| 38 | 48 |
public FragmentEffectContrast(Data1D contrast, Data4D region, boolean smooth) |
| 39 | 49 |
{
|
| 40 |
super(smooth?SMOOTH_CONTRAST:CONTRAST ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 50 |
super(smooth?SMOOTH_CONTRAST:CONTRAST ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 41 | 51 |
|
| 42 | 52 |
if( contrast instanceof Dynamic1D ) |
| 43 | 53 |
{
|
| ... | ... | |
| 48 | 58 |
mStatic0 = (Static1D)contrast; |
| 49 | 59 |
} |
| 50 | 60 |
|
| 51 |
mRegion = region; |
|
| 61 |
if( region instanceof Static4D) |
|
| 62 |
{
|
|
| 63 |
mStaticRegion = (Static4D)region; |
|
| 64 |
} |
|
| 65 |
else if( region instanceof Dynamic4D) |
|
| 66 |
{
|
|
| 67 |
mDynamicRegion = (Dynamic4D)region; |
|
| 68 |
} |
|
| 52 | 69 |
} |
| 53 | 70 |
|
| 54 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 |
|
|
| 72 |
/** |
|
| 73 |
* Makes the whole Object smoothly change its contrast level. |
|
| 74 |
* |
|
| 75 |
* @param contrast 1-dimensional Data that returns the level of contrast we want to have |
|
| 76 |
* at any given moment. Valid range: <0,infinity) |
|
| 77 |
*/ |
|
| 56 | 78 |
public FragmentEffectContrast(Data1D contrast) |
| 57 | 79 |
{
|
| 58 |
super(CONTRAST,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 80 |
super(CONTRAST,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 59 | 81 |
|
| 60 | 82 |
if( contrast instanceof Dynamic1D ) |
| 61 | 83 |
{
|
| ... | ... | |
| 65 | 87 |
{
|
| 66 | 88 |
mStatic0 = (Static1D)contrast; |
| 67 | 89 |
} |
| 90 |
|
|
| 91 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 68 | 92 |
} |
| 69 | 93 |
|
| 70 | 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 71 | 95 |
|
| 72 | 96 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
| 73 | 97 |
{
|
| 98 |
if( mDynamicRegion!=null ) |
|
| 99 |
{
|
|
| 100 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 101 |
} |
|
| 102 |
else |
|
| 103 |
{
|
|
| 104 |
uniforms[index+4] = mStaticRegion.getX(); |
|
| 105 |
uniforms[index+5] = mStaticRegion.getY(); |
|
| 106 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
| 107 |
uniforms[index+7] = mStaticRegion.getW(); |
|
| 108 |
} |
|
| 109 |
|
|
| 74 | 110 |
if( mDynamic0!=null ) |
| 75 | 111 |
{
|
| 76 | 112 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
| src/main/java/org/distorted/library/effect/FragmentEffectSaturation.java | ||
|---|---|---|
| 22 | 22 |
import org.distorted.library.type.Data1D; |
| 23 | 23 |
import org.distorted.library.type.Data4D; |
| 24 | 24 |
import org.distorted.library.type.Dynamic1D; |
| 25 |
import org.distorted.library.type.Dynamic4D; |
|
| 25 | 26 |
import org.distorted.library.type.Static1D; |
| 27 |
import org.distorted.library.type.Static4D; |
|
| 26 | 28 |
|
| 27 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 28 | 30 |
|
| 29 | 31 |
public class FragmentEffectSaturation extends FragmentEffect |
| 30 | 32 |
{
|
| 33 |
private static final String NAME = "SATURATION"; |
|
| 31 | 34 |
private static final float[] UNITIES = new float[] {1.0f};
|
| 32 | 35 |
private static final int DIMENSION = 1; |
| 33 | 36 |
private static final boolean SUPPORTS_CENTER = false; |
| 34 | 37 |
private static final boolean SUPPORTS_REGION = true; |
| 35 | 38 |
|
| 36 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 37 |
|
|
| 40 |
/** |
|
| 41 |
* Makes a certain sub-region of the Object smoothly change its saturation level. |
|
| 42 |
* |
|
| 43 |
* @param saturation 1-dimensional Data that returns the level of saturation we want to have |
|
| 44 |
* at any given moment. Valid range: <0,infinity) |
|
| 45 |
* @param region Region this Effect is limited to. |
|
| 46 |
* @param smooth If true, the level of 'saturation' will smoothly fade out towards the edges of the region. |
|
| 47 |
*/ |
|
| 38 | 48 |
public FragmentEffectSaturation(Data1D saturation, Data4D region, boolean smooth) |
| 39 | 49 |
{
|
| 40 |
super(smooth?SMOOTH_SATURATION:SATURATION ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 50 |
super(smooth?SMOOTH_SATURATION:SATURATION ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 41 | 51 |
|
| 42 | 52 |
if( saturation instanceof Dynamic1D ) |
| 43 | 53 |
{
|
| ... | ... | |
| 48 | 58 |
mStatic0 = (Static1D)saturation; |
| 49 | 59 |
} |
| 50 | 60 |
|
| 51 |
mRegion = region; |
|
| 61 |
if( region instanceof Static4D) |
|
| 62 |
{
|
|
| 63 |
mStaticRegion = (Static4D)region; |
|
| 64 |
} |
|
| 65 |
else if( region instanceof Dynamic4D) |
|
| 66 |
{
|
|
| 67 |
mDynamicRegion = (Dynamic4D)region; |
|
| 68 |
} |
|
| 52 | 69 |
} |
| 53 | 70 |
|
| 54 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 |
|
|
| 72 |
/** |
|
| 73 |
* Makes the whole Object smoothly change its saturation level. |
|
| 74 |
* |
|
| 75 |
* @param saturation 1-dimensional Data that returns the level of saturation we want to have |
|
| 76 |
* at any given moment. Valid range: <0,infinity) |
|
| 77 |
*/ |
|
| 56 | 78 |
public FragmentEffectSaturation(Data1D saturation) |
| 57 | 79 |
{
|
| 58 |
super(SATURATION,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 80 |
super(SATURATION,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 59 | 81 |
|
| 60 | 82 |
if( saturation instanceof Dynamic1D ) |
| 61 | 83 |
{
|
| ... | ... | |
| 65 | 87 |
{
|
| 66 | 88 |
mStatic0 = (Static1D)saturation; |
| 67 | 89 |
} |
| 90 |
|
|
| 91 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 68 | 92 |
} |
| 69 | 93 |
|
| 70 | 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 71 | 95 |
|
| 72 | 96 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
| 73 | 97 |
{
|
| 98 |
if( mDynamicRegion!=null ) |
|
| 99 |
{
|
|
| 100 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 101 |
} |
|
| 102 |
else |
|
| 103 |
{
|
|
| 104 |
uniforms[index+4] = mStaticRegion.getX(); |
|
| 105 |
uniforms[index+5] = mStaticRegion.getY(); |
|
| 106 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
| 107 |
uniforms[index+7] = mStaticRegion.getW(); |
|
| 108 |
} |
|
| 109 |
|
|
| 74 | 110 |
if( mDynamic0!=null ) |
| 75 | 111 |
{
|
| 76 | 112 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
| src/main/java/org/distorted/library/effect/MatrixEffect.java | ||
|---|---|---|
| 29 | 29 |
{
|
| 30 | 30 |
public static final int NUM_UNIFORMS = 7; |
| 31 | 31 |
|
| 32 |
public static final int MOVE = 0;
|
|
| 33 |
public static final int SCALE = 1; |
|
| 34 |
public static final int ROTATE = 2; |
|
| 35 |
public static final int QUATERNION = 3; |
|
| 36 |
public static final int SHEAR = 4; |
|
| 32 |
public static final int MOVE = MAX_EFFECTS*MATRIX ;
|
|
| 33 |
public static final int SCALE = MAX_EFFECTS*MATRIX + 1;
|
|
| 34 |
public static final int ROTATE = MAX_EFFECTS*MATRIX + 2;
|
|
| 35 |
public static final int QUATERNION = MAX_EFFECTS*MATRIX + 3;
|
|
| 36 |
public static final int SHEAR = MAX_EFFECTS*MATRIX + 4;
|
|
| 37 | 37 |
public static final int NUM_EFFECTS= 5; |
| 38 | 38 |
|
| 39 | 39 |
static final int MAX = 5; |
| ... | ... | |
| 49 | 49 |
|
| 50 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 51 | 51 |
|
| 52 |
public MatrixEffect(int name, float[] unity, int dimension, boolean center, boolean region) |
|
| 52 |
public MatrixEffect(int name, float[] unity, int dimension, boolean center, boolean region, final String str)
|
|
| 53 | 53 |
{
|
| 54 |
super(MATRIX,name,dimension,center,region); |
|
| 54 |
super(MATRIX,name,dimension,center,region,str);
|
|
| 55 | 55 |
|
| 56 | 56 |
for(int i=0; i<unity.length; i++) |
| 57 | 57 |
{
|
| src/main/java/org/distorted/library/effect/MatrixEffectMove.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
public class MatrixEffectMove extends MatrixEffect |
| 29 | 29 |
{
|
| 30 |
private static final String NAME = "MOVE"; |
|
| 30 | 31 |
private static final float[] UNITIES = new float[]{0.0f, 0.0f, 0.0f};
|
| 31 | 32 |
private static final int DIMENSION = 3; |
| 32 | 33 |
private static final boolean SUPPORTS_CENTER = false; |
| 33 | 34 |
private static final boolean SUPPORTS_REGION = false; |
| 34 | 35 |
|
| 35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 |
|
|
| 37 |
/** |
|
| 38 |
* Moves the Object by a (possibly changing in time) vector. |
|
| 39 |
* |
|
| 40 |
* @param vector 3-dimensional Data which at any given time will return a Static3D |
|
| 41 |
* representing the current coordinates of the vector we want to move the Object with. |
|
| 42 |
*/ |
|
| 37 | 43 |
public MatrixEffectMove(Data3D vector) |
| 38 | 44 |
{
|
| 39 |
super(MOVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 45 |
super(MOVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 40 | 46 |
|
| 41 | 47 |
if( vector instanceof Static3D) |
| 42 | 48 |
{
|
| src/main/java/org/distorted/library/effect/MatrixEffectQuaternion.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
public class MatrixEffectQuaternion extends MatrixEffect |
| 32 | 32 |
{
|
| 33 |
private static final String NAME = "QUATERNION"; |
|
| 33 | 34 |
private static final float[] UNITIES = new float[]{0.0f, 0.0f, 0.0f};
|
| 34 | 35 |
private static final int DIMENSION = 4; |
| 35 | 36 |
private static final boolean SUPPORTS_CENTER = true; |
| 36 | 37 |
private static final boolean SUPPORTS_REGION = false; |
| 37 | 38 |
|
| 38 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Rotates the Object by quaternion. |
|
| 42 |
* |
|
| 43 |
* @param quaternion The quaternion describing the rotation. |
|
| 44 |
* @param center Coordinates of the Point we are rotating around. |
|
| 45 |
*/ |
|
| 40 | 46 |
public MatrixEffectQuaternion(Data4D quaternion, Data3D center ) |
| 41 | 47 |
{
|
| 42 |
super(QUATERNION,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 48 |
super(QUATERNION,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 43 | 49 |
|
| 44 | 50 |
if( quaternion instanceof Static4D) |
| 45 | 51 |
{
|
| src/main/java/org/distorted/library/effect/MatrixEffectRotate.java | ||
|---|---|---|
| 33 | 33 |
|
| 34 | 34 |
public class MatrixEffectRotate extends MatrixEffect |
| 35 | 35 |
{
|
| 36 |
private static final String NAME = "ROTATE"; |
|
| 36 | 37 |
private static final float[] UNITIES = new float[]{0.0f};
|
| 37 | 38 |
private static final int DIMENSION = 4; |
| 38 | 39 |
private static final boolean SUPPORTS_CENTER = true; |
| 39 | 40 |
private static final boolean SUPPORTS_REGION = false; |
| 40 | 41 |
|
| 41 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 |
|
|
| 43 |
/** |
|
| 44 |
* Rotates the Object by 'angle' degrees around the center. |
|
| 45 |
* Static axis of rotation is given by the last parameter. |
|
| 46 |
* |
|
| 47 |
* @param angle Angle that we want to rotate the Object to. Unit: degrees |
|
| 48 |
* @param axis Axis of rotation |
|
| 49 |
* @param center Coordinates of the Point we are rotating around. |
|
| 50 |
*/ |
|
| 43 | 51 |
public MatrixEffectRotate(Data1D angle, Static3D axis, Data3D center) |
| 44 | 52 |
{
|
| 45 |
super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 53 |
super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 46 | 54 |
|
| 47 | 55 |
if( angle instanceof Static1D ) |
| 48 | 56 |
{
|
| ... | ... | |
| 66 | 74 |
} |
| 67 | 75 |
|
| 68 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 69 |
|
|
| 77 |
/** |
|
| 78 |
* Rotates the Object by 'angle' degrees around the center. |
|
| 79 |
* Here both angle and axis can dynamically change. |
|
| 80 |
* |
|
| 81 |
* @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ). |
|
| 82 |
* @param center Coordinates of the Point we are rotating around. |
|
| 83 |
*/ |
|
| 70 | 84 |
public MatrixEffectRotate(Data4D angleaxis, Data3D center) |
| 71 | 85 |
{
|
| 72 |
super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 86 |
super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 73 | 87 |
|
| 74 | 88 |
if( angleaxis instanceof Static4D) |
| 75 | 89 |
{
|
| src/main/java/org/distorted/library/effect/MatrixEffectScale.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
public class MatrixEffectScale extends MatrixEffect |
| 29 | 29 |
{
|
| 30 |
private static final String NAME = "SCALE"; |
|
| 30 | 31 |
private static final float[] UNITIES = new float[] {1.0f,1.0f,1.0f};
|
| 31 | 32 |
private static final int DIMENSION = 3; |
| 32 | 33 |
private static final boolean SUPPORTS_CENTER = false; |
| 33 | 34 |
private static final boolean SUPPORTS_REGION = false; |
| 34 | 35 |
|
| 35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 |
|
|
| 37 |
/** |
|
| 38 |
* Scales the Object by (possibly changing in time) 3D scale factors. |
|
| 39 |
* |
|
| 40 |
* @param scale 3-dimensional Data which at any given time returns a Static3D |
|
| 41 |
* representing the current x- , y- and z- scale factors. |
|
| 42 |
*/ |
|
| 37 | 43 |
public MatrixEffectScale(Data3D scale) |
| 38 | 44 |
{
|
| 39 |
super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 45 |
super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 40 | 46 |
|
| 41 | 47 |
if( scale instanceof Static3D) |
| 42 | 48 |
{
|
| ... | ... | |
| 49 | 55 |
} |
| 50 | 56 |
|
| 51 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 52 |
|
|
| 58 |
/** |
|
| 59 |
* Scales the Object by (possibly changing in time) 3D scale factors. |
|
| 60 |
* |
|
| 61 |
* @param scale Common x,y, and z scale factor. |
|
| 62 |
*/ |
|
| 53 | 63 |
public MatrixEffectScale(float scale) |
| 54 | 64 |
{
|
| 55 |
super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 65 |
super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 56 | 66 |
|
| 57 | 67 |
mStatic0 = new Static3D(scale,scale,scale); |
| 58 | 68 |
} |
| src/main/java/org/distorted/library/effect/MatrixEffectShear.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
public class MatrixEffectShear extends MatrixEffect |
| 29 | 29 |
{
|
| 30 |
private static final String NAME = "SHEAR"; |
|
| 30 | 31 |
private static final float[] UNITIES = new float[] {0.0f,0.0f,0.0f};
|
| 31 | 32 |
private static final int DIMENSION = 3; |
| 32 | 33 |
private static final boolean SUPPORTS_CENTER = true; |
| 33 | 34 |
private static final boolean SUPPORTS_REGION = false; |
| 34 | 35 |
|
| 35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 |
|
|
| 37 |
/** |
|
| 38 |
* Shears the Object. |
|
| 39 |
* |
|
| 40 |
* @param shear The 3-tuple of shear factors. The first controls level |
|
| 41 |
* of shearing in the X-axis, second - Y-axis and the third - |
|
| 42 |
* Z-axis. Each is the tangens of the shear angle, i.e 0 - |
|
| 43 |
* no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc. |
|
| 44 |
* @param center Center of shearing, i.e. the point which stays unmoved. |
|
| 45 |
*/ |
|
| 37 | 46 |
public MatrixEffectShear(Data3D shear, Data3D center) |
| 38 | 47 |
{
|
| 39 |
super(SHEAR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 48 |
super(SHEAR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 40 | 49 |
|
| 41 | 50 |
if( shear instanceof Static3D) |
| 42 | 51 |
{
|
| src/main/java/org/distorted/library/effect/PostprocessEffect.java | ||
|---|---|---|
| 30 | 30 |
{
|
| 31 | 31 |
public static final int NUM_UNIFORMS = 5; |
| 32 | 32 |
|
| 33 |
public static final int BLUR =0;
|
|
| 34 |
public static final int GLOW =1; |
|
| 35 |
public static final int NUM_EFFECTS=2; |
|
| 33 |
public static final int BLUR = MAX_EFFECTS*POSTPROCESS ;
|
|
| 34 |
public static final int GLOW = MAX_EFFECTS*POSTPROCESS + 1;
|
|
| 35 |
public static final int NUM_EFFECTS= 2;
|
|
| 36 | 36 |
|
| 37 | 37 |
static final int MAX = 5; |
| 38 | 38 |
private static final int MAX_UNITY_DIM = 1; |
| ... | ... | |
| 45 | 45 |
|
| 46 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 47 | 47 |
|
| 48 |
public PostprocessEffect(int name, float[] unity, int dimension, boolean center, boolean region) |
|
| 48 |
public PostprocessEffect(int name, float[] unity, int dimension, boolean center, boolean region, final String str)
|
|
| 49 | 49 |
{
|
| 50 |
super(POSTPROCESS,name,dimension,center,region); |
|
| 50 |
super(POSTPROCESS,name,dimension,center,region,str);
|
|
| 51 | 51 |
|
| 52 | 52 |
for(int i=0; i<unity.length; i++) |
| 53 | 53 |
{
|
| src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
public class PostprocessEffectBlur extends PostprocessEffect |
| 29 | 29 |
{
|
| 30 |
private static final String NAME = "BLUR"; |
|
| 30 | 31 |
private static final float[] UNITIES = new float[] {0.0f};
|
| 31 | 32 |
private static final int DIMENSION = 1; |
| 32 | 33 |
private static final boolean SUPPORTS_CENTER = false; |
| ... | ... | |
| 36 | 37 |
|
| 37 | 38 |
public PostprocessEffectBlur(Data1D radius) |
| 38 | 39 |
{
|
| 39 |
super(BLUR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 40 |
super(BLUR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 40 | 41 |
|
| 41 | 42 |
if( radius instanceof Dynamic1D) |
| 42 | 43 |
{
|
| src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
public class PostprocessEffectGlow extends PostprocessEffect |
| 32 | 32 |
{
|
| 33 |
private static final String NAME = "GLOW"; |
|
| 33 | 34 |
private static final float[] UNITIES = new float[] {0.0f};
|
| 34 | 35 |
private static final int DIMENSION = 5; |
| 35 | 36 |
private static final boolean SUPPORTS_CENTER = false; |
| ... | ... | |
| 39 | 40 |
|
| 40 | 41 |
public PostprocessEffectGlow(Data1D radius, Data4D color) |
| 41 | 42 |
{
|
| 42 |
super(GLOW,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 43 |
super(GLOW,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 43 | 44 |
|
| 44 | 45 |
if( radius instanceof Dynamic1D) |
| 45 | 46 |
{
|
| src/main/java/org/distorted/library/effect/VertexEffect.java | ||
|---|---|---|
| 34 | 34 |
{
|
| 35 | 35 |
public static final int NUM_UNIFORMS = 12; |
| 36 | 36 |
|
| 37 |
public static final int DISTORT =0;
|
|
| 38 |
public static final int DEFORM =1; |
|
| 39 |
public static final int SINK =2; |
|
| 40 |
public static final int PINCH =3; |
|
| 41 |
public static final int SWIRL =4; |
|
| 42 |
public static final int WAVE =5; |
|
| 43 |
public static final int NUM_EFFECTS=6; |
|
| 37 |
public static final int DISTORT = MAX_EFFECTS*VERTEX ;
|
|
| 38 |
public static final int DEFORM = MAX_EFFECTS*VERTEX + 1;
|
|
| 39 |
public static final int SINK = MAX_EFFECTS*VERTEX + 2;
|
|
| 40 |
public static final int PINCH = MAX_EFFECTS*VERTEX + 3;
|
|
| 41 |
public static final int SWIRL = MAX_EFFECTS*VERTEX + 4;
|
|
| 42 |
public static final int WAVE = MAX_EFFECTS*VERTEX + 5;
|
|
| 43 |
public static final int NUM_EFFECTS= 6;
|
|
| 44 | 44 |
|
| 45 | 45 |
static final int MAX = 5; |
| 46 | 46 |
private static final int MAX_UNITY_DIM = 3; |
| ... | ... | |
| 57 | 57 |
|
| 58 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | 59 |
|
| 60 |
public VertexEffect(int name, float[] unity, int dimension, boolean center, boolean region) |
|
| 60 |
public VertexEffect(int name, float[] unity, int dimension, boolean center, boolean region, final String str)
|
|
| 61 | 61 |
{
|
| 62 |
super(VERTEX,name,dimension,center,region); |
|
| 62 |
super(VERTEX,name,dimension,center,region,str);
|
|
| 63 | 63 |
|
| 64 | 64 |
for(int i=0; i<unity.length; i++) |
| 65 | 65 |
{
|
| src/main/java/org/distorted/library/effect/VertexEffectDeform.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
public class VertexEffectDeform extends VertexEffect |
| 32 | 32 |
{
|
| 33 |
private static final String NAME = "DEFORM"; |
|
| 33 | 34 |
private static final float[] UNITIES = new float[] {0.0f,0.0f,0.0f};
|
| 34 | 35 |
private static final int DIMENSION = 3; |
| 35 | 36 |
private static final boolean SUPPORTS_CENTER = true; |
| 36 | 37 |
private static final boolean SUPPORTS_REGION = true; |
| 37 | 38 |
|
| 38 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to |
|
| 42 |
* a (possibly changing in time) point on the Object. |
|
| 43 |
* |
|
| 44 |
* @param vector Vector of force that deforms the shape of the whole Object. |
|
| 45 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 46 |
* @param region Region that masks the Effect. |
|
| 47 |
*/ |
|
| 40 | 48 |
public VertexEffectDeform(Data3D vector, Data3D center, Data4D region) |
| 41 | 49 |
{
|
| 42 |
super(DEFORM,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 50 |
super(DEFORM,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 43 | 51 |
|
| 44 | 52 |
if( vector instanceof Dynamic3D ) |
| 45 | 53 |
{
|
| ... | ... | |
| 70 | 78 |
} |
| 71 | 79 |
|
| 72 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 73 |
|
|
| 81 |
/** |
|
| 82 |
* Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to |
|
| 83 |
* a (possibly changing in time) point on the Object. |
|
| 84 |
* |
|
| 85 |
* @param vector Vector of force that deforms the shape of the whole Object. |
|
| 86 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 87 |
*/ |
|
| 74 | 88 |
public VertexEffectDeform(Data3D vector, Data3D center) |
| 75 | 89 |
{
|
| 76 |
super(DEFORM,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 90 |
super(DEFORM,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 77 | 91 |
|
| 78 | 92 |
if( vector instanceof Dynamic3D ) |
| 79 | 93 |
{
|
| src/main/java/org/distorted/library/effect/VertexEffectDistort.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
public class VertexEffectDistort extends VertexEffect |
| 32 | 32 |
{
|
| 33 |
private static final String NAME = "DISORT"; |
|
| 33 | 34 |
private static final float[] UNITIES = new float[] {0.0f,0.0f,0.0f};
|
| 34 | 35 |
private static final int DIMENSION = 3; |
| 35 | 36 |
private static final boolean SUPPORTS_CENTER = true; |
| 36 | 37 |
private static final boolean SUPPORTS_REGION = true; |
| 37 | 38 |
|
| 38 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force. |
|
| 42 |
* |
|
| 43 |
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is |
|
| 44 |
* currently being dragged with. |
|
| 45 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 46 |
* @param region Region that masks the Effect. |
|
| 47 |
*/ |
|
| 40 | 48 |
public VertexEffectDistort(Data3D vector, Data3D center, Data4D region) |
| 41 | 49 |
{
|
| 42 |
super(DISTORT,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 50 |
super(DISTORT,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 43 | 51 |
|
| 44 | 52 |
if( vector instanceof Dynamic3D ) |
| 45 | 53 |
{
|
| ... | ... | |
| 70 | 78 |
} |
| 71 | 79 |
|
| 72 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 73 |
|
|
| 81 |
/** |
|
| 82 |
* Distort the whole Object by a (possibly changing in time) vector of force. |
|
| 83 |
* |
|
| 84 |
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is |
|
| 85 |
* currently being dragged with. |
|
| 86 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 87 |
*/ |
|
| 74 | 88 |
public VertexEffectDistort(Data3D vector, Data3D center) |
| 75 | 89 |
{
|
| 76 |
super(DISTORT,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 90 |
super(DISTORT,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 77 | 91 |
|
| 78 | 92 |
if( vector instanceof Dynamic3D ) |
| 79 | 93 |
{
|
| src/main/java/org/distorted/library/effect/VertexEffectPinch.java | ||
|---|---|---|
| 33 | 33 |
|
| 34 | 34 |
public class VertexEffectPinch extends VertexEffect |
| 35 | 35 |
{
|
| 36 |
private static final String NAME = "PINCH"; |
|
| 36 | 37 |
private static final float[] UNITIES = new float[] {1.0f};
|
| 37 | 38 |
private static final int DIMENSION = 2; |
| 38 | 39 |
private static final boolean SUPPORTS_CENTER = true; |
| 39 | 40 |
private static final boolean SUPPORTS_REGION = true; |
| 40 | 41 |
|
| 41 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 |
|
|
| 43 |
/** |
|
| 44 |
* Pull all points around the center of the Effect towards a line passing through the center |
|
| 45 |
* (that's if degree>=1) or push them away from the line (degree<=1) |
|
| 46 |
* |
|
| 47 |
* @param pinch The current degree of the Effect + angle the line forms with X-axis |
|
| 48 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 49 |
* @param region Region that masks the Effect. |
|
| 50 |
*/ |
|
| 43 | 51 |
public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region) |
| 44 | 52 |
{
|
| 45 |
super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 53 |
super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 46 | 54 |
|
| 47 | 55 |
if( pinch instanceof Dynamic2D) |
| 48 | 56 |
{
|
| ... | ... | |
| 73 | 81 |
} |
| 74 | 82 |
|
| 75 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 76 |
|
|
| 84 |
/** |
|
| 85 |
* Pull all points around the center of the Effect towards a line passing through the center |
|
| 86 |
* (that's if degree>=1) or push them away from the line (degree<=1) |
|
| 87 |
* |
|
| 88 |
* @param pinch The current degree of the Effect + angle the line forms with X-axis |
|
| 89 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 90 |
*/ |
|
| 77 | 91 |
public VertexEffectPinch(Data2D pinch, Data3D center) |
| 78 | 92 |
{
|
| 79 |
super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 93 |
super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 80 | 94 |
|
| 81 | 95 |
if( pinch instanceof Dynamic2D) |
| 82 | 96 |
{
|
| src/main/java/org/distorted/library/effect/VertexEffectSink.java | ||
|---|---|---|
| 33 | 33 |
|
| 34 | 34 |
public class VertexEffectSink extends VertexEffect |
| 35 | 35 |
{
|
| 36 |
private static final String NAME = "SINK"; |
|
| 36 | 37 |
private static final float[] UNITIES = new float[] {1.0f};
|
| 37 | 38 |
private static final int DIMENSION = 1; |
| 38 | 39 |
private static final boolean SUPPORTS_CENTER = true; |
| 39 | 40 |
private static final boolean SUPPORTS_REGION = true; |
| 40 | 41 |
|
| 41 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 |
|
|
| 43 |
/** |
|
| 44 |
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them |
|
| 45 |
* away from the center (degree<=1) |
|
| 46 |
* |
|
| 47 |
* @param sink The current degree of the Effect. |
|
| 48 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 49 |
* @param region Region that masks the Effect. |
|
| 50 |
*/ |
|
| 43 | 51 |
public VertexEffectSink(Data1D sink, Data3D center, Data4D region) |
| 44 | 52 |
{
|
| 45 |
super(SINK,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 53 |
super(SINK,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 46 | 54 |
|
| 47 | 55 |
if( sink instanceof Dynamic1D) |
| 48 | 56 |
{
|
| ... | ... | |
| 73 | 81 |
} |
| 74 | 82 |
|
| 75 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 76 |
|
|
| 84 |
/** |
|
| 85 |
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them |
|
| 86 |
* away from the center (degree<=1) |
|
| 87 |
* |
|
| 88 |
* @param sink The current degree of the Effect. |
|
| 89 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 90 |
*/ |
|
| 77 | 91 |
public VertexEffectSink(Data1D sink, Data3D center) |
| 78 | 92 |
{
|
| 79 |
super(SINK,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 93 |
super(SINK,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 80 | 94 |
|
| 81 | 95 |
if( sink instanceof Dynamic1D) |
| 82 | 96 |
{
|
| src/main/java/org/distorted/library/effect/VertexEffectSwirl.java | ||
|---|---|---|
| 33 | 33 |
|
| 34 | 34 |
public class VertexEffectSwirl extends VertexEffect |
| 35 | 35 |
{
|
| 36 |
private static final String NAME = "SWIRL"; |
|
| 36 | 37 |
private static final float[] UNITIES = new float[] {0.0f};
|
| 37 | 38 |
private static final int DIMENSION = 1; |
| 38 | 39 |
private static final boolean SUPPORTS_CENTER = true; |
| 39 | 40 |
private static final boolean SUPPORTS_REGION = true; |
| 40 | 41 |
|
| 41 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 |
|
|
| 43 |
/** |
|
| 44 |
* Rotate part of the Object around the Center of the Effect by a certain angle. |
|
| 45 |
* |
|
| 46 |
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise. |
|
| 47 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 48 |
* @param region Region that masks the Effect. |
|
| 49 |
*/ |
|
| 43 | 50 |
public VertexEffectSwirl(Data1D swirl, Data3D center, Data4D region) |
| 44 | 51 |
{
|
| 45 |
super(SWIRL,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 52 |
super(SWIRL,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 46 | 53 |
|
| 47 | 54 |
if( swirl instanceof Dynamic1D) |
| 48 | 55 |
{
|
| ... | ... | |
| 73 | 80 |
} |
| 74 | 81 |
|
| 75 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 76 |
|
|
| 83 |
/** |
|
| 84 |
* Rotate the whole Object around the Center of the Effect by a certain angle. |
|
| 85 |
* |
|
| 86 |
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise. |
|
| 87 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 88 |
*/ |
|
| 77 | 89 |
public VertexEffectSwirl(Data1D swirl, Data3D center) |
| 78 | 90 |
{
|
| 79 |
super(SWIRL,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 91 |
super(SWIRL,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 80 | 92 |
|
| 81 | 93 |
if( swirl instanceof Dynamic1D) |
| 82 | 94 |
{
|
| src/main/java/org/distorted/library/effect/VertexEffectWave.java | ||
|---|---|---|
| 33 | 33 |
|
| 34 | 34 |
public class VertexEffectWave extends VertexEffect |
| 35 | 35 |
{
|
| 36 |
private static final String NAME = "WAVE"; |
|
| 36 | 37 |
private static final float[] UNITIES = new float[] {0.0f};
|
| 37 | 38 |
private static final int DIMENSION = 5; |
| 38 | 39 |
private static final boolean SUPPORTS_CENTER = true; |
| 39 | 40 |
private static final boolean SUPPORTS_REGION = true; |
| 40 | 41 |
|
| 41 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 |
|
|
| 43 |
public VertexEffectWave(Data5D wave, Data3D center, Data4D region) |
|
| 43 |
/** |
|
| 44 |
* Directional, sinusoidal wave effect. |
|
| 45 |
* |
|
| 46 |
* @param wave A 5-dimensional data structure describing the wave: first member is the amplitude, |
|
| 47 |
* second is the wave length, third is the phase (i.e. when phase = PI/2, the sine |
|
| 48 |
* wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two |
|
| 49 |
* describe the 'direction' of the wave. |
|
| 50 |
* <p> |
|
| 51 |
* Wave direction is defined to be a 3D vector of length 1. To define such vectors, we |
|
| 52 |
* need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector |
|
| 53 |
* forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which |
|
| 54 |
* the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise). |
|
| 55 |
* <p> |
|
| 56 |
* <p> |
|
| 57 |
* Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically' |
|
| 58 |
* in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane |
|
| 59 |
* will be sine shapes. |
|
| 60 |
* <p> |
|
| 61 |
* Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical', |
|
| 62 |
* but this time it waves in the Y-direction, i.e. cross sections of the surface and the |
|
| 63 |
* YZ-plane with be sine shapes. |
|
| 64 |
* <p> |
|
| 65 |
* Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave |
|
| 66 |
* is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the |
|
| 67 |
* value if sin at this point. |
|
| 68 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 69 |
*/ |
|
| 70 |
public VertexEffectWave(Data5D wave, Data3D center) |
|
| 44 | 71 |
{
|
| 45 |
super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 72 |
super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 46 | 73 |
|
| 47 | 74 |
if( wave instanceof Dynamic5D) |
| 48 | 75 |
{
|
| ... | ... | |
| 57 | 84 |
{
|
| 58 | 85 |
mStaticCenter = (Static3D)center; |
| 59 | 86 |
} |
| 60 |
else if( center instanceof Dynamic3D) |
|
| 87 |
else if( center instanceof Dynamic3D )
|
|
| 61 | 88 |
{
|
| 62 | 89 |
mDynamicCenter = (Dynamic3D)center; |
| 63 | 90 |
} |
| 64 | 91 |
|
| 65 |
if( region instanceof Static4D) |
|
| 66 |
{
|
|
| 67 |
mStaticRegion = (Static4D)region; |
|
| 68 |
} |
|
| 69 |
else if( region instanceof Dynamic4D) |
|
| 70 |
{
|
|
| 71 |
mDynamicRegion = (Dynamic4D)region; |
|
| 72 |
} |
|
| 92 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 73 | 93 |
} |
| 74 | 94 |
|
| 75 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 76 |
|
|
| 77 |
public VertexEffectWave(Data5D wave, Data3D center) |
|
| 96 |
/** |
|
| 97 |
* Directional, sinusoidal wave effect. |
|
| 98 |
* |
|
| 99 |
* @param wave see {@link VertexEffectWave(Data5D,Data3D)}
|
|
| 100 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
|
| 101 |
* @param region Region that masks the Effect. |
|
| 102 |
*/ |
|
| 103 |
public VertexEffectWave(Data5D wave, Data3D center, Data4D region) |
|
| 78 | 104 |
{
|
| 79 |
super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION); |
|
| 105 |
super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
|
|
| 80 | 106 |
|
| 81 | 107 |
if( wave instanceof Dynamic5D) |
| 82 | 108 |
{
|
| ... | ... | |
| 91 | 117 |
{
|
| 92 | 118 |
mStaticCenter = (Static3D)center; |
| 93 | 119 |
} |
| 94 |
else if( center instanceof Dynamic3D )
|
|
| 120 |
else if( center instanceof Dynamic3D) |
|
| 95 | 121 |
{
|
| 96 | 122 |
mDynamicCenter = (Dynamic3D)center; |
| 97 | 123 |
} |
| 98 | 124 |
|
| 99 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 125 |
if( region instanceof Static4D) |
|
| 126 |
{
|
|
| 127 |
mStaticRegion = (Static4D)region; |
|
| 128 |
} |
|
| 129 |
else if( region instanceof Dynamic4D) |
|
| 130 |
{
|
|
| 131 |
mDynamicRegion = (Dynamic4D)region; |
|
| 132 |
} |
|
| 100 | 133 |
} |
| 101 | 134 |
|
| 102 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/library/main/DistortedEffects.java | ||
|---|---|---|
| 31 | 31 |
import org.distorted.library.program.LinkingException; |
| 32 | 32 |
import org.distorted.library.program.VertexCompilationException; |
| 33 | 33 |
import org.distorted.library.program.VertexUniformsException; |
| 34 |
import org.distorted.library.type.Data1D; |
|
| 35 |
import org.distorted.library.type.Data2D; |
|
| 36 |
import org.distorted.library.type.Data3D; |
|
| 37 |
import org.distorted.library.type.Data4D; |
|
| 38 |
import org.distorted.library.type.Data5D; |
|
| 39 |
import org.distorted.library.type.Static3D; |
|
| 40 | 34 |
|
| 41 | 35 |
import java.io.InputStream; |
| 42 | 36 |
import java.nio.ByteBuffer; |
| 43 | 37 |
import java.nio.ByteOrder; |
| 44 | 38 |
import java.nio.FloatBuffer; |
| 39 |
import java.util.ArrayList; |
|
| 45 | 40 |
|
| 46 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 47 | 42 |
/** |
| ... | ... | |
| 55 | 50 |
/// MAIN PROGRAM /// |
| 56 | 51 |
private static DistortedProgram mMainProgram; |
| 57 | 52 |
private static int mMainTextureH; |
| 58 |
private static boolean[] mEffectEnabled = new boolean[EffectNames.size()]; |
|
| 59 |
|
|
| 60 |
static |
|
| 61 |
{
|
|
| 62 |
int len = EffectNames.size(); |
|
| 63 |
|
|
| 64 |
for(int i=0; i<len; i++) |
|
| 65 |
{
|
|
| 66 |
mEffectEnabled[i] = false; |
|
| 67 |
} |
|
| 68 |
} |
|
| 53 |
private static ArrayList<Effect> mEnabledEffects = new ArrayList<>(); |
|
| 69 | 54 |
|
| 70 | 55 |
/// BLIT PROGRAM /// |
| 71 | 56 |
private static DistortedProgram mBlitProgram; |
| ... | ... | |
| 112 | 97 |
String mainVertHeader= Distorted.GLSL_VERSION; |
| 113 | 98 |
String mainFragHeader= Distorted.GLSL_VERSION; |
| 114 | 99 |
|
| 115 |
EffectNames name; |
|
| 116 |
EffectTypes type; |
|
| 117 | 100 |
boolean foundF = false; |
| 118 | 101 |
boolean foundV = false; |
| 102 |
int type, effects = mEnabledEffects.size(); |
|
| 103 |
Effect effect; |
|
| 119 | 104 |
|
| 120 |
for(int i=0; i<mEffectEnabled.length; i++)
|
|
| 105 |
for(int i=0; i<effects; i++)
|
|
| 121 | 106 |
{
|
| 122 |
if( mEffectEnabled[i] ) |
|
| 107 |
effect = mEnabledEffects.remove(0); |
|
| 108 |
type = effect.getType(); |
|
| 109 |
|
|
| 110 |
if( type == Effect.VERTEX ) |
|
| 111 |
{
|
|
| 112 |
mainVertHeader += ("#define "+effect.getString()+" "+effect.getName()+"\n");
|
|
| 113 |
foundV = true; |
|
| 114 |
} |
|
| 115 |
else if( type == Effect.FRAGMENT ) |
|
| 123 | 116 |
{
|
| 124 |
name = EffectNames.getName(i); |
|
| 125 |
type = EffectNames.getType(i); |
|
| 126 |
|
|
| 127 |
if( type == EffectTypes.VERTEX ) |
|
| 128 |
{
|
|
| 129 |
mainVertHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
|
|
| 130 |
foundV = true; |
|
| 131 |
} |
|
| 132 |
else if( type == EffectTypes.FRAGMENT ) |
|
| 133 |
{
|
|
| 134 |
mainFragHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
|
|
| 135 |
foundF = true; |
|
| 136 |
} |
|
| 117 |
mainFragHeader += ("#define "+effect.getString()+" "+effect.getName()+"\n");
|
|
| 118 |
foundF = true; |
|
| 137 | 119 |
} |
| 138 | 120 |
} |
| 139 | 121 |
|
| ... | ... | |
| 357 | 339 |
static void onDestroy() |
| 358 | 340 |
{
|
| 359 | 341 |
mNextID = 0; |
| 360 |
|
|
| 361 |
int len = EffectNames.size(); |
|
| 362 |
|
|
| 363 |
for(int i=0; i<len; i++) |
|
| 364 |
{
|
|
| 365 |
mEffectEnabled[i] = false; |
|
| 366 |
} |
|
| 367 | 342 |
} |
| 368 | 343 |
|
| 369 | 344 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 458 | 433 |
/** |
| 459 | 434 |
* Aborts all Effects of a given type, for example all MATRIX Effects. |
| 460 | 435 |
* |
| 461 |
* @param type one of the constants defined in {@link EffectTypes}
|
|
| 436 |
* @param type one of the constants defined in {@link Effect}
|
|
| 462 | 437 |
* @return Number of effects aborted. |
| 463 | 438 |
*/ |
| 464 |
public int abortEffects(EffectTypes type)
|
|
| 439 |
public int abortByType(int type)
|
|
| 465 | 440 |
{
|
| 466 | 441 |
switch(type) |
| 467 | 442 |
{
|
| 468 |
case MATRIX : return mM.abortAll(true); |
|
| 469 |
case VERTEX : return mV.abortAll(true); |
|
| 470 |
case FRAGMENT : return mF.abortAll(true); |
|
| 471 |
default : return 0; |
|
| 443 |
case Effect.MATRIX : return mM.abortAll(true); |
|
| 444 |
case Effect.VERTEX : return mV.abortAll(true); |
|
| 445 |
case Effect.FRAGMENT : return mF.abortAll(true); |
|
| 446 |
// case Effect.POSTPROCESS: return mP.abortAll(true); |
|
| 447 |
default : return 0; |
|
| 472 | 448 |
} |
| 473 | 449 |
} |
| 474 | 450 |
|
| ... | ... | |
| 476 | 452 |
/** |
| 477 | 453 |
* Aborts a single Effect. |
| 478 | 454 |
* |
| 479 |
* @param id ID of the Effect we want to abort.
|
|
| 455 |
* @param effect the Effect we want to abort.
|
|
| 480 | 456 |
* @return number of Effects aborted. Always either 0 or 1. |
| 481 | 457 |
*/ |
| 482 |
public int abortEffect(long id)
|
|
| 458 |
public int abortEffect(Effect effect)
|
|
| 483 | 459 |
{
|
| 484 |
int type = (int)(id&Effect.MASK); |
|
| 485 |
|
|
| 486 |
if( type==Effect.MATRIX ) return mM.removeByID(id>>Effect.LENGTH); |
|
| 487 |
if( type==Effect.VERTEX ) return mV.removeByID(id>>Effect.LENGTH); |
|
| 488 |
if( type==Effect.FRAGMENT ) return mF.removeByID(id>>Effect.LENGTH); |
|
| 489 |
|
|
| 490 |
return 0; |
|
| 460 |
switch(effect.getType()) |
|
| 461 |
{
|
|
| 462 |
case Effect.MATRIX : return mM.removeEffect(effect); |
|
| 463 |
case Effect.VERTEX : return mV.removeEffect(effect); |
|
| 464 |
case Effect.FRAGMENT : return mF.removeEffect(effect); |
|
| 465 |
// case Effect.POSTPROCESS: return mP.removeEffect(effect); |
|
| 466 |
default : return 0; |
|
| 467 |
} |
|
| 491 | 468 |
} |
| 492 | 469 |
|
| 493 | 470 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 494 | 471 |
/** |
| 495 | 472 |
* Abort all Effects of a given name, for example all rotations. |
| 496 | 473 |
* |
| 497 |
* @param name one of the constants defined in {@link EffectNames}
|
|
| 474 |
* @param name one of the constants defined in |
|
| 475 |
* {@link org.distorted.library.effect.MatrixEffect},
|
|
| 476 |
* {@link org.distorted.library.effect.VertexEffect},
|
|
| 477 |
* {@link org.distorted.library.effect.FragmentEffect} or
|
|
| 478 |
* {@link org.distorted.library.effect.PostprocessEffect}
|
|
| 498 | 479 |
* @return number of Effects aborted. |
| 499 | 480 |
*/ |
| 500 |
public int abortEffects(EffectNames name)
|
|
| 481 |
public int abortByName(int name)
|
|
| 501 | 482 |
{
|
| 502 |
switch(name.getType())
|
|
| 483 |
switch(Effect.getType(name))
|
|
| 503 | 484 |
{
|
| 504 |
case MATRIX : return mM.removeByType(name); |
|
| 505 |
case VERTEX : return mV.removeByType(name); |
|
| 506 |
case FRAGMENT : return mF.removeByType(name); |
|
| 507 |
default : return 0; |
|
| 485 |
case Effect.MATRIX : return mM.removeByName(name); |
|
| 486 |
case Effect.VERTEX : return mV.removeByName(name); |
|
| 487 |
case Effect.FRAGMENT : return mF.removeByName(name); |
|
| 488 |
// case Effect.POSTPROCESS: return mP.removeByName(name); |
|
| 489 |
default : return 0; |
|
| 508 | 490 |
} |
| 509 | 491 |
} |
| 510 |
|
|
| 511 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 512 |
/** |
|
| 513 |
* Print some info about a given Effect to Android's standard out. Used for debugging only. |
|
| 514 |
* |
|
| 515 |
* @param id Effect ID we want to print info about |
|
| 516 |
* @return <code>true</code> if a single Effect of type effectType has been found. |
|
| 517 |
*/ |
|
| 518 |
@SuppressWarnings("unused")
|
|
| 519 |
public boolean printEffect(long id) |
|
| 520 |
{
|
|
| 521 |
int type = (int)(id&EffectTypes.MASK); |
|
Also available in: Unified diff
Progress with support for Effect classes.