Project

General

Profile

Download (35.2 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / DistortedEffects.java @ 26df012c

1 d333eb6b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 6a06a912 Leszek Koltunski
package org.distorted.library;
21
22
import android.opengl.GLES20;
23
24 e458a4ba Leszek Koltunski
import org.distorted.library.message.EffectListener;
25 568b29d8 Leszek Koltunski
import org.distorted.library.type.Data1D;
26 f2fe7e28 Leszek Koltunski
import org.distorted.library.type.Data2D;
27 568b29d8 Leszek Koltunski
import org.distorted.library.type.Data3D;
28
import org.distorted.library.type.Data4D;
29 350cc2f5 Leszek Koltunski
import org.distorted.library.type.Data5D;
30 568b29d8 Leszek Koltunski
import org.distorted.library.type.Static3D;
31 a4835695 Leszek Koltunski
32 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
33 b329f352 Leszek Koltunski
/**
34 4e2382f3 Leszek Koltunski
 * Class containing {@link EffectTypes#LENGTH} queues, each a class derived from EffectQueue.
35 b73dcaa7 Leszek Koltunski
 * <p>
36 26df012c Leszek Koltunski
 * The queues hold actual effects to be applied to a given (DistortedTexture,MeshObject) combo.
37 b329f352 Leszek Koltunski
 */
38 421c2728 Leszek Koltunski
public class DistortedEffects
39 d425545a Leszek Koltunski
  {
40 8e34674e Leszek Koltunski
  private static long mNextID =0;
41 4e2382f3 Leszek Koltunski
  private long mID;
42 8e34674e Leszek Koltunski
43 3d590d8d Leszek Koltunski
  private EffectQueueMatrix    mM;
44
  private EffectQueueFragment  mF;
45
  private EffectQueueVertex    mV;
46
47
  private boolean matrixCloned, vertexCloned, fragmentCloned;
48 985ea9c5 Leszek Koltunski
49 9361b337 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
50 6a06a912 Leszek Koltunski
    
51 421c2728 Leszek Koltunski
  private void initializeEffectLists(DistortedEffects d, int flags)
52 d425545a Leszek Koltunski
    {
53 015642fb Leszek Koltunski
    if( (flags & Distorted.CLONE_MATRIX) != 0 )
54 6a06a912 Leszek Koltunski
      {
55 d425545a Leszek Koltunski
      mM = d.mM;
56
      matrixCloned = true;
57
      }
58
    else
59
      {
60 4e2382f3 Leszek Koltunski
      mM = new EffectQueueMatrix(mID);
61 d425545a Leszek Koltunski
      matrixCloned = false;
62
      }
63 6a06a912 Leszek Koltunski
    
64 d425545a Leszek Koltunski
    if( (flags & Distorted.CLONE_VERTEX) != 0 )
65
      {
66
      mV = d.mV;
67
      vertexCloned = true;
68
      }
69
    else
70
      {
71 4e2382f3 Leszek Koltunski
      mV = new EffectQueueVertex(mID);
72 d425545a Leszek Koltunski
      vertexCloned = false;
73
      }
74 6a06a912 Leszek Koltunski
    
75 d425545a Leszek Koltunski
    if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
76
      {
77
      mF = d.mF;
78
      fragmentCloned = true;
79 6a06a912 Leszek Koltunski
      }
80 d425545a Leszek Koltunski
    else
81
      {
82 4e2382f3 Leszek Koltunski
      mF = new EffectQueueFragment(mID);
83 d425545a Leszek Koltunski
      fragmentCloned = false;
84
      }
85
    }
86 6a06a912 Leszek Koltunski
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88
   
89 26df012c Leszek Koltunski
  void drawPriv(float halfInputW, float halfInputH, MeshObject grid, DistortedFramebuffer df, long currTime)
90 d425545a Leszek Koltunski
    {
91 ed13a5de Leszek Koltunski
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
92 0a046359 Leszek Koltunski
93 52358355 Leszek Koltunski
    float halfZ = halfInputW*grid.zFactor;
94 3ef3364d Leszek Koltunski
95 d425545a Leszek Koltunski
    mM.compute(currTime);
96 52358355 Leszek Koltunski
    mM.send(df,halfInputW,halfInputH,halfZ);
97 6a06a912 Leszek Koltunski
      
98 d425545a Leszek Koltunski
    mV.compute(currTime);
99 52358355 Leszek Koltunski
    mV.send(halfInputW,halfInputH,halfZ);
100 6a06a912 Leszek Koltunski
        
101 d425545a Leszek Koltunski
    mF.compute(currTime);
102 52358355 Leszek Koltunski
    mF.send(halfInputW,halfInputH);
103 a56bc359 Leszek Koltunski
104
    grid.draw();
105 d425545a Leszek Koltunski
    }
106 6a06a912 Leszek Koltunski
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108
   
109 26df012c Leszek Koltunski
  void drawNoEffectsPriv(float halfInputW, float halfInputH, MeshObject grid, DistortedFramebuffer df)
110 d425545a Leszek Koltunski
    {
111 ed13a5de Leszek Koltunski
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
112 0a046359 Leszek Koltunski
113 52358355 Leszek Koltunski
    mM.sendZero(df,halfInputW,halfInputH,halfInputW*grid.zFactor);
114 d425545a Leszek Koltunski
    mV.sendZero();
115
    mF.sendZero();
116 a56bc359 Leszek Koltunski
117
    grid.draw();
118 d425545a Leszek Koltunski
    }
119 6a06a912 Leszek Koltunski
    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
   
122 8e34674e Leszek Koltunski
  private void releasePriv()
123 d425545a Leszek Koltunski
    {
124 8e34674e Leszek Koltunski
    if( !matrixCloned  ) mM.abortAll(false);
125
    if( !vertexCloned  ) mV.abortAll(false);
126
    if( !fragmentCloned) mF.abortAll(false);
127 d425545a Leszek Koltunski
128 4e2382f3 Leszek Koltunski
    mM = null;
129
    mV = null;
130
    mF = null;
131 8e34674e Leszek Koltunski
    }
132
133 1942537e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
134
135 7b8086eb Leszek Koltunski
  static void onDestroy()
136 1942537e Leszek Koltunski
    {
137
    mNextID = 0;
138
    }
139
140 8e34674e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
141
// PUBLIC API
142 ada90d33 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
143 d425545a Leszek Koltunski
/**
144 4e2382f3 Leszek Koltunski
 * Create empty effect queue.
145 d425545a Leszek Koltunski
 */
146 421c2728 Leszek Koltunski
  public DistortedEffects()
147 d425545a Leszek Koltunski
    {
148 4e2382f3 Leszek Koltunski
    mID = mNextID++;
149
    initializeEffectLists(this,0);
150 d425545a Leszek Koltunski
    }
151 ada90d33 Leszek Koltunski
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153 d425545a Leszek Koltunski
/**
154 4e2382f3 Leszek Koltunski
 * Copy constructor.
155 d425545a Leszek Koltunski
 * <p>
156
 * Whatever we do not clone gets created just like in the default constructor.
157
 *
158
 * @param dc    Source object to create our object from
159
 * @param flags A bitmask of values specifying what to copy.
160 e6ab30eb Leszek Koltunski
 *              For example, CLONE_VERTEX | CLONE_MATRIX.
161 d425545a Leszek Koltunski
 */
162 421c2728 Leszek Koltunski
  public DistortedEffects(DistortedEffects dc, int flags)
163 d425545a Leszek Koltunski
    {
164 8e34674e Leszek Koltunski
    mID = mNextID++;
165 4e2382f3 Leszek Koltunski
    initializeEffectLists(dc,flags);
166 d425545a Leszek Koltunski
    }
167 ada90d33 Leszek Koltunski
168 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
169
/**
170 07305c87 Leszek Koltunski
 * Releases all resources. After this call, the queue should not be used anymore.
171 6a06a912 Leszek Koltunski
 */
172 8e34674e Leszek Koltunski
  public synchronized void delete()
173 d425545a Leszek Koltunski
    {
174
    releasePriv();
175
    }
176 6a06a912 Leszek Koltunski
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178
/**
179 4e2382f3 Leszek Koltunski
 * Returns unique ID of this instance.
180
 *
181
 * @return ID of the object.
182 6a06a912 Leszek Koltunski
 */
183 4e2382f3 Leszek Koltunski
  public long getID()
184 d425545a Leszek Koltunski
      {
185 4e2382f3 Leszek Koltunski
      return mID;
186 d425545a Leszek Koltunski
      }
187 4e2382f3 Leszek Koltunski
188 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
189
/**
190
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
191 07305c87 Leszek Koltunski
 * to one of the Effects in those queues. Nothing will happen if 'el' is already in the list.
192 6a06a912 Leszek Koltunski
 * 
193
 * @param el A class implementing the EffectListener interface that wants to get notifications.
194
 */
195 3fc994b2 Leszek Koltunski
  public void registerForMessages(EffectListener el)
196 d425545a Leszek Koltunski
    {
197 3fc994b2 Leszek Koltunski
    mV.registerForMessages(el);
198
    mF.registerForMessages(el);
199
    mM.registerForMessages(el);
200 d425545a Leszek Koltunski
    }
201 6a06a912 Leszek Koltunski
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203
/**
204
 * Removes the calling class from the list of Listeners.
205
 * 
206
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
207
 */
208 3fc994b2 Leszek Koltunski
  public void deregisterForMessages(EffectListener el)
209 d425545a Leszek Koltunski
    {
210 3fc994b2 Leszek Koltunski
    mV.deregisterForMessages(el);
211
    mF.deregisterForMessages(el);
212
    mM.deregisterForMessages(el);
213 d425545a Leszek Koltunski
    }
214 6a06a912 Leszek Koltunski
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216
/**
217 d07f2950 Leszek Koltunski
 * Aborts all Effects.
218
 * @return Number of effects aborted.
219 6a06a912 Leszek Koltunski
 */
220 d425545a Leszek Koltunski
  public int abortAllEffects()
221 6a06a912 Leszek Koltunski
      {
222 0df17fad Leszek Koltunski
      return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true);
223 6a06a912 Leszek Koltunski
      }
224
225
///////////////////////////////////////////////////////////////////////////////////////////////////
226
/**
227 d07f2950 Leszek Koltunski
 * Aborts all Effects of a given type, for example all MATRIX Effects.
228 6a06a912 Leszek Koltunski
 * 
229 d07f2950 Leszek Koltunski
 * @param type one of the constants defined in {@link EffectTypes}
230
 * @return Number of effects aborted.
231 6a06a912 Leszek Koltunski
 */
232 d425545a Leszek Koltunski
  public int abortEffects(EffectTypes type)
233
    {
234
    switch(type)
235 6a06a912 Leszek Koltunski
      {
236 0df17fad Leszek Koltunski
      case MATRIX  : return mM.abortAll(true);
237
      case VERTEX  : return mV.abortAll(true);
238
      case FRAGMENT: return mF.abortAll(true);
239 d425545a Leszek Koltunski
      default      : return 0;
240 6a06a912 Leszek Koltunski
      }
241 d425545a Leszek Koltunski
    }
242 6a06a912 Leszek Koltunski
    
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244
/**
245
 * Aborts a single Effect.
246
 * 
247
 * @param id ID of the Effect we want to abort.
248 476bbc81 Leszek Koltunski
 * @return number of Effects aborted. Always either 0 or 1.
249 6a06a912 Leszek Koltunski
 */
250 d425545a Leszek Koltunski
  public int abortEffect(long id)
251
    {
252
    int type = (int)(id&EffectTypes.MASK);
253 1e438fc7 Leszek Koltunski
254 d425545a Leszek Koltunski
    if( type==EffectTypes.MATRIX.type   ) return mM.removeByID(id>>EffectTypes.LENGTH);
255
    if( type==EffectTypes.VERTEX.type   ) return mV.removeByID(id>>EffectTypes.LENGTH);
256
    if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
257 1e438fc7 Leszek Koltunski
258 d425545a Leszek Koltunski
    return 0;
259
    }
260 6a06a912 Leszek Koltunski
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262
/**
263 e8c81a8e Leszek Koltunski
 * Abort all Effects of a given name, for example all rotations.
264 6a06a912 Leszek Koltunski
 * 
265 d07f2950 Leszek Koltunski
 * @param name one of the constants defined in {@link EffectNames}
266 476bbc81 Leszek Koltunski
 * @return number of Effects aborted.
267 6a06a912 Leszek Koltunski
 */
268 d425545a Leszek Koltunski
  public int abortEffects(EffectNames name)
269
    {
270
    switch(name.getType())
271 6a06a912 Leszek Koltunski
      {
272 d425545a Leszek Koltunski
      case MATRIX  : return mM.removeByType(name);
273
      case VERTEX  : return mV.removeByType(name);
274
      case FRAGMENT: return mF.removeByType(name);
275
      default      : return 0;
276 6a06a912 Leszek Koltunski
      }
277 d425545a Leszek Koltunski
    }
278 6a06a912 Leszek Koltunski
    
279
///////////////////////////////////////////////////////////////////////////////////////////////////
280
/**
281
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
282
 * 
283
 * @param id Effect ID we want to print info about
284
 * @return <code>true</code> if a single Effect of type effectType has been found.
285
 */
286
    
287 d425545a Leszek Koltunski
  public boolean printEffect(long id)
288
    {
289
    int type = (int)(id&EffectTypes.MASK);
290 1e438fc7 Leszek Koltunski
291 d425545a Leszek Koltunski
    if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
292
    if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
293
    if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
294 1e438fc7 Leszek Koltunski
295 d425545a Leszek Koltunski
    return false;
296
    }
297 432442f9 Leszek Koltunski
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299
/**
300
 * Returns the maximum number of Matrix effects.
301
 *
302
 * @return The maximum number of Matrix effects
303
 */
304
  public static int getMaxMatrix()
305
    {
306
    return EffectQueue.getMax(EffectTypes.MATRIX.ordinal());
307
    }
308
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310
/**
311
 * Returns the maximum number of Vertex effects.
312
 *
313
 * @return The maximum number of Vertex effects
314
 */
315
  public static int getMaxVertex()
316
    {
317
    return EffectQueue.getMax(EffectTypes.VERTEX.ordinal());
318
    }
319
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321
/**
322
 * Returns the maximum number of Fragment effects.
323
 *
324
 * @return The maximum number of Fragment effects
325
 */
326
  public static int getMaxFragment()
327
    {
328
    return EffectQueue.getMax(EffectTypes.FRAGMENT.ordinal());
329
    }
330
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332
/**
333
 * Returns the maximum number of Postprocess effects.
334
 *
335
 * @return The maximum number of Postprocess effects
336
 */
337
  public static int getMaxPostprocess()
338
    {
339
    return EffectQueue.getMax(EffectTypes.POSTPROCESS.ordinal());
340
    }
341
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343
/**
344
 * Sets the maximum number of Matrix effects that can be stored in a single EffectQueue at one time.
345
 * This can fail if:
346
 * <ul>
347
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
348
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
349
 *     before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
350
 *     time only decreasing the value of 'max' is permitted.
351
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
352
 * </ul>
353
 *
354
 * @param max new maximum number of simultaneous Matrix Effects. Has to be a non-negative number not greater
355
 *            than Byte.MAX_VALUE
356
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
357
 */
358
  public static boolean setMaxMatrix(int max)
359
    {
360
    return EffectQueue.setMax(EffectTypes.MATRIX.ordinal(),max);
361
    }
362
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364
/**
365
 * Sets the maximum number of Vertex effects that can be stored in a single EffectQueue at one time.
366
 * This can fail if:
367
 * <ul>
368
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
369
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
370
 *     before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
371
 *     time only decreasing the value of 'max' is permitted.
372
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
373
 * </ul>
374
 *
375
 * @param max new maximum number of simultaneous Vertex Effects. Has to be a non-negative number not greater
376
 *            than Byte.MAX_VALUE
377
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
378
 */
379
  public static boolean setMaxVertex(int max)
380
    {
381
    return EffectQueue.setMax(EffectTypes.VERTEX.ordinal(),max);
382
    }
383
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385
/**
386
 * Sets the maximum number of Fragment effects that can be stored in a single EffectQueue at one time.
387
 * This can fail if:
388
 * <ul>
389
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
390
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
391
 *     before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
392
 *     time only decreasing the value of 'max' is permitted.
393
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
394
 * </ul>
395
 *
396
 * @param max new maximum number of simultaneous Fragment Effects. Has to be a non-negative number not greater
397
 *            than Byte.MAX_VALUE
398
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
399
 */
400
  public static boolean setMaxFragment(int max)
401
    {
402
    return EffectQueue.setMax(EffectTypes.FRAGMENT.ordinal(),max);
403
    }
404
405
///////////////////////////////////////////////////////////////////////////////////////////////////
406
/**
407
 * Sets the maximum number of Postprocess effects that can be stored in a single EffectQueue at one time.
408
 * This can fail if:
409
 * <ul>
410
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
411
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
412
 *     before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
413
 *     time only decreasing the value of 'max' is permitted.
414
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
415
 * </ul>
416
 *
417
 * @param max new maximum number of simultaneous Postprocess Effects. Has to be a non-negative number not greater
418
 *            than Byte.MAX_VALUE
419
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
420
 */
421
  public static boolean setMaxPostprocess(int max)
422
    {
423
    return EffectQueue.setMax(EffectTypes.POSTPROCESS.ordinal(),max);
424
    }
425
426 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////   
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428
// Individual effect functions.
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430
// Matrix-based effects
431
///////////////////////////////////////////////////////////////////////////////////////////////////
432
/**
433 e8c81a8e Leszek Koltunski
 * Moves the Object by a (possibly changing in time) vector.
434 6a06a912 Leszek Koltunski
 * 
435 568b29d8 Leszek Koltunski
 * @param vector 3-dimensional Data which at any given time will return a Static3D
436 e0a16874 Leszek Koltunski
 *               representing the current coordinates of the vector we want to move the Object with.
437
 * @return       ID of the effect added, or -1 if we failed to add one.
438 6a06a912 Leszek Koltunski
 */
439 568b29d8 Leszek Koltunski
  public long move(Data3D vector)
440 6a06a912 Leszek Koltunski
    {   
441 e0a16874 Leszek Koltunski
    return mM.add(EffectNames.MOVE,vector);
442 6a06a912 Leszek Koltunski
    }
443
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445
/**
446 e8c81a8e Leszek Koltunski
 * Scales the Object by (possibly changing in time) 3D scale factors.
447 6a06a912 Leszek Koltunski
 * 
448 d1e740c5 Leszek Koltunski
 * @param scale 3-dimensional Data which at any given time returns a Static3D
449 e0a16874 Leszek Koltunski
 *              representing the current x- , y- and z- scale factors.
450
 * @return      ID of the effect added, or -1 if we failed to add one.
451 6a06a912 Leszek Koltunski
 */
452 568b29d8 Leszek Koltunski
  public long scale(Data3D scale)
453 6a06a912 Leszek Koltunski
    {   
454 e0a16874 Leszek Koltunski
    return mM.add(EffectNames.SCALE,scale);
455 6a06a912 Leszek Koltunski
    }
456
457 2fce34f4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
458
/**
459 e8c81a8e Leszek Koltunski
 * Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
460 2fce34f4 Leszek Koltunski
 *
461
 * @param scale The factor to scale all 3 dimensions with.
462
 * @return      ID of the effect added, or -1 if we failed to add one.
463
 */
464 d425545a Leszek Koltunski
  public long scale(float scale)
465
    {
466
    return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
467
    }
468 2fce34f4 Leszek Koltunski
469 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
470
/**
471 568b29d8 Leszek Koltunski
 * Rotates the Object by 'angle' degrees around the center.
472
 * Static axis of rotation is given by the last parameter.
473
 *
474 9351ad55 Leszek Koltunski
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
475 568b29d8 Leszek Koltunski
 * @param axis   Axis of rotation
476 0df17fad Leszek Koltunski
 * @param center Coordinates of the Point we are rotating around.
477 e0a16874 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
478
 */
479 0df17fad Leszek Koltunski
  public long rotate(Data1D angle, Static3D axis, Data3D center )
480 6a06a912 Leszek Koltunski
    {   
481 0df17fad Leszek Koltunski
    return mM.add(EffectNames.ROTATE, angle, axis, center);
482 6a06a912 Leszek Koltunski
    }
483
484
///////////////////////////////////////////////////////////////////////////////////////////////////
485
/**
486 568b29d8 Leszek Koltunski
 * Rotates the Object by 'angle' degrees around the center.
487 2fce34f4 Leszek Koltunski
 * Here both angle and axis can dynamically change.
488 568b29d8 Leszek Koltunski
 *
489
 * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
490 0df17fad Leszek Koltunski
 * @param center    Coordinates of the Point we are rotating around.
491 568b29d8 Leszek Koltunski
 * @return          ID of the effect added, or -1 if we failed to add one.
492 e0a16874 Leszek Koltunski
 */
493 0df17fad Leszek Koltunski
  public long rotate(Data4D angleaxis, Data3D center)
494 568b29d8 Leszek Koltunski
    {
495 0df17fad Leszek Koltunski
    return mM.add(EffectNames.ROTATE, angleaxis, center);
496 6a06a912 Leszek Koltunski
    }
497
498
///////////////////////////////////////////////////////////////////////////////////////////////////
499
/**
500 568b29d8 Leszek Koltunski
 * Rotates the Object by quaternion.
501 0df17fad Leszek Koltunski
 *
502 568b29d8 Leszek Koltunski
 * @param quaternion The quaternion describing the rotation.
503 0df17fad Leszek Koltunski
 * @param center     Coordinates of the Point we are rotating around.
504 568b29d8 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
505 6a06a912 Leszek Koltunski
 */
506 0df17fad Leszek Koltunski
  public long quaternion(Data4D quaternion, Data3D center )
507 568b29d8 Leszek Koltunski
    {
508 0df17fad Leszek Koltunski
    return mM.add(EffectNames.QUATERNION,quaternion,center);
509 6a06a912 Leszek Koltunski
    }
510
511
///////////////////////////////////////////////////////////////////////////////////////////////////
512
/**
513 568b29d8 Leszek Koltunski
 * Shears the Object.
514 6a06a912 Leszek Koltunski
 *
515 8c3cdec5 Leszek Koltunski
 * @param shear   The 3-tuple of shear factors. The first controls level
516
 *                of shearing in the X-axis, second - Y-axis and the third -
517
 *                Z-axis. Each is the tangens of the shear angle, i.e 0 -
518
 *                no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
519 0df17fad Leszek Koltunski
 * @param center  Center of shearing, i.e. the point which stays unmoved.
520 e0a16874 Leszek Koltunski
 * @return        ID of the effect added, or -1 if we failed to add one.
521 6a06a912 Leszek Koltunski
 */
522 0df17fad Leszek Koltunski
  public long shear(Data3D shear, Data3D center)
523 6a06a912 Leszek Koltunski
    {
524 0df17fad Leszek Koltunski
    return mM.add(EffectNames.SHEAR, shear, center);
525 6a06a912 Leszek Koltunski
    }
526
527
///////////////////////////////////////////////////////////////////////////////////////////////////
528
// Fragment-based effects  
529
///////////////////////////////////////////////////////////////////////////////////////////////////
530
/**
531 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
532 6a06a912 Leszek Koltunski
 *        
533 2fce34f4 Leszek Koltunski
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
534 e4878781 Leszek Koltunski
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
535
 *               Valid range: <0,1>
536 b1e91f2c Leszek Koltunski
 * @param color  Color to mix. (1,0,0) is RED.
537 2fce34f4 Leszek Koltunski
 * @param region Region this Effect is limited to.
538
 * @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
539
 * @return       ID of the effect added, or -1 if we failed to add one.
540 6a06a912 Leszek Koltunski
 */
541 8c893ffc Leszek Koltunski
  public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
542 6a06a912 Leszek Koltunski
    {
543 2fce34f4 Leszek Koltunski
    return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
544 6a06a912 Leszek Koltunski
    }
545
546
///////////////////////////////////////////////////////////////////////////////////////////////////
547
/**
548 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change all three of its RGB components.
549
 *
550
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
551 e4878781 Leszek Koltunski
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
552
 *               Valid range: <0,1>
553 b1e91f2c Leszek Koltunski
 * @param color  Color to mix. (1,0,0) is RED.
554 2fce34f4 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
555 6a06a912 Leszek Koltunski
 */
556 8c893ffc Leszek Koltunski
  public long chroma(Data1D blend, Data3D color)
557 6a06a912 Leszek Koltunski
    {
558 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.CHROMA, blend, color);
559 6a06a912 Leszek Koltunski
    }
