Project

General

Profile

« Previous | Next » 

Revision da9b3f07

Added by Leszek Koltunski over 7 years ago

Progress with support for Effect classes.

The library compiles now!

View differences:

src/main/java/org/distorted/library/effect/Effect.java
23 23

  
24 24
public abstract class Effect
25 25
  {
26
  private final static int MAX_UNITY_DIM = 4;
27
  private final static int NUM_EFFECTS = EffectName.size();
28

  
26 29
  private final long mID;
27
  private final int mType;
28
  private final int mName;
30
  private final EffectType mType;
31
  private final EffectName mName;
29 32
  private final int mDimension;
30 33
  private final boolean mSupportsR;
31 34
  private final boolean mSupportsC;
32
  private final String mStr;
33 35

  
34 36
  private static long mNextID = 0;
35 37

  
36
  public static final int MATRIX      = 0;
37
  public static final int VERTEX      = 1;
38
  public static final int FRAGMENT    = 2;
39
  public static final int POSTPROCESS = 3;
40

  
41
  public static final int LENGTH = 4;           // The number of effect types above.
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.
38
  private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS];
39
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
44 40

  
45 41
///////////////////////////////////////////////////////////////////////////////////////////////////
46 42

  
......
55 51

  
56 52
///////////////////////////////////////////////////////////////////////////////////////////////////
57 53

  
58
  public static void reset(int[] maxtable)
54
  public boolean isUnity(float[] buffer, int index)
59 55
    {
60
    maxtable[0] = MatrixEffect.MAX;
61
    maxtable[1] = VertexEffect.MAX;
62
    maxtable[2] = FragmentEffect.MAX;
63
    maxtable[3] = PostprocessEffect.MAX;
56
    int name = mName.ordinal();
57

  
58
    switch(mUnityDim[name])
59
      {
60
      case 0: return true;
61
      case 1: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ];
62
      case 2: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
63
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
64
      case 3: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
65
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
66
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
67
      case 4: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
68
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
69
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
70
                     buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
71
      }
72

  
73
    return false;
64 74
    }
65

  
66 75
///////////////////////////////////////////////////////////////////////////////////////////////////
67 76

  
68
  public static int getType(int name)
69
    {
70
    return name/MAX_EFFECTS;
71
    }
72

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75
  public int getType()
77
  public EffectType getType()
76 78
    {
77 79
    return mType;
78 80
    }
79 81

  
80 82
///////////////////////////////////////////////////////////////////////////////////////////////////
81 83

  
82
  public int getName()
84
  public EffectName getName()
83 85
    {
84 86
    return mName;
85 87
    }
......
95 97

  
96 98
  public String getString()
97 99
    {
98
    return mStr;
100
    return mName.name();
99 101
    }
100 102

  
101 103
///////////////////////////////////////////////////////////////////////////////////////////////////
......
121 123

  
122 124
///////////////////////////////////////////////////////////////////////////////////////////////////
123 125

  
124
  Effect(int type, int name, int dimension, boolean center, boolean region, final String str)
126
  Effect(EffectType type, EffectName name, int dimension, boolean center, boolean region, float[] unity)
125 127
    {
126 128
    mID        = mNextID++;
127 129

  
......
130 132
    mDimension = dimension;
131 133
    mSupportsC = center;
132 134
    mSupportsR = region;
133
    mStr       = str;
135

  
136
    int n = name.ordinal();
137
    int l = unity.length;
138

  
139
    for(int i=0; i<l; i++)
140
      {
141
      mUnity[n*MAX_UNITY_DIM+i] = unity[i];
142
      }
143

  
144
    mUnityDim[n] = l;
134 145
    }
135 146
  }
src/main/java/org/distorted/library/effect/EffectName.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.library.effect;
21

  
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23
/**
24
 * Names of Effects one can add to the DistortedEffects queues.
25
 * <p>
26
 * Effect's 'Type' is one of the constants defined in {@link EffectType}.
27
 */
28

  
29
public enum EffectName
30
  {
31
  // EFFECT NAME /////// EFFECT TYPE
32
  // MATRIX EFFECTS
33
  ROTATE           ( EffectType.MATRIX ),
34
  QUATERNION       ( EffectType.MATRIX ),
35
  MOVE             ( EffectType.MATRIX ),
36
  SCALE            ( EffectType.MATRIX ),
37
  SHEAR            ( EffectType.MATRIX ),
38
  // add new Matrix effects here...
39
  // VERTEX EFFECTS
40
  DISTORT          ( EffectType.VERTEX ),
41
  DEFORM           ( EffectType.VERTEX ),
42
  SINK             ( EffectType.VERTEX ),
43
  PINCH            ( EffectType.VERTEX ),
44
  SWIRL            ( EffectType.VERTEX ),
45
  WAVE             ( EffectType.VERTEX ),
46
  // add new Vertex Effects here...
47
  // FRAGMENT EFFECTS
48
  ALPHA            ( EffectType.FRAGMENT ),
49
  SMOOTH_ALPHA     ( EffectType.FRAGMENT ),
50
  CHROMA           ( EffectType.FRAGMENT ),
51
  SMOOTH_CHROMA    ( EffectType.FRAGMENT ),
52
  BRIGHTNESS       ( EffectType.FRAGMENT ),
53
  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT ),
54
  SATURATION       ( EffectType.FRAGMENT ),
55
  SMOOTH_SATURATION( EffectType.FRAGMENT ),
56
  CONTRAST         ( EffectType.FRAGMENT ),
57
  SMOOTH_CONTRAST  ( EffectType.FRAGMENT ),
58
  // add new Fragment effects here...
59
  // POSTPROCESSING EFFECTS.
