Project

General

Profile

« Previous | Next » 

Revision b24e4719

Added by Leszek Koltunski over 5 years ago

Make the Fragment effects truly 3D: change their 4D 'region' into a 3D 'center' (a point in 3D) and 3D 'region' (which is now a set of 3 radii defining an ellipsoid around the center)

Also corresponding changes to the applications.

View differences:

src/main/java/org/distorted/library/effect/EffectName.java
43 43
public enum EffectName
44 44
  {
45 45
  // EFFECT NAME /////// EFFECT TYPE ////////// EFFECT UNITY //////////// DIM REGION CENTER // CLASS
46
  ROTATE           ( EffectType.MATRIX  ,   new float[] {0.0f}           , 4, false, true  , MatrixEffectRotate.class       ),
47
  QUATERNION       ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 4, false, true  , MatrixEffectQuaternion.class   ),
48
  MOVE             ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false, false , MatrixEffectMove.class         ),
49
  SCALE            ( EffectType.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} , 3, false, false , MatrixEffectScale.class        ),
50
  SHEAR            ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false, true  , MatrixEffectShear.class        ),
51

  
52
  DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, true , true  , VertexEffectDistort.class      ),
53
  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, true , true  , VertexEffectDeform.class       ),
54
  SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, true , true  , VertexEffectSink.class         ),
55
  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 2, true , true  , VertexEffectPinch.class        ),
56
  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, true , true  , VertexEffectSwirl.class        ),
57
  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, true , true  , VertexEffectWave.class         ),
58

  
59
  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectAlpha.class      ),
60
  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectAlpha.class      ),
61
  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, true , false , FragmentEffectChroma.class     ),
62
  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, true , false , FragmentEffectChroma.class     ),
63
  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectBrightness.class ),
64
  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectBrightness.class ),
65
  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectSaturation.class ),
66
  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectSaturation.class ),
67
  CONTRAST         ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectContrast.class   ),
68
  SMOOTH_CONTRAST  ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, true , false , FragmentEffectContrast.class   ),
69

  
70
  BLUR             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 1, false, false , PostprocessEffectBlur.class    ),
71
  GLOW             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 5, false, false , PostprocessEffectGlow.class    );
46
  ROTATE           ( EffectType.MATRIX  ,   new float[] {0.0f}           , 4, 0,     3    , MatrixEffectRotate.class       ),
47
  QUATERNION       ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 4, 0,     3    , MatrixEffectQuaternion.class   ),
48
  MOVE             ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 0,     0    , MatrixEffectMove.class         ),
49
  SCALE            ( EffectType.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} , 3, 0,     0    , MatrixEffectScale.class        ),
50
  SHEAR            ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 0,     3    , MatrixEffectShear.class        ),
51

  
52
  DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4 ,    3    , VertexEffectDistort.class      ),
53
  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4 ,    3    , VertexEffectDeform.class       ),
54
  SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, 4 ,    3    , VertexEffectSink.class         ),
55
  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 2, 4 ,    3    , VertexEffectPinch.class        ),
56
  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, 4 ,    3    , VertexEffectSwirl.class        ),
57
  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, 4 ,    3    , VertexEffectWave.class         ),
58

  
59
  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectAlpha.class      ),
60
  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectAlpha.class      ),
61
  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3 ,    3    , FragmentEffectChroma.class     ),
62
  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3 ,    3    , FragmentEffectChroma.class     ),
63
  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectBrightness.class ),
64
  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectBrightness.class ),
65
  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectSaturation.class ),
66
  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectSaturation.class ),
67
  CONTRAST         ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectContrast.class   ),
68
  SMOOTH_CONTRAST  ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectContrast.class   ),
69

  
70
  BLUR             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 1, 0,     0    , PostprocessEffectBlur.class    ),
71
  GLOW             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 5, 0,     0    , PostprocessEffectGlow.class    );
72 72

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

  
......
77 77
  private final EffectType type;
78 78
  private final float[] unity;
79 79
  private final int dimension;
80
  private final boolean supportsR;
81
  private final boolean supportsC;
80
  private final int regionDim;
81
  private final int centerDim;
82 82
  private final Class<? extends Effect> effectClass;
83 83

  
84 84
  private static final int[] dimensions;
85
  private static final boolean[] supportsRegion;
86
  private static final boolean[] supportsCenter;
85
  private static final int[] regionDimension;
86
  private static final int[] centerDimension;
87 87
  private static final EffectName[] names;  // copy the values() to a local variable so that we
88 88
                                            // don't have to keep recreating the array every time
89 89
  static
......
91 91
    int i=0;
92 92

  
93 93
    dimensions      = new int[LENGTH];
94
    supportsRegion  = new boolean[LENGTH];
95
    supportsCenter  = new boolean[LENGTH];
94
    regionDimension = new int[LENGTH];
95
    centerDimension = new int[LENGTH];
96 96
    names           = new EffectName[LENGTH];
97 97

  
98 98
    for(EffectName name: EffectName.values())
99 99
      {
100 100
      dimensions[i]      = name.dimension;
101
      supportsRegion[i]  = name.supportsR;
102
      supportsCenter[i]  = name.supportsC;
101
      regionDimension[i] = name.regionDim;
102
      centerDimension[i] = name.centerDim;
103 103
      names[i]           = name;
104 104

  
105 105
      i++;
......
115 115

  
116 116
///////////////////////////////////////////////////////////////////////////////////////////////////
117 117

  
118
  EffectName(EffectType type, float[] unity, int dimension, boolean supportsR,
119
             boolean supportsC, Class<? extends Effect> effectClass )
118
  EffectName(EffectType type, float[] unity, int dimension, int regionDim,
119
             int centerDim, Class<? extends Effect> effectClass )
120 120
    {
121 121
    this.type        = type;
122 122
    this.unity       = unity;
123 123
    this.dimension   = dimension;
124
    this.supportsR   = supportsR;
125
    this.supportsC   = supportsC;
124
    this.regionDim   = regionDim;
125
    this.centerDim   = centerDim;
126 126
    this.effectClass = effectClass;
127 127
    }
128 128

  
......
166 166
 * Returns the dimension of an Effect (in other words, the number of interpolated values).
167 167
 * @return dimension of the Effect.
168 168
 */
169
  public int getDimension() { return dimensions[ordinal()]; }
169
  public int getEffectDimension() { return dimensions[ordinal()]; }
170 170

  
171 171
///////////////////////////////////////////////////////////////////////////////////////////////////
172 172
/**
173
 * Do we support being masked by a Region?
174
 * @return true if the Effect supports being masked with a Region.
173
 * What is the dimension of the Region supported by this effect?
174
 * @return Dimension of the Region supported (0-region not supported at all).
175 175
 */
176
  public boolean supportsRegion() { return supportsRegion[ordinal()]; }
176
  public int getRegionDimension() { return regionDimension[ordinal()]; }
177 177

  
178 178
///////////////////////////////////////////////////////////////////////////////////////////////////
179 179
/**
180
 * Does this Effect have a center?
181
 * @return true if the Effect has a center.
180
 * What is the dimension of the Center supported by this effect?
181
 * @return Dimension of the Center supported (0-center not supported at all).
182 182
 */
183
  public boolean supportsCenter() { return supportsCenter[ordinal()]; }
183
  public int getCenterDimension() { return centerDimension[ordinal()]; }
184 184
  }
185 185

  

Also available in: Unified diff