560
561
///////////////////////////////////////////////////////////////////////////////////////////////////
562
/**
563 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its transparency level.
564 6a06a912 Leszek Koltunski
 *        
565 2fce34f4 Leszek Koltunski
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any given
566 e4878781 Leszek Koltunski
 *               moment: pixel.a *= alpha.
567
 *               Valid range: <0,1>
568 d7bbef2f Leszek Koltunski
 * @param region Region this Effect is limited to. 
569 2fce34f4 Leszek Koltunski
 * @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
570 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
571 6a06a912 Leszek Koltunski
 */
572 2fce34f4 Leszek Koltunski
  public long alpha(Data1D alpha, Data4D region, boolean smooth)
573 6a06a912 Leszek Koltunski
    {
574 2fce34f4 Leszek Koltunski
    return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
575 6a06a912 Leszek Koltunski
    }
576
577
///////////////////////////////////////////////////////////////////////////////////////////////////
578
/**
579 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its transparency level.
580
 *
581
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any
582 e4878781 Leszek Koltunski
 *               given moment: pixel.a *= alpha.
583
 *               Valid range: <0,1>
584 2fce34f4 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
585 6a06a912 Leszek Koltunski
 */
586 2fce34f4 Leszek Koltunski
  public long alpha(Data1D alpha)
587 6a06a912 Leszek Koltunski
    {
588 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.ALPHA, alpha);
589 6a06a912 Leszek Koltunski
    }
590
591
///////////////////////////////////////////////////////////////////////////////////////////////////
592
/**
593 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its brightness level.
594 6a06a912 Leszek Koltunski
 *        
595 2fce34f4 Leszek Koltunski
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
596 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
597 e0a16874 Leszek Koltunski
 * @param region     Region this Effect is limited to.
598 2fce34f4 Leszek Koltunski
 * @param smooth     If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
599 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
600 6a06a912 Leszek Koltunski
 */
601 2fce34f4 Leszek Koltunski
  public long brightness(Data1D brightness, Data4D region, boolean smooth)
602 6a06a912 Leszek Koltunski
    {
603 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
604 6a06a912 Leszek Koltunski
    }
605
606
///////////////////////////////////////////////////////////////////////////////////////////////////
607
/**
608 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its brightness level.
609
 *
610
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
611 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
612 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
613 6a06a912 Leszek Koltunski
 */
614 2fce34f4 Leszek Koltunski
  public long brightness(Data1D brightness)
615 6a06a912 Leszek Koltunski
    {
616 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.BRIGHTNESS, brightness);
617 6a06a912 Leszek Koltunski
    }
618
619
///////////////////////////////////////////////////////////////////////////////////////////////////
620
/**
621 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its contrast level.
622 6a06a912 Leszek Koltunski
 *        
623 2fce34f4 Leszek Koltunski
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
624 e4878781 Leszek Koltunski
 *                 at any given moment. Valid range: <0,infinity)
625 e0a16874 Leszek Koltunski
 * @param region   Region this Effect is limited to.
626 2fce34f4 Leszek Koltunski
 * @param smooth   If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
627 e0a16874 Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one.
628 6a06a912 Leszek Koltunski
 */
629 2fce34f4 Leszek Koltunski
  public long contrast(Data1D contrast, Data4D region, boolean smooth)
630 6a06a912 Leszek Koltunski
    {
631 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
632 6a06a912 Leszek Koltunski
    }
633
634
///////////////////////////////////////////////////////////////////////////////////////////////////
635
/**
636 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its contrast level.
637
 *
638
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
639 e4878781 Leszek Koltunski
 *                 at any given moment. Valid range: <0,infinity)
640 e0a16874 Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one.
641 6a06a912 Leszek Koltunski
 */
642 2fce34f4 Leszek Koltunski
  public long contrast(Data1D contrast)
643 6a06a912 Leszek Koltunski
    {
644 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.CONTRAST, contrast);
645 6a06a912 Leszek Koltunski
    }
646
647
///////////////////////////////////////////////////////////////////////////////////////////////////
648
/**
649 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its saturation level.
650 6a06a912 Leszek Koltunski
 *        
651 2fce34f4 Leszek Koltunski
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
652 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
653 e0a16874 Leszek Koltunski
 * @param region     Region this Effect is limited to.
654 2fce34f4 Leszek Koltunski
 * @param smooth     If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
655 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
656 6a06a912 Leszek Koltunski
 */
657 2fce34f4 Leszek Koltunski
  public long saturation(Data1D saturation, Data4D region, boolean smooth)
658 6a06a912 Leszek Koltunski
    {
659 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
660 6a06a912 Leszek Koltunski
    }
661
662
///////////////////////////////////////////////////////////////////////////////////////////////////
663
/**
664 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its saturation level.
665
 *
666
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
667 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
668 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
669 6a06a912 Leszek Koltunski
 */
670 2fce34f4 Leszek Koltunski
  public long saturation(Data1D saturation)
671 6a06a912 Leszek Koltunski
    {
672 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.SATURATION, saturation);
673 6a06a912 Leszek Koltunski
    }
674
675
///////////////////////////////////////////////////////////////////////////////////////////////////
676
// Vertex-based effects  
677
///////////////////////////////////////////////////////////////////////////////////////////////////
678
/**
679 e0a16874 Leszek Koltunski
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
680 f2fe7e28 Leszek Koltunski
 *
681
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
682
 *               currently being dragged with.
683 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
684 f2fe7e28 Leszek Koltunski
 * @param region Region that masks the Effect.
685
 * @return       ID of the effect added, or -1 if we failed to add one.
686 6a06a912 Leszek Koltunski
 */
687 fa6c352d Leszek Koltunski
  public long distort(Data3D vector, Data3D center, Data4D region)
688 6a06a912 Leszek Koltunski
    {  
689 f2fe7e28 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, vector, center, region);
690 6a06a912 Leszek Koltunski
    }
691
692
///////////////////////////////////////////////////////////////////////////////////////////////////
693
/**
694 e0a16874 Leszek Koltunski
 * Distort the whole Object by a (possibly changing in time) vector of force.
695 f2fe7e28 Leszek Koltunski
 *
696
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
697
 *               currently being dragged with.
698 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
699 e0a16874 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
700 6a06a912 Leszek Koltunski
 */
701 fa6c352d Leszek Koltunski
  public long distort(Data3D vector, Data3D center)
702 d425545a Leszek Koltunski
    {
703 02ef26bc Leszek Koltunski
    return mV.add(EffectNames.DISTORT, vector, center, null);
704 d425545a Leszek Koltunski
    }
705 6a06a912 Leszek Koltunski
706 6ebdbbf1 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
707
/**
708
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
709
 * a (possibly changing in time) point on the Object.
710
 *
711
 * @param vector Vector of force that deforms the shape of the whole Object.
712
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
713
 * @param region Region that masks the Effect.
714
 * @return       ID of the effect added, or -1 if we failed to add one.
715
 */