60
  BLUR             ( EffectType.POSTPROCESS ),
61
  GLOW             ( EffectType.POSTPROCESS );
62
  // add new Postprocess effects here...
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66
  private final EffectType type;
67

  
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

  
70
  EffectName(EffectType type)
71
    {
72
    this.type = type;
73
    }
74

  
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

  
77
  static int size()
78
    {
79
    return values().length;
80
    }
81

  
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83
// PUBLIC API
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85
/**
86
 * Returns the Type of an individual Effect. For example, EffectName.ROTATION.getType() will
87
 * return EffectType.MATRIX.
88
 * @return type of the effect.
89
 */
90
  public EffectType getType()
91
    {
92
    return type;
93
    }
94
  }
95

  
src/main/java/org/distorted/library/effect/EffectType.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.library.effect;
21

  
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

  
24
/**
25
 * Types of Effects one can add to the DistortedEffects queues.
26
 * <p>
27
 * Each effect type goes to an independent queue; the queues get executed one-by-one
28
 * and are each a class descendant from EffectQueue.
29
 */
30

  
31
public enum EffectType
32
  {
33
  /**
34
   * Effects that change the ModelView matrix: Rotations, Moves, Shears, Scales.
35
   */
36
  MATRIX,
37
  /**
38
   * Effects that get executed in the Vertex shader: various distortions of the vertices.
39
   */
40
  VERTEX,
41
  /**
42
   * Effects executed in the Fragment shader: changes of color, hue, transparency levels, etc.
43
   */
44
  FRAGMENT,
45
  /**
46
   * Postprocessing effects done to the texture the first stage fragment shader created
47
   */
48
  POSTPROCESS;
49

  
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

  
52
  public static final int LENGTH = values().length;  // The number of effect types.
53
  public static final int MASK= (1<<LENGTH)-1;       // Needed when we do bitwise operations on Effect Types.
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56
// called from EffectQueue
57

  
58
  public static void reset(int[] maxtable)
59
    {
60
    maxtable[0] =10;  // By default, there can be a maximum 10 MATRIX effects in a single
61
                      // EffectQueueMatrix at any given time. This can be changed with a call
62
                      // to EffectQueueMatrix.setMax(int)
63
    maxtable[1] = 5;  // Max 5 VERTEX Effects
64
    maxtable[2] = 5;  // Max 5 FRAGMENT Effects
65
    maxtable[3] = 5;  // Max 5 POSTPROCESSING Effects
66
    }
67
  }
src/main/java/org/distorted/library/effect/FragmentEffect.java
32 32
  {
33 33
  public static final int NUM_UNIFORMS = 8;
34 34

  
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;
46

  
47
  static final int MAX = 5;
48
  private static final int MAX_UNITY_DIM = 1;
49

  
50 35
  Dynamic mDynamic0, mDynamic1;
51 36
  Static mStatic0, mStatic1;
52 37
  Dynamic4D mDynamicRegion;
53 38
  Static4D mStaticRegion;
54 39

  
55
  private final static float[] mUnity    = new float[MAX_UNITY_DIM*NUM_EFFECTS];
56
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
57

  
58 40
///////////////////////////////////////////////////////////////////////////////////////////////////
59 41

  
60
  public FragmentEffect(int name,float[] unity, int dimension, boolean center, boolean region, final String str)
42
  public FragmentEffect(EffectName name, int dimension, boolean center, boolean region, float[] unity)
61 43
    {
62
    super(FRAGMENT,name,dimension,center,region,str);
63

  
64
    for(int i=0; i<unity.length; i++)
65
      {
66
      mUnity[name*MAX_UNITY_DIM+i] = unity[i];
67
      }
68

  
69
    mUnityDim[name] = unity.length;
70
    }
71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

  
74
  public static boolean isUnity(int name, float[] buffer, int index)
75
    {
76
    switch(mUnityDim[name])
77
      {
78
      case 0: return true;
79
      case 1: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ];
80
      case 2: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
81
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
82
      case 3: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
83
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
84
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
85
      case 4: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
86
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
87
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
88
                     buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
89
      }
90

  
91
    return false;
44
    super(EffectType.FRAGMENT,name,dimension,center,region,unity);
92 45
    }
93 46
  }
