Revision 1beb6f13
Added by Leszek Koltunski about 8 years ago
src/main/java/org/distorted/library/EffectNames.java | ||
---|---|---|
53 | 53 |
* <p> |
54 | 54 |
* Unity: angle==0 |
55 | 55 |
*/ |
56 |
ROTATE ( EffectTypes.MATRIX , new float[] {0.0f} ), |
|
56 |
ROTATE ( EffectTypes.MATRIX , new float[] {0.0f} , 1, false ),
|
|
57 | 57 |
/** |
58 | 58 |
* Rotate the whole Object around a center point (in quaternion notation). |
59 | 59 |
* <p> |
... | ... | |
61 | 61 |
* <p> |
62 | 62 |
* Unity: (quatX,quatY,quatZ) = (0,0,0) |
63 | 63 |
*/ |
64 |
QUATERNION ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} ), |
|
64 |
QUATERNION ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} , 4, false ),
|
|
65 | 65 |
/** |
66 | 66 |
* Move the whole Object by a vector. |
67 | 67 |
* <p> |
... | ... | |
69 | 69 |
* <p> |
70 | 70 |
* Unity: (vectorX,vectorY,vectorZ) = (0,0,0) |
71 | 71 |
*/ |
72 |
MOVE ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} ), |
|
72 |
MOVE ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} , 3, false ),
|
|
73 | 73 |
/** |
74 | 74 |
* Scale the whole Object independently in all 3 dimensions. |
75 | 75 |
* <p> |
... | ... | |
77 | 77 |
* <p> |
78 | 78 |
* Unity: (scaleX,scaleY,scaleZ) = (1,1,1) |
79 | 79 |
*/ |
80 |
SCALE ( EffectTypes.MATRIX , new float[] {1.0f,1.0f,1.0f} ), |
|
80 |
SCALE ( EffectTypes.MATRIX , new float[] {1.0f,1.0f,1.0f} , 3, false ),
|
|
81 | 81 |
/** |
82 | 82 |
* Shear the whole Object in 3 dimensions around a center point. |
83 | 83 |
* <p> |
... | ... | |
85 | 85 |
* <p> |
86 | 86 |
* Unity: (shearX,shearY,shearZ) = (0,0,0) |
87 | 87 |
*/ |
88 |
SHEAR ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} ), |
|
88 |
SHEAR ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} , 3, false ),
|
|
89 | 89 |
// add new Matrix effects here... |
90 | 90 |
|
91 | 91 |
///////////////////////////////////////////////////////////////////////////////// |
... | ... | |
101 | 101 |
* <p> |
102 | 102 |
* Unity: (forceX,forceY,forceZ) = (0,0,0) |
103 | 103 |
*/ |
104 |
DISTORT ( EffectTypes.VERTEX , new float[] {0.0f,0.0f,0.0f} ), |
|
104 |
DISTORT ( EffectTypes.VERTEX , new float[] {0.0f,0.0f,0.0f} , 3, true ),
|
|
105 | 105 |
/** |
106 | 106 |
* Deform the whole Object by applying a 2D vector of force to a center point. |
107 | 107 |
* <p> |
... | ... | |
111 | 111 |
* <p> |
112 | 112 |
* Unity: (forceX,forceY) = (0,0) |
113 | 113 |
*/ |
114 |
DEFORM ( EffectTypes.VERTEX , new float[] {0.0f,0.0f} ), |
|
114 |
DEFORM ( EffectTypes.VERTEX , new float[] {0.0f,0.0f} , 3, false ),
|
|
115 | 115 |
/** |
116 | 116 |
* Pull (or push away) all points around a center point to (from) it. |
117 | 117 |
* <p> |
... | ... | |
121 | 121 |
* <p> |
122 | 122 |
* Unity: sinkFactor = 1 |
123 | 123 |
*/ |
124 |
SINK ( EffectTypes.VERTEX , new float[] {1.0f} ), |
|
124 |
SINK ( EffectTypes.VERTEX , new float[] {1.0f} , 1, true ),
|
|
125 | 125 |
/** |
126 | 126 |
* Smoothly rotate a limited area around a center point. |
127 | 127 |
* <p> |
... | ... | |
131 | 131 |
* <p> |
132 | 132 |
* Unity: swirlAngle = 0 |
133 | 133 |
*/ |
134 |
SWIRL ( EffectTypes.VERTEX , new float[] {0.0f} ), |
|
134 |
SWIRL ( EffectTypes.VERTEX , new float[] {0.0f} , 1, true ),
|
|
135 | 135 |
/** |
136 | 136 |
* Directional sinusoidal wave effect. The direction of the wave is given by the 'angle' |
137 | 137 |
* parameters. Details: {@link DistortedObject#wave(Data5D,Data2D)} |
... | ... | |
142 | 142 |
* <p> |
143 | 143 |
* Unity: amplitude = 0 |
144 | 144 |
*/ |
145 |
WAVE ( EffectTypes.VERTEX , new float[] {0.0f} ), |
|
145 |
WAVE ( EffectTypes.VERTEX , new float[] {0.0f} , 5, true ),
|
|
146 | 146 |
// add new Vertex Effects here... |
147 | 147 |
|
148 | 148 |
///////////////////////////////////////////////////////////////////////////////// |
... | ... | |
155 | 155 |
* <p> |
156 | 156 |
* Unity: transparencyLevel = 1 |
157 | 157 |
*/ |
158 |
ALPHA ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
158 |
ALPHA ( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true ),
|
|
159 | 159 |
/** |
160 | 160 |
* Make a given Region (partially) transparent. |
161 | 161 |
* Effect smoothly fades towards the edges of the region. |
... | ... | |
163 | 163 |
* Uniforms: (transparencyLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
164 | 164 |
* Unity: transparencyLevel = 1 |
165 | 165 |
*/ |
166 |
SMOOTH_ALPHA ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
166 |
SMOOTH_ALPHA ( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true ),
|
|
167 | 167 |
/** |
168 | 168 |
* Blend current color in the texture with a given color. |
169 | 169 |
* <p> |
... | ... | |
171 | 171 |
* <p> |
172 | 172 |
* Unity: blendLevel = 0 |
173 | 173 |
*/ |
174 |
CHROMA ( EffectTypes.FRAGMENT, new float[] {0.0f} ), |
|
174 |
CHROMA ( EffectTypes.FRAGMENT, new float[] {0.0f} , 4, true ),
|
|
175 | 175 |
/** |
176 | 176 |
* Smoothly blend current color in the texture with a given color. |
177 | 177 |
* <p> |
178 | 178 |
* Uniforms: (blendLevel,colorR,colorG,colorB, regionX, regionY, regionRX, regionRY) |
179 | 179 |
* Unity: blendLevel = 0 |
180 | 180 |
*/ |
181 |
SMOOTH_CHROMA ( EffectTypes.FRAGMENT, new float[] {0.0f} ), |
|
181 |
SMOOTH_CHROMA ( EffectTypes.FRAGMENT, new float[] {0.0f} , 4, true ),
|
|
182 | 182 |
/** |
183 | 183 |
* Change brightness level of a given Region. |
184 | 184 |
* <p> |
... | ... | |
186 | 186 |
* <p> |
187 | 187 |
* Unity: brightnessLevel = 1 |
188 | 188 |
*/ |
189 |
BRIGHTNESS ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
189 |
BRIGHTNESS ( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true ),
|
|
190 | 190 |
/** |
191 | 191 |
* Smoothly change brightness level of a given Region. |
192 | 192 |
* <p> |
... | ... | |
194 | 194 |
* <p> |
195 | 195 |
* Unity: brightnessLevel = 1 |
196 | 196 |
*/ |
197 |
SMOOTH_BRIGHTNESS( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
197 |
SMOOTH_BRIGHTNESS( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true ),
|
|
198 | 198 |
/** |
199 | 199 |
* Change saturation level of a given Region. |
200 | 200 |
* <p> |
... | ... | |
202 | 202 |
* <p> |
203 | 203 |
* Unity: saturationLevel = 1 |
204 | 204 |
*/ |
205 |
SATURATION ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
205 |
SATURATION ( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true ),
|
|
206 | 206 |
/** |
207 | 207 |
* Smoothly change saturation level of a given Region. |
208 | 208 |
* <p> |
... | ... | |
210 | 210 |
* <p> |
211 | 211 |
* Unity: saturationLevel = 1 |
212 | 212 |
*/ |
213 |
SMOOTH_SATURATION( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
213 |
SMOOTH_SATURATION( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true ),
|
|
214 | 214 |
/** |
215 | 215 |
* Change contrast level of a given Region. |
216 | 216 |
* <p> |
... | ... | |
218 | 218 |
* <p> |
219 | 219 |
* Unity: contrastLevel = 1 |
220 | 220 |
*/ |
221 |
CONTRAST ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
221 |
CONTRAST ( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true ),
|
|
222 | 222 |
/** |
223 | 223 |
* Smoothly change contrast level of a given Region. |
224 | 224 |
* <p> |
... | ... | |
226 | 226 |
* <p> |
227 | 227 |
* Unity: contrastLevel = 1 |
228 | 228 |
*/ |
229 |
SMOOTH_CONTRAST ( EffectTypes.FRAGMENT, new float[] {1.0f} ); |
|
229 |
SMOOTH_CONTRAST ( EffectTypes.FRAGMENT, new float[] {1.0f} , 1, true );
|
|
230 | 230 |
// add new Fragment effects here... |
231 | 231 |
|
232 | 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
235 | 235 |
|
236 | 236 |
private final EffectTypes type; |
237 | 237 |
private final float[] unity; |
238 |
private final int dimension; |
|
239 |
private final boolean supportsRegion; |
|
238 | 240 |
|
239 | 241 |
private static final float[] unities; |
242 |
private static final int[] unityDimensions; |
|
240 | 243 |
private static final int[] dimensions; |
244 |
private static final boolean[] supports; |
|
241 | 245 |
private static final EffectNames[] names; |
242 | 246 |
|
243 | 247 |
static |
... | ... | |
245 | 249 |
int len = values().length; |
246 | 250 |
int i=0; |
247 | 251 |
|
248 |
dimensions = new int[len]; |
|
249 |
unities = new float[MAXDIM*len]; |
|
250 |
names = new EffectNames[len]; |
|
252 |
unityDimensions = new int[len]; |
|
253 |
dimensions = new int[len]; |
|
254 |
supports = new boolean[len]; |
|
255 |
unities = new float[MAXDIM*len]; |
|
256 |
names = new EffectNames[len]; |
|
251 | 257 |
|
252 | 258 |
for(EffectNames name: EffectNames.values()) |
253 | 259 |
{ |
254 |
dimensions[i] = (name.unity==null ? 0 : name.unity.length); |
|
255 |
names[i] = name; |
|
260 |
unityDimensions[i] = (name.unity==null ? 0 : name.unity.length); |
|
261 |
dimensions[i] = name.dimension; |
|
262 |
supports[i] = name.supportsRegion; |
|
263 |
names[i] = name; |
|
256 | 264 |
|
257 |
switch(dimensions[i])
|
|
265 |
switch(unityDimensions[i])
|
|
258 | 266 |
{ |
259 | 267 |
case 4: unities[MAXDIM*i+3] = name.unity[3]; |
260 | 268 |
case 3: unities[MAXDIM*i+2] = name.unity[2]; |
... | ... | |
269 | 277 |
|
270 | 278 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
271 | 279 |
|
272 |
EffectNames(EffectTypes type, float[] unity) |
|
280 |
EffectNames(EffectTypes type, float[] unity, int dimension, boolean supportsRegion)
|
|
273 | 281 |
{ |
274 |
this.type = type; |
|
275 |
this.unity= unity; |
|
282 |
this.type = type; |
|
283 |
this.unity = unity; |
|
284 |
this.dimension = dimension; |
|
285 |
this.supportsRegion = supportsRegion; |
|
276 | 286 |
} |
277 | 287 |
|
278 | 288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
293 | 303 |
|
294 | 304 |
static void fillWithUnities(int ordinal, float[] buffer, int index) |
295 | 305 |
{ |
296 |
switch(dimensions[ordinal])
|
|
306 |
switch(unityDimensions[ordinal])
|
|
297 | 307 |
{ |
298 | 308 |
case 0: break; |
299 | 309 |
case 1: buffer[index ]=unities[MAXDIM*ordinal ]; |
... | ... | |
317 | 327 |
|
318 | 328 |
static boolean isUnity(int ordinal, float[] buffer, int index) |
319 | 329 |
{ |
320 |
switch(dimensions[ordinal])
|
|
330 |
switch(unityDimensions[ordinal])
|
|
321 | 331 |
{ |
322 | 332 |
case 0: return true; |
323 | 333 |
case 1: return buffer[index ]==unities[MAXDIM*ordinal ]; |
... | ... | |
348 | 358 |
return type; |
349 | 359 |
} |
350 | 360 |
|
361 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
362 |
|
|
351 | 363 |
/** |
352 | 364 |
* Returns the dimension of an Effect (in other words, the number of interpolated values). |
353 | 365 |
* @return dimension of the Effect. |
354 | 366 |
*/ |
355 | 367 |
public int getDimension() { return dimensions[ordinal()]; } |
368 |
|
|
369 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
370 |
|
|
371 |
/** |
|
372 |
* Do we support being masked by a Region? |
|
373 |
* @return true if the Effect supports being masked with a Region. |
|
374 |
*/ |
|
375 |
public boolean supportsRegion() { return supports[ordinal()]; } |
|
376 |
|
|
356 | 377 |
} |
Also available in: Unified diff
Encode more info in the EfectNames enum.