716
  public long deform(Data3D vector, Data3D center, Data4D region)
717
    {
718
    return mV.add(EffectNames.DEFORM, vector, center, region);
719
    }
720
721 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
722
/**
723 e0a16874 Leszek Koltunski
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
724 9351ad55 Leszek Koltunski
 * a (possibly changing in time) point on the Object.
725 6a06a912 Leszek Koltunski
 *     
726 f2fe7e28 Leszek Koltunski
 * @param vector Vector of force that deforms the shape of the whole Object.
727 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
728 e0a16874 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
729 6a06a912 Leszek Koltunski
 */
730 fa6c352d Leszek Koltunski
  public long deform(Data3D vector, Data3D center)
731 6a06a912 Leszek Koltunski
    {  
732 02ef26bc Leszek Koltunski
    return mV.add(EffectNames.DEFORM, vector, center, null);
733 6a06a912 Leszek Koltunski
    }
734
735
///////////////////////////////////////////////////////////////////////////////////////////////////  
736
/**
737 f2fe7e28 Leszek Koltunski
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
738 6a06a912 Leszek Koltunski
 * away from the center (degree<=1)
739 f2fe7e28 Leszek Koltunski
 *
740
 * @param sink   The current degree of the Effect.
741 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
742 f2fe7e28 Leszek Koltunski
 * @param region Region that masks the Effect.
743
 * @return       ID of the effect added, or -1 if we failed to add one.
744 6a06a912 Leszek Koltunski
 */
745 fa6c352d Leszek Koltunski
  public long sink(Data1D sink, Data3D center, Data4D region)
746 6a06a912 Leszek Koltunski
    {
747 f2fe7e28 Leszek Koltunski
    return mV.add(EffectNames.SINK, sink, center, region);
748 6a06a912 Leszek Koltunski
    }
749
750
///////////////////////////////////////////////////////////////////////////////////////////////////
751
/**
752 f2fe7e28 Leszek Koltunski
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
753
 * away from the center (degree<=1)
754
 *
755
 * @param sink   The current degree of the Effect.
756 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
757 f2fe7e28 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
758 6a06a912 Leszek Koltunski
 */