src/main/java/org/distorted/library/effect/FragmentEffectAlpha.java
30 30

  
31 31
public class FragmentEffectAlpha extends FragmentEffect
32 32
  {
33
  private static final String NAME = "ALPHA";
34
  private static final float[] UNITIES = new float[] {1.0f};
35
  private static final int DIMENSION = 1;
33
  private static final float[] UNITIES         = new float[] {1.0f};
34
  private static final int     DIMENSION       = 1;
36 35
  private static final boolean SUPPORTS_CENTER = false;
37 36
  private static final boolean SUPPORTS_REGION = true;
38 37

  
......
48 47
 */
49 48
  public FragmentEffectAlpha(Data1D alpha, Data4D region, boolean smooth)
50 49
    {
51
    super(smooth?SMOOTH_ALPHA:ALPHA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
50
    super(smooth? EffectName.SMOOTH_ALPHA:EffectName.ALPHA ,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
52 51

  
53 52
    if( alpha instanceof Dynamic1D )
54 53
      {
......
79 78
 */
80 79
  public FragmentEffectAlpha(Data1D alpha)
81 80
    {
82
    super(ALPHA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
81
    super(EffectName.ALPHA,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
83 82

  
84 83
    if( alpha instanceof Dynamic1D )
85 84
      {
src/main/java/org/distorted/library/effect/FragmentEffectBrightness.java
30 30

  
31 31
public class FragmentEffectBrightness extends FragmentEffect
32 32
  {
33
  private static final String NAME = "BRIGHTNESS";
34
  private static final float[] UNITIES = new float[] {1.0f};
35
  private static final int DIMENSION = 1;
33
  private static final float[] UNITIES         = new float[] {1.0f};
34
  private static final int DIMENSION           = 1;
36 35
  private static final boolean SUPPORTS_CENTER = false;
37 36
  private static final boolean SUPPORTS_REGION = true;
38 37

  
......
47 46
 */
48 47
  public FragmentEffectBrightness(Data1D brightness, Data4D region, boolean smooth)
49 48
    {
50
    super(smooth?SMOOTH_BRIGHTNESS:BRIGHTNESS ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
49
    super(smooth?EffectName.SMOOTH_BRIGHTNESS:EffectName.BRIGHTNESS ,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
51 50

  
52 51
    if( brightness instanceof Dynamic1D )
53 52
      {
......
77 76
 */
78 77
  public FragmentEffectBrightness(Data1D brightness)
79 78
    {
80
    super(BRIGHTNESS,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
79
    super(EffectName.BRIGHTNESS,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
81 80

  
82 81
    if( brightness instanceof Dynamic1D )
83 82
      {
src/main/java/org/distorted/library/effect/FragmentEffectChroma.java
33 33

  
34 34
public class FragmentEffectChroma extends FragmentEffect
35 35
  {
36
  private static final String NAME = "CHROMA";
37
  private static final float[] UNITIES = new float[] {0.0f};
38
  private static final int DIMENSION = 4;
36
  private static final float[] UNITIES         = new float[] {0.0f};
37
  private static final int DIMENSION           = 4;
39 38
  private static final boolean SUPPORTS_CENTER = false;
40 39
  private static final boolean SUPPORTS_REGION = true;
41 40

  
......
52 51
 */
53 52
  public FragmentEffectChroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
54 53
    {
55
    super(smooth?SMOOTH_CHROMA:CHROMA ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
54
    super(smooth?EffectName.SMOOTH_CHROMA:EffectName.CHROMA,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
56 55

  
57 56
    if( blend instanceof Dynamic1D )
58 57
      {
......
93 92
 */
94 93
  public FragmentEffectChroma(Data1D blend, Data3D color)
95 94
    {
96
    super(CHROMA,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
95
    super(EffectName.CHROMA,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
97 96

  
98 97
    if( blend instanceof Dynamic1D )
99 98
      {
src/main/java/org/distorted/library/effect/FragmentEffectContrast.java
30 30

  
31 31
public class FragmentEffectContrast extends FragmentEffect
32 32
  {
33
  private static final String NAME = "CONTRAST";
34
  private static final float[] UNITIES = new float[] {1.0f};
35
  private static final int DIMENSION = 1;
33
  private static final float[] UNITIES         = new float[] {1.0f};
34
  private static final int DIMENSION           = 1;
36 35
  private static final boolean SUPPORTS_CENTER = false;
37 36
  private static final boolean SUPPORTS_REGION = true;
38 37

  
......
47 46
 */
48 47
  public FragmentEffectContrast(Data1D contrast, Data4D region, boolean smooth)
49 48
    {
50
    super(smooth?SMOOTH_CONTRAST:CONTRAST ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
49
    super(smooth?EffectName.SMOOTH_CONTRAST:EffectName.CONTRAST,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
51 50

  
52 51
    if( contrast instanceof Dynamic1D )
53 52
      {
......
77 76
 */
78 77
  public FragmentEffectContrast(Data1D contrast)
79 78
    {
80
    super(CONTRAST,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
79
    super(EffectName.CONTRAST,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
81 80

  
82 81
    if( contrast instanceof Dynamic1D )
83 82
      {
src/main/java/org/distorted/library/effect/FragmentEffectSaturation.java
30 30

  
31 31
public class FragmentEffectSaturation extends FragmentEffect
32 32
  {
33
  private static final String NAME = "SATURATION";
34
  private static final float[] UNITIES = new float[] {1.0f};
35
  private static final int DIMENSION = 1;
33
  private static final float[] UNITIES         = new float[] {1.0f};
34
  private static final int DIMENSION           = 1;
36 35
  private static final boolean SUPPORTS_CENTER = false;
37 36
  private static final boolean SUPPORTS_REGION = true;
38 37

  
......
47 46
 */
48 47
  public FragmentEffectSaturation(Data1D saturation, Data4D region, boolean smooth)
49 48
    {
50
    super(smooth?SMOOTH_SATURATION:SATURATION ,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
49
    super(smooth?EffectName.SMOOTH_SATURATION:EffectName.SATURATION ,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
51 50

  
52 51
    if( saturation instanceof Dynamic1D )
53 52
      {
......
77 76
 */
78 77
  public FragmentEffectSaturation(Data1D saturation)
79 78
    {
80
    super(SATURATION,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
79
    super(EffectName.SATURATION,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
81 80

  
82 81
    if( saturation instanceof Dynamic1D )
83 82
      {
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       = 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
  public static final int NUM_EFFECTS= 5;
38

  
39
  static final int MAX = 5;
40
  private static final int MAX_UNITY_DIM = 3;
41

  
42 32
  Dynamic mDynamic0,mDynamic1;
43 33
  Static  mStatic0 , mStatic1;
44 34
  Dynamic3D mDynamicCenter;
45 35
  Static3D mStaticCenter;
46 36

  
47
  private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS];
48
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
49

  
50 37
///////////////////////////////////////////////////////////////////////////////////////////////////
51 38

  
52
  public MatrixEffect(int name, float[] unity, int dimension, boolean center, boolean region, final String str)
39
  public MatrixEffect(EffectName name, int dimension, boolean center, boolean region, float[] unity)
53 40
    {
54
    super(MATRIX,name,dimension,center,region,str);
55

  
56
    for(int i=0; i<unity.length; i++)
57
      {
58
      mUnity[name*MAX_UNITY_DIM+i] = unity[i];
59
      }
60

  
61
    mUnityDim[name] = unity.length;
62
    }
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66
  public static boolean isUnity(int name, float[] buffer, int index)
67
    {
68
    switch(mUnityDim[name])
69
      {
70
      case 0: return true;
71
      case 1: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ];
72
      case 2: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
73
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
74
      case 3: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
75
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
76
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
77
      case 4: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
78
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
79
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
80
                     buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
81
      }
82

  
83
    return false;
41
    super(EffectType.MATRIX,name,dimension,center,region,unity);
84 42
    }
85 43
  }
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";
31
  private static final float[] UNITIES = new float[]{0.0f, 0.0f, 0.0f};
32
  private static final int DIMENSION = 3;
30
  private static final float[] UNITIES         = new float[]{0.0f, 0.0f, 0.0f};
31
  private static final int DIMENSION           = 3;
33 32
  private static final boolean SUPPORTS_CENTER = false;
34 33
  private static final boolean SUPPORTS_REGION = false;
35 34

  
......
42 41
 */
43 42
  public MatrixEffectMove(Data3D vector)
44 43
    {
45
    super(MOVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
44
    super(EffectName.MOVE,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
46 45

  
47 46
    if( vector instanceof Static3D)
48 47
      {
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";
34
  private static final float[] UNITIES = new float[]{0.0f, 0.0f, 0.0f};
35
  private static final int DIMENSION = 4;
33
  private static final float[] UNITIES         = new float[]{0.0f, 0.0f, 0.0f};
34
  private static final int DIMENSION           = 4;
36 35
  private static final boolean SUPPORTS_CENTER = true;
37 36
  private static final boolean SUPPORTS_REGION = false;
38 37

  
......
45 44
 */
46 45
  public MatrixEffectQuaternion(Data4D quaternion, Data3D center )
47 46
    {
48
    super(QUATERNION,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
47
    super(EffectName.QUATERNION,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
49 48

  
50 49
    if( quaternion instanceof Static4D)
51 50
      {
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";
37
  private static final float[] UNITIES = new float[]{0.0f};
38
  private static final int DIMENSION = 4;
36
  private static final float[] UNITIES         = new float[]{0.0f};
37
  private static final int DIMENSION           = 4;
39 38
  private static final boolean SUPPORTS_CENTER = true;
40 39
  private static final boolean SUPPORTS_REGION = false;
41 40

  
......
50 49
 */
51 50
  public MatrixEffectRotate(Data1D angle, Static3D axis, Data3D center)
52 51
    {
53
    super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
52
    super(EffectName.ROTATE,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
54 53

  
55 54
    if( angle instanceof Static1D )
56 55
      {
......
83 82
 */
84 83
  public MatrixEffectRotate(Data4D angleaxis, Data3D center)
85 84
    {
86
    super(ROTATE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
85
    super(EffectName.ROTATE,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
87 86

  
88 87
    if( angleaxis instanceof Static4D)
89 88
      {
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";
31
  private static final float[] UNITIES = new float[] {1.0f,1.0f,1.0f};
32
  private static final int DIMENSION = 3;
30
  private static final float[] UNITIES         = new float[] {1.0f,1.0f,1.0f};
31
  private static final int DIMENSION           = 3;
33 32
  private static final boolean SUPPORTS_CENTER = false;
34 33
  private static final boolean SUPPORTS_REGION = false;
35 34

  
......
42 41
 */
43 42
  public MatrixEffectScale(Data3D scale)
44 43
    {
45
    super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
44
    super(EffectName.SCALE,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
46 45

  
47 46
    if( scale instanceof Static3D)
48 47
      {
......
62 61
 */
63 62
  public MatrixEffectScale(float scale)
64 63
    {
65
    super(SCALE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
64
    super(EffectName.SCALE,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
66 65

  
67 66
    mStatic0 = new Static3D(scale,scale,scale);
68 67
    }
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";
31
  private static final float[] UNITIES = new float[] {0.0f,0.0f,0.0f};
32
  private static final int DIMENSION = 3;
30
  private static final float[] UNITIES         = new float[] {0.0f,0.0f,0.0f};
31
  private static final int DIMENSION           = 3;
33 32
  private static final boolean SUPPORTS_CENTER = true;
34 33
  private static final boolean SUPPORTS_REGION = false;
35 34

  
......
45 44
 */
46 45
  public MatrixEffectShear(Data3D shear, Data3D center)
47 46
    {
48
    super(SHEAR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
47
    super(EffectName.SHEAR,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
49 48

  
50 49
    if( shear instanceof Static3D)
51 50
      {
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       = MAX_EFFECTS*POSTPROCESS    ;
34
  public static final int GLOW       = MAX_EFFECTS*POSTPROCESS + 1;
35
  public static final int NUM_EFFECTS= 2;
36

  
37
  static final int MAX = 5;
38
  private static final int MAX_UNITY_DIM = 1;
39

  
40 33
  Dynamic mDynamic0, mDynamic1;
41 34
  Static mStatic0, mStatic1;
42 35

  
43
  private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS];
44
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
45

  
46 36
///////////////////////////////////////////////////////////////////////////////////////////////////
47 37

  
48
  public PostprocessEffect(int name, float[] unity, int dimension, boolean center, boolean region, final String str)
38
  public PostprocessEffect(EffectName name, int dimension, boolean center, boolean region, float[] unity)
49 39
    {
50
    super(POSTPROCESS,name,dimension,center,region,str);
51

  
52
    for(int i=0; i<unity.length; i++)
53
      {
54
      mUnity[name*MAX_UNITY_DIM+i] = unity[i];
55
      }
56

  
57
    mUnityDim[name] = unity.length;
58
    }
59

  
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

  
62
  public static boolean isUnity(int name, float[] buffer, int index)
63
    {
64
    switch(mUnityDim[name])
65
      {
66
      case 0: return true;
67
      case 1: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ];
68
      case 2: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
69
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
70
      case 3: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
71
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
72
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
73
      case 4: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
74
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
75
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
76
                     buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
77
      }
78

  
79
    return false;
40
    super(EffectType.POSTPROCESS,name,dimension,center,region,unity);
80 41
    }
81 42
  }
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";
31
  private static final float[] UNITIES = new float[] {0.0f};
32
  private static final int DIMENSION = 1;
30
  private static final float[] UNITIES         = new float[] {0.0f};
31
  private static final int DIMENSION           = 1;
33 32
  private static final boolean SUPPORTS_CENTER = false;
34 33
  private static final boolean SUPPORTS_REGION = false;
35 34

  
......
42 41
 */
43 42
  public PostprocessEffectBlur(Data1D radius)
44 43
    {
45
    super(BLUR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
44
    super(EffectName.BLUR,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
46 45

  
47 46
    if( radius instanceof Dynamic1D)
48 47
      {
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";
34
  private static final float[] UNITIES = new float[] {0.0f};
35
  private static final int DIMENSION = 5;
33
  private static final float[] UNITIES         = new float[] {0.0f};
34
  private static final int DIMENSION           = 5;
36 35
  private static final boolean SUPPORTS_CENTER = false;
37 36
  private static final boolean SUPPORTS_REGION = false;
38 37

  
......
46 45
 */
47 46
  public PostprocessEffectGlow(Data1D radius, Data4D color)
48 47
    {
49
    super(GLOW,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
48
    super(EffectName.GLOW,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
50 49

  
51 50
    if( radius instanceof Dynamic1D)
52 51
      {
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    = 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

  
45
  static final int MAX = 5;
46
  private static final int MAX_UNITY_DIM = 3;
47

  
48 37
  Dynamic mDynamic0;
49 38
  Static mStatic0;
50 39
  Dynamic3D mDynamicCenter;
......
52 41
  Dynamic4D mDynamicRegion;
53 42
  Static4D  mStaticRegion;
54 43

  
55
  private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS];
56
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
57

  
58 44
///////////////////////////////////////////////////////////////////////////////////////////////////
59 45

  
60
  public VertexEffect(int name, float[] unity, int dimension, boolean center, boolean region, final String str)
46
  public VertexEffect(EffectName name, int dimension, boolean center, boolean region, float[] unity)
61 47
    {
62
    super(VERTEX,name,dimension,center,region,str);
63

  
64
    for(int i=0; i<unity.length; i++)
65
      {
66
      mUnity[name*MAX_UNITY_DIM+i] = unity[i];
67
      }
68

  
69
    mUnityDim[name] = unity.length;
70
    }
71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

  
74
  public static boolean isUnity(int name, float[] buffer, int index)
75
    {
76
    switch(mUnityDim[name])
77
      {
78
      case 0: return true;
79
      case 1: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ];
80
      case 2: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
81
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
82
      case 3: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
83
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
84
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
85
      case 4: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
86
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
87
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
88
                     buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
89
      }
90

  
91
    return false;
48
    super(EffectType.VERTEX,name,dimension,center,region,unity);
92 49
    }
93 50
  }
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";
34
  private static final float[] UNITIES = new float[] {0.0f,0.0f,0.0f};
35
  private static final int DIMENSION = 3;
33
  private static final float[] UNITIES         = new float[] {0.0f,0.0f,0.0f};
34
  private static final int DIMENSION           = 3;
36 35
  private static final boolean SUPPORTS_CENTER = true;
37 36
  private static final boolean SUPPORTS_REGION = true;
38 37

  
......
47 46
 */
48 47
  public VertexEffectDeform(Data3D vector, Data3D center, Data4D region)
49 48
    {
50
    super(DEFORM,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
49
    super(EffectName.DEFORM,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
51 50

  
52 51
    if( vector instanceof Dynamic3D )
53 52
      {
......
87 86
 */
88 87
  public VertexEffectDeform(Data3D vector, Data3D center)
89 88
    {
90
    super(DEFORM,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
89
    super(EffectName.DEFORM,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
91 90

  
92 91
    if( vector instanceof Dynamic3D )
93 92
      {
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";
34
  private static final float[] UNITIES = new float[] {0.0f,0.0f,0.0f};
35
  private static final int DIMENSION = 3;
33
  private static final float[] UNITIES         = new float[] {0.0f,0.0f,0.0f};
34
  private static final int DIMENSION           = 3;
36 35
  private static final boolean SUPPORTS_CENTER = true;
37 36
  private static final boolean SUPPORTS_REGION = true;
38 37

  
......
47 46
 */
48 47
  public VertexEffectDistort(Data3D vector, Data3D center, Data4D region)
49 48
    {
50
    super(DISTORT,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
49
    super(EffectName.DISTORT,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
51 50

  
52 51
    if( vector instanceof Dynamic3D )
53 52
      {
......
87 86
 */
88 87
  public VertexEffectDistort(Data3D vector, Data3D center)
89 88
    {
90
    super(DISTORT,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
89
    super(EffectName.DISTORT,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
91 90

  
92 91
    if( vector instanceof Dynamic3D )
93 92
      {
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";
37
  private static final float[] UNITIES = new float[] {1.0f};
38
  private static final int DIMENSION = 2;
36
  private static final float[] UNITIES         = new float[] {1.0f};
37
  private static final int     DIMENSION       = 2;
39 38
  private static final boolean SUPPORTS_CENTER = true;
40 39
  private static final boolean SUPPORTS_REGION = true;
41 40

  
......
50 49
 */
51 50
  public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region)
52 51
    {
53
    super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
52
    super(EffectName.PINCH,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
54 53

  
55 54
    if( pinch instanceof Dynamic2D)
56 55
      {
......
90 89
 */
91 90
  public VertexEffectPinch(Data2D pinch, Data3D center)
92 91
    {
93
    super(PINCH,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
92
    super(EffectName.PINCH,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
94 93

  
95 94
    if( pinch instanceof Dynamic2D)
96 95
      {
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";
37
  private static final float[] UNITIES = new float[] {1.0f};
38
  private static final int DIMENSION = 1;
36
  private static final float[] UNITIES         = new float[] {1.0f};
37
  private static final int     DIMENSION       = 1;
39 38
  private static final boolean SUPPORTS_CENTER = true;
40 39
  private static final boolean SUPPORTS_REGION = true;
41 40

  
......
50 49
 */
51 50
  public VertexEffectSink(Data1D sink, Data3D center, Data4D region)
52 51
    {
53
    super(SINK,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
52
    super(EffectName.SINK,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
54 53

  
55 54
    if( sink instanceof Dynamic1D)
56 55
      {
......
90 89
 */
91 90
  public VertexEffectSink(Data1D sink, Data3D center)
92 91
    {
93
    super(SINK,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
92
    super(EffectName.SINK,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
94 93

  
95 94
    if( sink instanceof Dynamic1D)
96 95
      {
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";
37
  private static final float[] UNITIES = new float[] {0.0f};
38
  private static final int DIMENSION = 1;
36
  private static final float[] UNITIES         = new float[] {0.0f};
37
  private static final int     DIMENSION       = 1;
39 38
  private static final boolean SUPPORTS_CENTER = true;
40 39
  private static final boolean SUPPORTS_REGION = true;
41 40

  
......
49 48
 */
50 49
  public VertexEffectSwirl(Data1D swirl, Data3D center, Data4D region)
51 50
    {
52
    super(SWIRL,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
51
    super(EffectName.SWIRL,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
53 52

  
54 53
    if( swirl instanceof Dynamic1D)
55 54
      {
......
88 87
 */
89 88
  public VertexEffectSwirl(Data1D swirl, Data3D center)
90 89
    {
91
    super(SWIRL,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
90
    super(EffectName.SWIRL,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
92 91

  
93 92
    if( swirl instanceof Dynamic1D)
94 93
      {
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";
37
  private static final float[] UNITIES = new float[] {0.0f};
38
  private static final int DIMENSION = 5;
36
  private static final float[] UNITIES         = new float[] {0.0f};
37
  private static final int     DIMENSION       = 5;
39 38
  private static final boolean SUPPORTS_CENTER = true;
40 39
  private static final boolean SUPPORTS_REGION = true;
41 40

  
......
69 68
 */
70 69
  public VertexEffectWave(Data5D wave, Data3D center)
71 70
    {
72
    super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
71
    super(EffectName.WAVE,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
73 72

  
74 73
    if( wave instanceof Dynamic5D)
75 74
      {
......
102 101
 */
103 102
  public VertexEffectWave(Data5D wave, Data3D center, Data4D region)
104 103
    {
105
    super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
104
    super(EffectName.WAVE,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,UNITIES);
106 105

  
107 106
    if( wave instanceof Dynamic5D)
108 107
      {
src/main/java/org/distorted/library/main/DistortedEffects.java
24 24

  
25 25
import org.distorted.library.R;
26 26
import org.distorted.library.effect.Effect;
27
import org.distorted.library.effect.EffectName;
28
import org.distorted.library.effect.EffectType;
27 29
import org.distorted.library.message.EffectListener;
28 30
import org.distorted.library.program.DistortedProgram;
29 31
import org.distorted.library.program.FragmentCompilationException;
......
50 52
  /// MAIN PROGRAM ///
51 53
  private static DistortedProgram mMainProgram;
52 54
  private static int mMainTextureH;
53
  private static ArrayList<Effect> mEnabledEffects = new ArrayList<>();
55
  private static ArrayList<EffectName> mEnabledEffects = new ArrayList<>();
54 56

  
55 57
  /// BLIT PROGRAM ///
56 58
  private static DistortedProgram mBlitProgram;
......
99 101

  
100 102
    boolean foundF = false;
101 103
    boolean foundV = false;
102
    int type, effects = mEnabledEffects.size();
103
    Effect effect;
104
    int effects = mEnabledEffects.size();
105
    EffectName effect;
106
    EffectType type;
104 107

  
105 108
    for(int i=0; i<effects; i++)
106 109
      {
107 110
      effect = mEnabledEffects.remove(0);
108 111
      type   = effect.getType();
109 112

  
110
      if( type == Effect.VERTEX )
113
      if( type == EffectType.VERTEX )
111 114
        {
112
        mainVertHeader += ("#define "+effect.getString()+" "+effect.getName()+"\n");
115
        mainVertHeader += ("#define "+effect.name()+" "+effect.ordinal()+"\n");
113 116
        foundV = true;
114 117
        }
115
      else if( type == Effect.FRAGMENT )
118
      else if( type == EffectType.FRAGMENT )
116 119
        {
117
        mainFragHeader += ("#define "+effect.getString()+" "+effect.getName()+"\n");
120
        mainFragHeader += ("#define "+effect.name()+" "+effect.ordinal()+"\n");
118 121
        foundF = true;
119 122
        }
120 123
      }
......
433 436
/**
434 437
 * Aborts all Effects of a given type, for example all MATRIX Effects.
435 438
 * 
436
 * @param type one of the constants defined in {@link Effect}
439
 * @param type one of the constants defined in {@link EffectType}
437 440
 * @return Number of effects aborted.
438 441
 */
439
  public int abortByType(int type)
442
  public int abortByType(EffectType type)
440 443
    {
441 444
    switch(type)
442 445
      {
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;
446
      case MATRIX     : return mM.abortAll(true);
447
      case VERTEX     : return mV.abortAll(true);
448
      case FRAGMENT   : return mF.abortAll(true);
449
  //  case POSTPROCESS: return mP.abortAll(true);
450
      default         : return 0;
448 451
      }
449 452
    }
450 453
    
......
459 462
    {
460 463
    switch(effect.getType())
461 464
      {
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;
465
      case MATRIX     : return mM.removeEffect(effect);
466
      case VERTEX     : return mV.removeEffect(effect);
467
      case FRAGMENT   : return mF.removeEffect(effect);
468
  //  case POSTPROCESS: return mP.removeEffect(effect);
469
      default         : return 0;
467 470
      }
468 471
    }
469 472

  
......
471 474
/**
472 475
 * Abort all Effects of a given name, for example all rotations.
473 476
 * 
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}
477
 * @param name one of the constants defined in {@link EffectName}
479 478
 * @return number of Effects aborted.
480 479
 */
481
  public int abortByName(int name)
480
  public int abortByName(EffectName name)
482 481
    {
483
    switch(Effect.getType(name))
482
    switch(name.getType())
484 483
      {
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);
484
      case MATRIX     : return mM.removeByName(name);
485
      case VERTEX     : return mV.removeByName(name);
486
      case FRAGMENT   : return mF.removeByName(name);
487
  //  case POSTPROCESS: return mP.removeByName(name);
489 488
      default                : return 0;
490 489
      }
491 490
    }
......
498 497
 * This needs to be called BEFORE shaders get compiled, i.e. before the call to Distorted.onCreate().
499 498
 * The point: by enabling only the effects we need, we can optimize the shaders.
500 499
 *
501
 * @param name one of the constants defined in
502
 *             {@link org.distorted.library.effect.MatrixEffect},
503
 *             {@link org.distorted.library.effect.VertexEffect},
504
 *             {@link org.distorted.library.effect.FragmentEffect} or
505
 *             {@link org.distorted.library.effect.PostprocessEffect}
500
 * @param name one of the constants defined in {@link EffectName}
506 501
 */
507
  public static void enableEffect(int name)
502
  public static void enableEffect(EffectName name)
508 503
    {
509
    mEffectEnabled[name] = true;
504
    mEnabledEffects.add(name);
510 505
    }
511 506

  
512 507
///////////////////////////////////////////////////////////////////////////////////////////////////
......
518 513
  @SuppressWarnings("unused")
519 514
  public static int getMaxMatrix()
520 515
    {
521
    return EffectQueue.getMax(Effect.MATRIX);
516
    return EffectQueue.getMax(EffectType.MATRIX.ordinal());
522 517
    }
523 518

  
524 519
///////////////////////////////////////////////////////////////////////////////////////////////////
......
530 525
  @SuppressWarnings("unused")
531 526
  public static int getMaxVertex()
532 527
    {
533
    return EffectQueue.getMax(Effect.VERTEX);
528
    return EffectQueue.getMax(EffectType.VERTEX.ordinal());
534 529
    }
535 530

  
536 531
///////////////////////////////////////////////////////////////////////////////////////////////////
......
542 537
  @SuppressWarnings("unused")
543 538
  public static int getMaxFragment()
544 539
    {
545
    return EffectQueue.getMax(Effect.FRAGMENT);
540
    return EffectQueue.getMax(EffectType.FRAGMENT.ordinal());
546 541
    }
547 542

  
548 543
///////////////////////////////////////////////////////////////////////////////////////////////////
......
564 559
  @SuppressWarnings("unused")
565 560
  public static boolean setMaxMatrix(int max)
566 561
    {
567
    return EffectQueue.setMax(Effect.MATRIX,max);
562
    return EffectQueue.setMax(EffectType.MATRIX.ordinal(),max);
568 563
    }
569 564

  
570 565
///////////////////////////////////////////////////////////////////////////////////////////////////
......
586 581
  @SuppressWarnings("unused")
587 582
  public static boolean setMaxVertex(int max)
588 583
    {
589
    return EffectQueue.setMax(Effect.VERTEX,max);
584
    return EffectQueue.setMax(EffectType.VERTEX.ordinal(),max);
590 585
    }
591 586

  
592 587
///////////////////////////////////////////////////////////////////////////////////////////////////
......
608 603
  @SuppressWarnings("unused")
609 604
  public static boolean setMaxFragment(int max)
610 605
    {
611
    return EffectQueue.setMax(Effect.FRAGMENT,max);
606
    return EffectQueue.setMax(EffectType.FRAGMENT.ordinal(),max);
612 607
    }
613 608

  
614 609
///////////////////////////////////////////////////////////////////////////////////////////////////
......
621 616
    {
622 617
    switch(effect.getType())
623 618
      {
624
      case Effect.VERTEX      : mV.add(effect); break;
625
      case Effect.FRAGMENT    : mF.add(effect); break;
626
      case Effect.MATRIX      : mM.add(effect); break;
627
   // case Effect.POSTPROCESS : mP.add(effect); break;
619
      case VERTEX      : mV.add(effect); break;
620
      case FRAGMENT    : mF.add(effect); break;
621
      case MATRIX      : mM.add(effect); break;
622
   // case POSTPROCESS : mP.add(effect); break;
628 623
      }
629 624
    }
630 625
  }
src/main/java/org/distorted/library/main/DistortedEffectsPostprocess.java
20 20
package org.distorted.library.main;
21 21

  
22 22
import org.distorted.library.effect.Effect;
23
import org.distorted.library.effect.EffectType;
23 24
import org.distorted.library.message.EffectListener;
24 25

  
25 26
import java.util.ArrayList;
......
240 241
/**
241 242
 * Aborts all Effects of a given type, for example all POSTPROCESS Effects.
242 243
 *
243
 * @param type one of the constants defined in {@link Effect}
244
 * @param type one of the constants defined in {@link EffectType}
244 245
 * @return Number of effects aborted.
245 246
 */
246
  public int abortByType(int type)
247
  public int abortByType(EffectType type)
247 248
    {
248 249
    switch(type)
249 250
      {
250
      case Effect.POSTPROCESS: return mP.abortAll(true);
251
      default                : return 0;
251
      case POSTPROCESS: return mP.abortAll(true);
252
      default         : return 0;
252 253
      }
253 254
    }
254 255

  
......
263 264
    {
264 265
    switch(effect.getType())
265 266
      {
266
      case Effect.POSTPROCESS: return mP.removeEffect(effect);
267
      default                : return 0;
267
      case POSTPROCESS: return mP.removeEffect(effect);
268
      default         : return 0;
268 269
      }
269 270
    }
270 271

  
......
277 278
  @SuppressWarnings("unused")
278 279
  public static int getMaxPostprocess()
279 280
    {
280
    return EffectQueue.getMax(Effect.POSTPROCESS);
281
    return EffectQueue.getMax(EffectType.POSTPROCESS.ordinal());
281 282
    }
282 283

  
283 284
///////////////////////////////////////////////////////////////////////////////////////////////////
......
299 300
  @SuppressWarnings("unused")
300 301
  public static boolean setMaxPostprocess(int max)
301 302
    {
302
    return EffectQueue.setMax(Effect.POSTPROCESS,max);
303
    return EffectQueue.setMax(EffectType.POSTPROCESS.ordinal(),max);
303 304
    }
304 305

  
305 306
///////////////////////////////////////////////////////////////////////////////////////////////////
......
328 329
    {
329 330
    switch(effect.getType())
330 331
      {
331
      case Effect.POSTPROCESS : mP.add(effect); break;
332
      case POSTPROCESS : mP.add(effect); break;
332 333
      }
333 334
    }
334 335
  }
src/main/java/org/distorted/library/main/EffectQueue.java
20 20
package org.distorted.library.main;
21 21

  
22 22
import org.distorted.library.effect.Effect;
23
import org.distorted.library.effect.EffectName;
24
import org.distorted.library.effect.EffectType;
23 25
import org.distorted.library.message.EffectListener;
24 26
import org.distorted.library.message.EffectMessage;
25 27

  
......
35 37
  protected Effect[] mEffects;
36 38
  protected int[] mName;
37 39
  protected long mTime=0;
38
  protected static int[] mMax = new int[Effect.LENGTH];
40
  protected static int[] mMax = new int[EffectType.LENGTH];
39 41
  protected Vector<EffectListener> mListeners =null;
40 42
  protected int mNumListeners=0;  // ==mListeners.length(), but we only create mListeners if the first one gets added
41 43
  protected long mID;
......
132 134

  
133 135
  static void onDestroy()
134 136
    {
135
    Effect.reset(mMax);
137
    EffectType.reset(mMax);
136 138
    mCreated = false;  
137 139
    }
138 140

  
139 141
///////////////////////////////////////////////////////////////////////////////////////////////////
140 142

  
141
  synchronized int removeByName(int name)
143
  synchronized int removeByName(EffectName name)
142 144
    {
143 145
    int ret = 0;
144 146

  
......
231 233
      {
232 234
      mCurrentDuration[mNumEffects] = 0;
233 235
      mEffects[mNumEffects] = effect;
234
      mName[mNumEffects] = effect.getName();
236
      mName[mNumEffects] = effect.getName().ordinal();
235 237
      mNumEffects++;
236 238
      }
237 239
    }
src/main/java/org/distorted/library/main/EffectQueueFragment.java
21 21

  
22 22
import android.opengl.GLES30;
23 23

  
24
import org.distorted.library.effect.Effect;
24
import org.distorted.library.effect.EffectType;
25 25
import org.distorted.library.effect.FragmentEffect;
26 26
import org.distorted.library.message.EffectMessage;
27 27

  
......
30 30
class EffectQueueFragment extends EffectQueue
31 31
  {
32 32
  private static final int NUM_UNIFORMS = FragmentEffect.NUM_UNIFORMS;
33
  private static final int INDEX = Effect.FRAGMENT;
33
  private static final int INDEX = EffectType.FRAGMENT.ordinal();
34 34
  private static int mNumEffectsH;
35 35
  private static int mNameH;
36 36
  private static int mUniformsH;
......
68 68
        for(int j=0; j<mNumListeners; j++)
69 69
          EffectMessageSender.newMessage( mListeners.elementAt(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mID);
70 70

  
71
        if( FragmentEffect.isUnity( mEffects[i].getName(), mUniforms, NUM_UNIFORMS*i) )
71
        if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) )
72 72
          remove(i--);
73 73
        }
74 74
      }
src/main/java/org/distorted/library/main/EffectQueueMatrix.java
22 22
import android.opengl.GLES30;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff