Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedObject.java @ d0c902b8

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