759 fa6c352d Leszek Koltunski
  public long sink(Data1D sink, Data3D center)
760 d425545a Leszek Koltunski
    {
761
    return mV.add(EffectNames.SINK, sink, center);
762
    }
763 6a06a912 Leszek Koltunski
764 82ee855a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
765
/**
766
 * Pull all points around the center of the Effect towards a line passing through the center
767
 * (that's if degree>=1) or push them away from the line (degree<=1)
768
 *
769
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
770
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
771
 * @param region Region that masks the Effect.
772
 * @return       ID of the effect added, or -1 if we failed to add one.
773
 */
774
  public long pinch(Data2D pinch, Data3D center, Data4D region)
775
    {
776
    return mV.add(EffectNames.PINCH, pinch, center, region);
777
    }
778
779
///////////////////////////////////////////////////////////////////////////////////////////////////
780
/**
781
 * Pull all points around the center of the Effect towards a line passing through the center
782
 * (that's if degree>=1) or push them away from the line (degree<=1)
783
 *
784
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
785
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
786
 * @return       ID of the effect added, or -1 if we failed to add one.
787
 */
788
  public long pinch(Data2D pinch, Data3D center)
789
    {
790
    return mV.add(EffectNames.PINCH, pinch, center);
791
    }
792
793 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////  
794
/**
795 f2fe7e28 Leszek Koltunski
 * Rotate part of the Object around the Center of the Effect by a certain angle.
796
 *
797 4fde55a0 Leszek Koltunski
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
798 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
799 f2fe7e28 Leszek Koltunski
 * @param region Region that masks the Effect.
800
 * @return       ID of the effect added, or -1 if we failed to add one.
801 6a06a912 Leszek Koltunski
 */
802 fa6c352d Leszek Koltunski
  public long swirl(Data1D swirl, Data3D center, Data4D region)
803 6a06a912 Leszek Koltunski
    {    
804 f2fe7e28 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, swirl, center, region);
805 6a06a912 Leszek Koltunski
    }
806
807
///////////////////////////////////////////////////////////////////////////////////////////////////
808
/**
809 f2fe7e28 Leszek Koltunski
 * Rotate the whole Object around the Center of the Effect by a certain angle.
810
 *
811 4fde55a0 Leszek Koltunski
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
812 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
813 f2fe7e28 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
814 6a06a912 Leszek Koltunski
 */
815 fa6c352d Leszek Koltunski
  public long swirl(Data1D swirl, Data3D center)
816 d425545a Leszek Koltunski
    {
817
    return mV.add(EffectNames.SWIRL, swirl, center);
818
    }
819 4fde55a0 Leszek Koltunski
820
///////////////////////////////////////////////////////////////////////////////////////////////////
821
/**
822
 * Directional, sinusoidal wave effect.
823
 *
824 350cc2f5 Leszek Koltunski
 * @param wave   A 5-dimensional data structure describing the wave: first member is the amplitude,
825 ea16dc89 Leszek Koltunski
 *               second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
826 350cc2f5 Leszek Koltunski
 *               wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
827
 *               describe the 'direction' of the wave.
828 3695d6fa Leszek Koltunski
 *               <p>
829 d0c902b8 Leszek Koltunski
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
830
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
831
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
832
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
833 3695d6fa Leszek Koltunski
 *               <p>
834
 *               <p>
835 d0c902b8 Leszek Koltunski
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
836
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
837
 *               will be sine shapes.
838 3695d6fa Leszek Koltunski
 *               <p>
839 d0c902b8 Leszek Koltunski
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
840
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
841
 *               YZ-plane with be sine shapes.
842 3695d6fa Leszek Koltunski
 *               <p>
843 d0c902b8 Leszek Koltunski
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
844 350cc2f5 Leszek Koltunski
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
845
 *               value if sin at this point.
846 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
847 4fde55a0 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
848
 */
849 fa6c352d Leszek Koltunski
  public long wave(Data5D wave, Data3D center)
850 4fde55a0 Leszek Koltunski
    {
851 02ef26bc Leszek Koltunski
    return mV.add(EffectNames.WAVE, wave, center, null);
852 4fde55a0 Leszek Koltunski
    }
853
854
///////////////////////////////////////////////////////////////////////////////////////////////////
855
/**
856
 * Directional, sinusoidal wave effect.
857
 *
858 421c2728 Leszek Koltunski
 * @param wave   see {@link DistortedEffects#wave(Data5D,Data3D)}
859 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
860 4fde55a0 Leszek Koltunski
 * @param region Region that masks the Effect.
861
 * @return       ID of the effect added, or -1 if we failed to add one.
862
 */
863 fa6c352d Leszek Koltunski
  public long wave(Data5D wave, Data3D center, Data4D region)
864 4fde55a0 Leszek Koltunski
    {
865
    return mV.add(EffectNames.WAVE, wave, center, region);
866
    }
867 f2fe7e28 Leszek Koltunski
  }