Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedObject.java @ 2fce34f4

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
import android.opengl.GLES20;
24
import android.opengl.GLUtils;
25
26 e458a4ba Leszek Koltunski
import org.distorted.library.message.EffectListener;
27 568b29d8 Leszek Koltunski
import org.distorted.library.type.Data1D;
28
import org.distorted.library.type.Data3D;
29
import org.distorted.library.type.Data4D;
30
import org.distorted.library.type.Dynamic;
31
import org.distorted.library.type.Dynamic1D;
32
import org.distorted.library.type.Dynamic2D;
33
import org.distorted.library.type.Dynamic3D;
34
import org.distorted.library.type.Dynamic4D;
35
import org.distorted.library.type.Static1D;
36
import org.distorted.library.type.Static2D;
37
import org.distorted.library.type.Static3D;
38
import org.distorted.library.type.Static4D;
39
import org.distorted.library.type.DynamicQuat;
40 a4835695 Leszek Koltunski
41 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
42 b329f352 Leszek Koltunski
/**
43 437bc43e Leszek Koltunski
 * All Objects to which Distorted Graphics effects can be applied need to be extended from here.
44 b329f352 Leszek Koltunski
 */
45 6a06a912 Leszek Koltunski
public abstract class DistortedObject 
46 1e438fc7 Leszek Koltunski
{
47 568b29d8 Leszek Koltunski
    private static final Static2D mZero2D = new Static2D(0,0);
48
    private static final Static3D mZero3D = new Static3D(0,0,0);
49 e0a16874 Leszek Koltunski
50
    private static float[] mViewMatrix   = new float[16];
51 6a06a912 Leszek Koltunski
   
52 d07f2950 Leszek Koltunski
    protected EffectQueueMatrix    mM;
53
    protected EffectQueueFragment  mF;
54
    protected EffectQueueVertex    mV;
55 6a06a912 Leszek Koltunski
56
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
57
 
58 e458a4ba Leszek Koltunski
    protected DistortedObjectGrid mGrid = null;
59 6a06a912 Leszek Koltunski
    protected long mID;
60
    protected int mSizeX, mSizeY, mSizeZ, mSize; // in screen space
61
62
    protected Bitmap[] mBmp= null; // 
63
    int[] mTextureDataH;           // have to be shared among all the cloned Objects
64
    boolean[] mBitmapSet;          // 
65 9361b337 Leszek Koltunski
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67
68 ada90d33 Leszek Koltunski
    protected abstract DistortedObject deepCopy(int flags);
69 9361b337 Leszek Koltunski
70 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
71
72
    protected void initializeData(int size)
73
      {
74
      mID             = DistortedObjectList.add(this);
75
      mSize           = size;
76
      mTextureDataH   = new int[1];
77
      mTextureDataH[0]= 0;
78
      mBmp            = new Bitmap[1];
79
      mBmp[0]         = null;
80
      mBitmapSet      = new boolean[1];
81
      mBitmapSet[0]   = false;
82
      
83
      initializeEffectLists(this,0);
84
      
85
      if( Distorted.isInitialized() ) resetTexture();    
86
      }
87
    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
    
90
    protected void initializeEffectLists(DistortedObject d, int flags)
91
      {
92 b3618cb5 Leszek Koltunski
      if( (flags & Distorted.CLONE_PRESHADER) != 0 )
93 6a06a912 Leszek Koltunski
        {
94
        mM = d.mM;
95
        matrixCloned = true;
96
        } 
97
      else
98
        {
99 d07f2950 Leszek Koltunski
        mM = new EffectQueueMatrix(d);
100 6a06a912 Leszek Koltunski
        matrixCloned = false;  
101
        }
102
    
103
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
104
        {
105
        mV = d.mV;
106
        vertexCloned = true;
107
        } 
108
      else
109
        {
110 d07f2950 Leszek Koltunski
        mV = new EffectQueueVertex(d);
111 6a06a912 Leszek Koltunski
        vertexCloned = false;  
112
        }
113
    
114
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
115
        {
116
        mF = d.mF;
117
        fragmentCloned = true;
118
        } 
119
      else
120
        {
121 d07f2950 Leszek Koltunski
        mF = new EffectQueueFragment(d);
122 6a06a912 Leszek Koltunski
        fragmentCloned = false;   
123
        }
124
      }
125
    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127
// this will be called on startup and every time OpenGL context has been lost
128
// also call this from the constructor if the OpenGL context has been created already.
129
    
130
    void resetTexture()
131
      {
132
      if( mTextureDataH!=null ) 
133
        {
134
        if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
135
136
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);       
137
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
138
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
139
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
140
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
141
       
142
        if( mBmp!=null && mBmp[0]!=null)
143
          {
144
          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBmp[0], 0);
145
          mBmp[0] = null;
146
          }
147
        }
148
      }
149
  
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151
   
152
    void drawPriv(long currTime, DistortedProjection dp)
153
      {
154
      GLES20.glViewport(0, 0, dp.width, dp.height); 
155
      
156
      mM.compute(currTime);
157
      mM.send(mViewMatrix, dp);
158
      
159
      mV.compute(currTime);
160
      mV.postprocess();
161
      mV.send();
162
        
163
      mF.compute(currTime);
164
      mF.postprocess(mViewMatrix);
165
      mF.send();
166
       
167
      mGrid.draw();
168
      }
169
170
///////////////////////////////////////////////////////////////////////////////////////////////////
171
   
172
    void drawNoEffectsPriv(DistortedProjection dp)
173
      {
174
      GLES20.glViewport(0, 0, dp.width, dp.height);
175
      mM.sendNoEffects(dp);
176
      mV.sendZero();
177
      mF.sendZero();
178
      mGrid.draw();
179
      }
180
    
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182
   
183
    void releasePriv()
184
      {
185
      if( matrixCloned  ==false) mM.abortAll();
186
      if( vertexCloned  ==false) mV.abortAll();
187
      if( fragmentCloned==false) mF.abortAll();
188
189
      mBmp          = null;
190
      mGrid         = null;
191
      mM            = null;
192
      mV            = null;
193
      mF            = null;
194
      mTextureDataH = null;
195
      }
196
 
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198
199
    long getBitmapID()
200
      {
201
      return mBmp==null ? 0 : mBmp.hashCode();
202
      }
203
204 ada90d33 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
205
206
  /**
207
   * Default empty constructor so that derived classes can call it
208
   */
209
    public DistortedObject()
210
      {
211
212
      }
213
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215
  /**
216
   * Copy constructor used to create a DistortedObject based on various parts of another object.
217
   * <p>
218
   * Whatever we do not clone gets created just like in the default constructor.
219 d07f2950 Leszek Koltunski
   * We only call this from the descendant's classes' constructors where we have to pay attention
220
   * to give it the appropriate type of a DistortedObject!
221 ada90d33 Leszek Koltunski
   *
222
   * @param dc    Source object to create our object from
223
   * @param flags A bitmask of values specifying what to copy.
224 d07f2950 Leszek Koltunski
   *              For example, CLONE_BITMAP | CLONE_MATRIX.
225 ada90d33 Leszek Koltunski
   */
226
    public DistortedObject(DistortedObject dc, int flags)
227
      {
228
      initializeEffectLists(dc,flags);
229
230
      mID = DistortedObjectList.add(this);
231
232
      mSizeX = dc.mSizeX;
233
      mSizeY = dc.mSizeY;
234
      mSizeZ = dc.mSizeZ;
235
      mSize  = dc.mSize;
236
      mGrid  = dc.mGrid;
237
238
      if( (flags & Distorted.CLONE_BITMAP) != 0 )
239
        {
240
        mTextureDataH = dc.mTextureDataH;
241
        mBmp          = dc.mBmp;
242
        mBitmapSet    = dc.mBitmapSet;
243
        }
244
      else
245
        {
246
        mTextureDataH   = new int[1];
247
        mTextureDataH[0]= 0;
248
        mBitmapSet      = new boolean[1];
249
        mBitmapSet[0]   = false;
250
        mBmp            = new Bitmap[1];
251
        mBmp[0]         = null;
252
253
        if( Distorted.isInitialized() ) resetTexture();
254
        }
255
      }
256
257 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
258
/**
259
 * Draw the DistortedObject to the location specified by current Matrix effects.    
260
 *     
261
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
262
 *        This gets passed on to Interpolators inside the Effects that are currently applied to the 
263
 *        Object.
264
 */
265
   public void draw(long currTime)
266
     {
267
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
268
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
269
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
270
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]); 
271
      
272
     drawPriv(currTime, Distorted.mProjection);
273
     }
274
 
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276
/**
277
 * Releases all resources.
278
 */
279
   public synchronized void release()
280
     {
281
     releasePriv();  
282
     DistortedObjectList.remove(this);
283
     }
284
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286
/**
287
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
288
 * <p>
289
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
290
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
291
 * 
292
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
293
 */
294
   
295
   public void setBitmap(Bitmap bmp)
296
     {
297
     mBitmapSet[0] = true; 
298
      
299
     if( Distorted.isInitialized() )
300
       {
301
       GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
302
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);        
303
       GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
304
       }
305
     else
306
       {
307
       mBmp[0] = bmp;  
308
       }
309
     }
310
    
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312
/**
313
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
314 9351ad55 Leszek Koltunski
 * to one of the Effects that are currently applied to the DistortedObject.
315 6a06a912 Leszek Koltunski
 * 
316
 * @param el A class implementing the EffectListener interface that wants to get notifications.
317
 */
318
   public void addEventListener(EffectListener el)
319
     {
320
     mV.addListener(el);
321
     mF.addListener(el);
322
     mM.addListener(el);
323
     }
324
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326
/**
327
 * Removes the calling class from the list of Listeners.
328
 * 
329
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
330
 */
331
   public void removeEventListener(EffectListener el)
332
     {
333
     mV.removeListener(el);
334
     mF.removeListener(el);
335
     mM.removeListener(el);
336
     }
337
   
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339
/**
340
 * Returns the height of the DistortedObject.
341
 *    
342
 * @return height of the object, in pixels.
343
 */
344
   public int getWidth()
345
     {
346
     return mSizeX;   
347
     }
348
349
///////////////////////////////////////////////////////////////////////////////////////////////////
350
/**
351
 * Returns the width of the DistortedObject.
352
 * 
353
 * @return width of the Object, in pixels.
354
 */
355
    public int getHeight()
356
      {
357
      return mSizeY;  
358
      }
359
    
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361
/**
362
 * Returns the depth of the DistortedObject.
363
 * 
364
 * @return depth of the Object, in pixels.
365
 */
366
    public int getDepth()
367
      {
368
      return mSizeZ;  
369
      }
370
        
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372
/**
373
 * Returns unique ID of this instance.
374
 * 
375
 * @return ID of the object.
376
 */
377
    public long getID()
378
      {
379
      return mID;  
380
      }
381
    
382
///////////////////////////////////////////////////////////////////////////////////////////////////
383
/**
384 d07f2950 Leszek Koltunski
 * Aborts all Effects.
385
 * @return Number of effects aborted.
386 6a06a912 Leszek Koltunski
 */
387 d07f2950 Leszek Koltunski
    public int abortAllEffects()
388 6a06a912 Leszek Koltunski
      {
389 cdd6333d Leszek Koltunski
      return mM.abortAll() + mV.abortAll() + mF.abortAll();
390 6a06a912 Leszek Koltunski
      }
391
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393
/**
394 d07f2950 Leszek Koltunski
 * Aborts all Effects of a given type, for example all MATRIX Effects.
395 6a06a912 Leszek Koltunski
 * 
396 d07f2950 Leszek Koltunski
 * @param type one of the constants defined in {@link EffectTypes}
397
 * @return Number of effects aborted.
398 6a06a912 Leszek Koltunski
 */
399 d07f2950 Leszek Koltunski
    public int abortEffects(EffectTypes type)
400 6a06a912 Leszek Koltunski
      {
401 d07f2950 Leszek Koltunski
      switch(type)
402
        {
403
        case MATRIX  : return mM.abortAll();
404
        case VERTEX  : return mV.abortAll();
405
        case FRAGMENT: return mF.abortAll();
406
        default      : return 0;
407
        }
408 6a06a912 Leszek Koltunski
      }
409
    
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411
/**
412
 * Aborts a single Effect.
413
 * 
414
 * @param id ID of the Effect we want to abort.
415 476bbc81 Leszek Koltunski
 * @return number of Effects aborted. Always either 0 or 1.
416 6a06a912 Leszek Koltunski
 */
417 476bbc81 Leszek Koltunski
    public int abortEffect(long id)
418 6a06a912 Leszek Koltunski
      {
419 1e438fc7 Leszek Koltunski
      int type = (int)(id&EffectTypes.MASK);
420
421 476bbc81 Leszek Koltunski
      if( type==EffectTypes.MATRIX.type   ) return mM.removeByID(id>>EffectTypes.LENGTH);
422
      if( type==EffectTypes.VERTEX.type   ) return mV.removeByID(id>>EffectTypes.LENGTH);
423
      if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
424 1e438fc7 Leszek Koltunski
425 476bbc81 Leszek Koltunski
      return 0;
426 6a06a912 Leszek Koltunski
      }
427
428
///////////////////////////////////////////////////////////////////////////////////////////////////
429
/**
430
 * Abort all Effects of a given type, for example all rotations.
431
 * 
432 d07f2950 Leszek Koltunski
 * @param name one of the constants defined in {@link EffectNames}
433 476bbc81 Leszek Koltunski
 * @return number of Effects aborted.
434 6a06a912 Leszek Koltunski
 */
435 476bbc81 Leszek Koltunski
    public int abortEffects(EffectNames name)
436 6a06a912 Leszek Koltunski
      {
437 d07f2950 Leszek Koltunski
      switch(name.getType())
438 6a06a912 Leszek Koltunski
        {
439 d07f2950 Leszek Koltunski
        case MATRIX  : return mM.removeByType(name);
440
        case VERTEX  : return mV.removeByType(name);
441
        case FRAGMENT: return mF.removeByType(name);
442 476bbc81 Leszek Koltunski
        default      : return 0;
443 6a06a912 Leszek Koltunski
        }
444
      }
445
    
446
///////////////////////////////////////////////////////////////////////////////////////////////////
447
/**
448
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
449
 * 
450
 * @param id Effect ID we want to print info about
451
 * @return <code>true</code> if a single Effect of type effectType has been found.
452
 */
453
    
454
    public boolean printEffect(long id)
455
      {
456 1e438fc7 Leszek Koltunski
      int type = (int)(id&EffectTypes.MASK);
457
458
      if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
459
      if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
460
      if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
461
462
      return false;
463 6a06a912 Leszek Koltunski
      }
464
   
465
///////////////////////////////////////////////////////////////////////////////////////////////////   
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467
// Individual effect functions.
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469
// Matrix-based effects
470
///////////////////////////////////////////////////////////////////////////////////////////////////
471
/**
472 568b29d8 Leszek Koltunski
 * Moves the Object by a vector that changes in time as interpolated by the Dynamic.
473 6a06a912 Leszek Koltunski
 * 
474 568b29d8 Leszek Koltunski
 * @param vector 3-dimensional Data which at any given time will return a Static3D
475 e0a16874 Leszek Koltunski
 *               representing the current coordinates of the vector we want to move the Object with.
476
 * @return       ID of the effect added, or -1 if we failed to add one.
477 6a06a912 Leszek Koltunski
 */
478 568b29d8 Leszek Koltunski
  public long move(Data3D vector)
479 6a06a912 Leszek Koltunski
    {   
480 e0a16874 Leszek Koltunski
    return mM.add(EffectNames.MOVE,vector);
481 6a06a912 Leszek Koltunski
    }
482
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484
/**
485 568b29d8 Leszek Koltunski
 * Scales the Object by factors that change in time as returned by the Dynamic.
486 6a06a912 Leszek Koltunski
 * 
487 568b29d8 Leszek Koltunski
 * @param scale 3-dimensional Dynamic which at any given time returns a Static3D
488 e0a16874 Leszek Koltunski
 *              representing the current x- , y- and z- scale factors.
489
 * @return      ID of the effect added, or -1 if we failed to add one.
490 6a06a912 Leszek Koltunski
 */
491 568b29d8 Leszek Koltunski
  public long scale(Data3D scale)
492 6a06a912 Leszek Koltunski
    {   
493 e0a16874 Leszek Koltunski
    return mM.add(EffectNames.SCALE,scale);
494 6a06a912 Leszek Koltunski
    }
495
496 2fce34f4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
497
/**
498
 * Scales the Object by one uniform factor in all 3 dimensions. Convenience function.
499
 *
500
 * @param scale The factor to scale all 3 dimensions with.
501
 * @return      ID of the effect added, or -1 if we failed to add one.
502
 */
503
public long scale(float scale)
504
  {
505
  return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
506
  }
507
508 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
509
/**
510 568b29d8 Leszek Koltunski
 * Rotates the Object by 'angle' degrees around the center.
511
 * Static axis of rotation is given by the last parameter.
512
 *
513 e0a16874 Leszek Koltunski
 * @param center Coordinates of the Point we are rotating around.
514 9351ad55 Leszek Koltunski
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
515 568b29d8 Leszek Koltunski
 * @param axis   Axis of rotation
516 e0a16874 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
517
 */
518 568b29d8 Leszek Koltunski
  public long rotate(Data3D center, Data1D angle, Static3D axis)
519 6a06a912 Leszek Koltunski
    {   
520 568b29d8 Leszek Koltunski
    return mM.add(EffectNames.ROTATE, center, angle, axis);
521 6a06a912 Leszek Koltunski
    }
522
523
///////////////////////////////////////////////////////////////////////////////////////////////////
524
/**
525 568b29d8 Leszek Koltunski
 * Rotates the Object by 'angle' degrees around the center.
526 2fce34f4 Leszek Koltunski
 * Here both angle and axis can dynamically change.
527 568b29d8 Leszek Koltunski
 *
528
 * @param center    Coordinates of the Point we are rotating around.
529
 * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
530
 * @return          ID of the effect added, or -1 if we failed to add one.
531 e0a16874 Leszek Koltunski
 */
532 568b29d8 Leszek Koltunski
  public long rotate(Data3D center, Data4D angleaxis)
533
    {
534
    return mM.add(EffectNames.ROTATE, center, angleaxis);
535 6a06a912 Leszek Koltunski
    }
536
537
///////////////////////////////////////////////////////////////////////////////////////////////////
538
/**
539 568b29d8 Leszek Koltunski
 * Rotates the Object by quaternion.
540 6a06a912 Leszek Koltunski
 *   
541 568b29d8 Leszek Koltunski
 * @param center     Coordinates of the Point we are rotating around.
542
 * @param quaternion The quaternion describing the rotation.
543
 * @return           ID of the effect added, or -1 if we failed to add one.
544 6a06a912 Leszek Koltunski
 */
545 568b29d8 Leszek Koltunski
  public long quaternion(Data3D center, Data4D quaternion)
546
    {
547
    return mM.add(EffectNames.QUATERNION,center,quaternion);
548 6a06a912 Leszek Koltunski
    }
549
550
///////////////////////////////////////////////////////////////////////////////////////////////////
551
/**
552 568b29d8 Leszek Koltunski
 * Shears the Object.
553 6a06a912 Leszek Koltunski
 *
554 e0a16874 Leszek Koltunski
 * @param center  Center of shearing, i.e. the point which stays unmoved.
555 568b29d8 Leszek Koltunski
 * @param shear   The 3-tuple of shear factors.
556 e0a16874 Leszek Koltunski
 * @return        ID of the effect added, or -1 if we failed to add one.
557 6a06a912 Leszek Koltunski
 */
558 568b29d8 Leszek Koltunski
  public long shear(Data3D center, Data3D shear)
559 6a06a912 Leszek Koltunski
    {
560 e0a16874 Leszek Koltunski
    return mM.add(EffectNames.SHEAR, center, shear);
561 6a06a912 Leszek Koltunski
    }
562
563
///////////////////////////////////////////////////////////////////////////////////////////////////
564
// Fragment-based effects  
565
///////////////////////////////////////////////////////////////////////////////////////////////////
566
/**
567 2fce34f4 Leszek Koltunski
 * Creates macroblocks at and around point defined by the Region.
568 6a06a912 Leszek Koltunski
 * 
569 568b29d8 Leszek Koltunski
 * @param size   1-dimensional Dynamic which, at any given time, returns the size of the macroblocks.
570 d7bbef2f Leszek Koltunski
 * @param region Region this Effect is limited to.
571 2fce34f4 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
572 6a06a912 Leszek Koltunski
 */
573 2fce34f4 Leszek Koltunski
  public long macroblock(Data1D size, Data4D region)
574 6a06a912 Leszek Koltunski
    {
575 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.MACROBLOCK, size, region);
576 6a06a912 Leszek Koltunski
    }
577
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579
/**
580 e0a16874 Leszek Koltunski
 * Creates macroblocks on the whole Object.
581 2fce34f4 Leszek Koltunski
 *
582
 * @param size   1-dimensional Data which, at any given time, returns the size of the macroblocks.
583
 * @return       ID of the effect added, or -1 if we failed to add one.
584 6a06a912 Leszek Koltunski
 */
585 2fce34f4 Leszek Koltunski
  public long macroblock(Data1D size)
586 6a06a912 Leszek Koltunski
    {
587 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.MACROBLOCK, size);
588 6a06a912 Leszek Koltunski
    }
589
590
///////////////////////////////////////////////////////////////////////////////////////////////////
591
/**
592 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
593 6a06a912 Leszek Koltunski
 *        
594 2fce34f4 Leszek Koltunski
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
595 d7bbef2f Leszek Koltunski
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
596 b1e91f2c Leszek Koltunski
 * @param color  Color to mix. (1,0,0) is RED.
597 2fce34f4 Leszek Koltunski
 * @param region Region this Effect is limited to.
598
 * @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
599
 * @return       ID of the effect added, or -1 if we failed to add one.
600 6a06a912 Leszek Koltunski
 */
601 2fce34f4 Leszek Koltunski
  public long chroma(Data1D blend, Static3D color, Data4D region, boolean smooth)
602 6a06a912 Leszek Koltunski
    {
603 2fce34f4 Leszek Koltunski
    return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
604 6a06a912 Leszek Koltunski
    }
605
606
///////////////////////////////////////////////////////////////////////////////////////////////////
607
/**
608 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change all three of its RGB components.
609
 *
610
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
611 d7bbef2f Leszek Koltunski
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
612 b1e91f2c Leszek Koltunski
 * @param color  Color to mix. (1,0,0) is RED.
613 2fce34f4 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
614 6a06a912 Leszek Koltunski
 */
615 2fce34f4 Leszek Koltunski
  public long chroma(Data1D blend, Static3D color)
616 6a06a912 Leszek Koltunski
    {
617 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.CHROMA, blend, color);
618 6a06a912 Leszek Koltunski
    }
619
620
///////////////////////////////////////////////////////////////////////////////////////////////////  
621
/**
622 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
623 6a06a912 Leszek Koltunski
 *        
624 2fce34f4 Leszek Koltunski
 * @param blendcolor  4-dimensional Data returning the 4-tuple (blend,R,G,B).
625
 *                    Level of blend a given pixel will be mixed with the next parameter 'color':
626
 *                    pixel = (1-t)*pixel + t*color
627 d7bbef2f Leszek Koltunski
 * @param region Region this Effect is limited to.
628 2fce34f4 Leszek Koltunski
 * @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
629
 * @return       ID of the effect added, or -1 if we failed to add one.
630 6a06a912 Leszek Koltunski
 */
631 2fce34f4 Leszek Koltunski
  public long chroma(Data4D blendcolor, Data4D region, boolean smooth )
632 6a06a912 Leszek Koltunski
    {
633 2fce34f4 Leszek Koltunski
    return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blendcolor, region );
634 6a06a912 Leszek Koltunski
    }
635
636
///////////////////////////////////////////////////////////////////////////////////////////////////
637
/**
638 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change all three of its RGB components.
639
 *
640
 * @param blendcolor  4-dimensional Data returning the 4-tuple (blend,R,G,B).
641
 *                    Level of blend a given pixel will be mixed with the next parameter 'color':
642
 *                    pixel = (1-t)*pixel + t*color
643 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
644 6a06a912 Leszek Koltunski
 */
645 2fce34f4 Leszek Koltunski
  public long chroma(Data4D blendcolor)
646 6a06a912 Leszek Koltunski
    {
647 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.CHROMA, blendcolor);
648 6a06a912 Leszek Koltunski
    }
649
650
///////////////////////////////////////////////////////////////////////////////////////////////////
651
/**
652 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its transparency level.
653 6a06a912 Leszek Koltunski
 *        
654 2fce34f4 Leszek Koltunski
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any given
655
 *               moment.
656 d7bbef2f Leszek Koltunski
 * @param region Region this Effect is limited to. 
657 2fce34f4 Leszek Koltunski
 * @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
658 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
659 6a06a912 Leszek Koltunski
 */
660 2fce34f4 Leszek Koltunski
  public long alpha(Data1D alpha, Data4D region, boolean smooth)
661 6a06a912 Leszek Koltunski
    {
662 2fce34f4 Leszek Koltunski
    return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
663 6a06a912 Leszek Koltunski
    }
664
665
///////////////////////////////////////////////////////////////////////////////////////////////////
666
/**
667 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its transparency level.
668
 *
669
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any
670
 *               given moment.
671
 * @return       ID of the effect added, or -1 if we failed to add one.
672 6a06a912 Leszek Koltunski
 */
673 2fce34f4 Leszek Koltunski
  public long alpha(Data1D alpha)
674 6a06a912 Leszek Koltunski
    {
675 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.ALPHA, alpha);
676 6a06a912 Leszek Koltunski
    }
677
678
///////////////////////////////////////////////////////////////////////////////////////////////////
679
/**
680 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its brightness level.
681 6a06a912 Leszek Koltunski
 *        
682 2fce34f4 Leszek Koltunski
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
683 e0a16874 Leszek Koltunski
 *                   at any given moment.
684
 * @param region     Region this Effect is limited to.
685 2fce34f4 Leszek Koltunski
 * @param smooth     If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
686 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
687 6a06a912 Leszek Koltunski
 */
688 2fce34f4 Leszek Koltunski
  public long brightness(Data1D brightness, Data4D region, boolean smooth)
689 6a06a912 Leszek Koltunski
    {
690 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
691 6a06a912 Leszek Koltunski
    }
692
693
///////////////////////////////////////////////////////////////////////////////////////////////////
694
/**
695 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its brightness level.
696
 *
697
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
698 e0a16874 Leszek Koltunski
 *                   at any given moment.
699
 * @return           ID of the effect added, or -1 if we failed to add one.
700 6a06a912 Leszek Koltunski
 */
701 2fce34f4 Leszek Koltunski
  public long brightness(Data1D brightness)
702 6a06a912 Leszek Koltunski
    {
703 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.BRIGHTNESS, brightness);
704 6a06a912 Leszek Koltunski
    }
705
706
///////////////////////////////////////////////////////////////////////////////////////////////////
707
/**
708 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its contrast level.
709 6a06a912 Leszek Koltunski
 *        
710 2fce34f4 Leszek Koltunski
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
711 e0a16874 Leszek Koltunski
 *                 at any given moment.
712
 * @param region   Region this Effect is limited to.
713 2fce34f4 Leszek Koltunski
 * @param smooth   If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
714 e0a16874 Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one.
715 6a06a912 Leszek Koltunski
 */
716 2fce34f4 Leszek Koltunski
  public long contrast(Data1D contrast, Data4D region, boolean smooth)
717 6a06a912 Leszek Koltunski
    {
718 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
719 6a06a912 Leszek Koltunski
    }
720
721
///////////////////////////////////////////////////////////////////////////////////////////////////
722
/**
723 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its contrast level.
724
 *
725
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
726 e0a16874 Leszek Koltunski
 *                 at any given moment.
727
 * @return         ID of the effect added, or -1 if we failed to add one.
728 6a06a912 Leszek Koltunski
 */
729 2fce34f4 Leszek Koltunski
  public long contrast(Data1D contrast)
730 6a06a912 Leszek Koltunski
    {
731 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.CONTRAST, contrast);
732 6a06a912 Leszek Koltunski
    }
733
734
///////////////////////////////////////////////////////////////////////////////////////////////////
735
/**
736 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its saturation level.
737 6a06a912 Leszek Koltunski
 *        
738 2fce34f4 Leszek Koltunski
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
739 e0a16874 Leszek Koltunski
 *                   at any given moment.
740
 * @param region     Region this Effect is limited to.
741 2fce34f4 Leszek Koltunski
 * @param smooth     If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
742 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
743 6a06a912 Leszek Koltunski
 */
744 2fce34f4 Leszek Koltunski
  public long saturation(Data1D saturation, Data4D region, boolean smooth)
745 6a06a912 Leszek Koltunski
    {
746 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
747 6a06a912 Leszek Koltunski
    }
748
749
///////////////////////////////////////////////////////////////////////////////////////////////////
750
/**
751 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its saturation level.
752
 *
753
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
754 e0a16874 Leszek Koltunski
 *                   at any given moment.
755
 * @return           ID of the effect added, or -1 if we failed to add one.
756 6a06a912 Leszek Koltunski
 */
757 2fce34f4 Leszek Koltunski
  public long saturation(Data1D saturation)
758 6a06a912 Leszek Koltunski
    {
759 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.SATURATION, saturation);
760 6a06a912 Leszek Koltunski
    }
761
762
///////////////////////////////////////////////////////////////////////////////////////////////////
763
// Vertex-based effects  
764
///////////////////////////////////////////////////////////////////////////////////////////////////
765
// DISTORT
766
/**
767 e0a16874 Leszek Koltunski
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
768 6a06a912 Leszek Koltunski
 * 
769 568b29d8 Leszek Koltunski
 * @param vector 2- or 3-dimensional Dynamic that returns a 2- or 3-dimensional Point which
770 d7bbef2f Leszek Koltunski
 *               represents the vector the Center of the Effect is currently being dragged with.
771
 * @param region Region that masks the effect of the Distortion.
772 568b29d8 Leszek Koltunski
 * @param center 2-dimensional Dynamic that, at any given time, returns a Point2D representing
773 d7bbef2f Leszek Koltunski
 *               the Center of the Effect.
774
 * @return       ID of the effect added, or -1 if we failed to add one. 
775 6a06a912 Leszek Koltunski
 */
776 568b29d8 Leszek Koltunski
  public long distort(Dynamic vector, Static4D region, Dynamic2D center)
777 6a06a912 Leszek Koltunski
    {  
778 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, vector, region, center);
779 6a06a912 Leszek Koltunski
    }
780
781
///////////////////////////////////////////////////////////////////////////////////////////////////
782
/**
783 e0a16874 Leszek Koltunski
 * Distort part of the Object by a (possibly changing in time) vector of force.
784 6a06a912 Leszek Koltunski
 * <p>
785
 * Difference between this and the previous method is that here the center of the Effect stays constant.
786
 *   
787 568b29d8 Leszek Koltunski
 * @param vector 2- or 3-dimensional Dynamic that returns a 2- or 3-dimensional Point which
788 d7bbef2f Leszek Koltunski
 *               represents the vector the Center of the Effect is currently being dragged with.
789
 * @param region Region that masks the effect of the Distortion.
790 e0a16874 Leszek Koltunski
 * @param center Center of the Effect.
791 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
792 6a06a912 Leszek Koltunski
 */
793 568b29d8 Leszek Koltunski
  public long distort(Dynamic vector, Static4D region, Static2D center)
794 6a06a912 Leszek Koltunski
    {  
795 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, vector, region, center);
796 6a06a912 Leszek Koltunski
    }
797
798
///////////////////////////////////////////////////////////////////////////////////////////////////
799
/**
800 e0a16874 Leszek Koltunski
 * Distort the whole Object by a (possibly changing in time) vector of force.
801 6a06a912 Leszek Koltunski
 * 
802 568b29d8 Leszek Koltunski
 * @param vector 2- or 3-dimensional Dynamic that returns a 2- or 3-dimensional Point which
803 e0a16874 Leszek Koltunski
 *               represents the vector the Center of the Effect is currently being dragged with.
804
 * @param center Center of the Effect.
805
 * @return       ID of the effect added, or -1 if we failed to add one.
806 6a06a912 Leszek Koltunski
 */
807 568b29d8 Leszek Koltunski
  public long distort(Dynamic vector, Static2D center)
808 6a06a912 Leszek Koltunski
    {
809 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, vector, null, center);
810 6a06a912 Leszek Koltunski
    }
811
812
///////////////////////////////////////////////////////////////////////////////////////////////////
813
/**
814 e0a16874 Leszek Koltunski
 * Distort part of the Object by a vector of force that changes from (0,0,0) to v.
815 6a06a912 Leszek Koltunski
 * 
816 d7bbef2f Leszek Koltunski
 * @param vector   Maximum vector of force. 
817
 * @param region   Region that masks the effect of the Distortion.
818 e0a16874 Leszek Koltunski
 * @param center   Center of the Effect.
819 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
820 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
821 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
822 6a06a912 Leszek Koltunski
 */
823 568b29d8 Leszek Koltunski
  public long distort(Static3D vector, Static4D region, Static2D center, int duration, float count)
824 6a06a912 Leszek Koltunski
    {  
825 568b29d8 Leszek Koltunski
    Dynamic3D di = new Dynamic3D();
826 6a06a912 Leszek Koltunski
    di.setCount(count);
827
    di.setDuration(duration);
828 568b29d8 Leszek Koltunski
    di.add(new Static3D(0.0f,0.0f,0.0f));
829 6a06a912 Leszek Koltunski
    di.add(vector);                                                  
830
           
831 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, di, region, center);
832 6a06a912 Leszek Koltunski
    }
833
834
///////////////////////////////////////////////////////////////////////////////////////////////////
835
/**
836 e0a16874 Leszek Koltunski
 * Distort the whole Object by a vector of force that changes from (0,0,0) to v.
837 6a06a912 Leszek Koltunski
 * 
838 d7bbef2f Leszek Koltunski
 * @param vector   Maximum vector of force.
839 e0a16874 Leszek Koltunski
 * @param center   Center of the Effect.
840 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
841 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
842 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
843 6a06a912 Leszek Koltunski
 */
844 568b29d8 Leszek Koltunski
  public long distort(Static3D vector, Static2D center, int duration, float count)
845 6a06a912 Leszek Koltunski
    {
846 568b29d8 Leszek Koltunski
    Dynamic3D di = new Dynamic3D();
847 6a06a912 Leszek Koltunski
    di.setCount(count);
848
    di.setDuration(duration);
849 568b29d8 Leszek Koltunski
    di.add(new Static3D(0.0f,0.0f,0.0f));
850 6a06a912 Leszek Koltunski
    di.add(vector);                                                 
851
           
852 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, di, null, center);
853 6a06a912 Leszek Koltunski
    }
854
855
///////////////////////////////////////////////////////////////////////////////////////////////////
856
/**
857 e0a16874 Leszek Koltunski
 * Distort the whole Object by a vector of force that changes from (0,0,0) to v.
858 6a06a912 Leszek Koltunski
 * <p>
859
 * Difference between this and the previous method is that here the vector of force will get interpolated
860
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
861
 * 
862 d7bbef2f Leszek Koltunski
 * @param vector   Maximum, final vector of force.
863 e0a16874 Leszek Koltunski
 * @param center   Center of the Effect.
864 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
865 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
866 6a06a912 Leszek Koltunski
 */
867 568b29d8 Leszek Koltunski
  public long distort(Static3D vector, Static2D center, int duration)
868 6a06a912 Leszek Koltunski
    {
869 568b29d8 Leszek Koltunski
    Dynamic3D di = new Dynamic3D();
870 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
871
    di.setDuration(duration);
872 568b29d8 Leszek Koltunski
    di.add(new Static3D(0.0f,0.0f,0.0f));
873 6a06a912 Leszek Koltunski
    di.add(vector);                 
874
           
875 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, di, null, center);
876 6a06a912 Leszek Koltunski
    }
877
878
///////////////////////////////////////////////////////////////////////////////////////////////////
879
/**
880 e0a16874 Leszek Koltunski
 * Distort the whole Object by a vector of force v.
881 6a06a912 Leszek Koltunski
 * <p>
882
 * Here we apply a constant vector of force.
883
 * 
884 d7bbef2f Leszek Koltunski
 * @param vector Vector of force.
885 e0a16874 Leszek Koltunski
 * @param center Center of the Effect.
886 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
887 6a06a912 Leszek Koltunski
 */
888 568b29d8 Leszek Koltunski
  public long distort(Static3D vector, Static2D center )
889 6a06a912 Leszek Koltunski
    {
890 568b29d8 Leszek Koltunski
    Dynamic3D di = new Dynamic3D();
891 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
892
    di.setDuration(0);
893 568b29d8 Leszek Koltunski
    di.add(new Static3D(0.0f,0.0f,0.0f));
894 6a06a912 Leszek Koltunski
    di.add(vector);           
895
           
896 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, di, null, center);
897 6a06a912 Leszek Koltunski
    }
898
899
///////////////////////////////////////////////////////////////////////////////////////////////////
900
///////////////////////////////////////////////////////////////////////////////////////////////////
901
// DEFORM
902
/**
903 e0a16874 Leszek Koltunski
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
904 9351ad55 Leszek Koltunski
 * a (possibly changing in time) point on the Object.
905 6a06a912 Leszek Koltunski
 *     
906 568b29d8 Leszek Koltunski
 * @param vector Dynamic that, at any given time, returns a Static2D representing vector of
907 9351ad55 Leszek Koltunski
 *               force that deforms the shape of the whole Object.
908 568b29d8 Leszek Koltunski
 * @param center 2-dimensional Dynamic that, at any given time, returns a Point2D representing
909 e0a16874 Leszek Koltunski
 *               the Center of the Effect.
910
 * @return       ID of the effect added, or -1 if we failed to add one.
911 6a06a912 Leszek Koltunski
 */
912 568b29d8 Leszek Koltunski
  public long deform(Dynamic vector, Dynamic2D center)
913 6a06a912 Leszek Koltunski
    {  
914 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DEFORM, vector, null, center);
915 6a06a912 Leszek Koltunski
    }
916
917
///////////////////////////////////////////////////////////////////////////////////////////////////
918
/**
919 e0a16874 Leszek Koltunski
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
920 9351ad55 Leszek Koltunski
 * a constant point on the Object.
921 6a06a912 Leszek Koltunski
 * 
922 568b29d8 Leszek Koltunski
 * @param vector Dynamic that, at any given time, returns a Static2D representing
923 9351ad55 Leszek Koltunski
 *               vector of force that deforms the shape of the whole Object.
924 e0a16874 Leszek Koltunski
 * @param center Center of the Effect.
925
 * @return       ID of the effect added, or -1 if we failed to add one.
926 6a06a912 Leszek Koltunski
 */
927 568b29d8 Leszek Koltunski
  public long deform(Dynamic vector, Static2D center)
928 6a06a912 Leszek Koltunski
    {
929 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DEFORM, vector, null, center);
930 6a06a912 Leszek Koltunski
    }
931
932
///////////////////////////////////////////////////////////////////////////////////////////////////
933
/**
934 e0a16874 Leszek Koltunski
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
935
 * applied to a constant point on the Object.
936 6a06a912 Leszek Koltunski
 * 
937 d7bbef2f Leszek Koltunski
 * @param vector   Vector of force.
938 e0a16874 Leszek Koltunski
 * @param center   Center of the Effect.
939 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
940 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
941 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
942 6a06a912 Leszek Koltunski
 */
943 568b29d8 Leszek Koltunski
  public long deform(Static3D vector, Static2D center, int duration, float count)
944 6a06a912 Leszek Koltunski
    {
945 568b29d8 Leszek Koltunski
    Dynamic3D di = new Dynamic3D();
946 6a06a912 Leszek Koltunski
    di.setCount(count);
947
    di.setDuration(duration);
948 568b29d8 Leszek Koltunski
    di.add(new Static3D(0.0f,0.0f,0.0f));
949 6a06a912 Leszek Koltunski
    di.add(vector);                
950
           
951 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DEFORM, di, null, center);
952 6a06a912 Leszek Koltunski
    }
953
954
///////////////////////////////////////////////////////////////////////////////////////////////////
955
/**
956 e0a16874 Leszek Koltunski
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
957
 * applied to a constant point on the Object.
958 6a06a912 Leszek Koltunski
 * <p>
959
 * Identical to calling the previous method with count=0.5.
960
 * 
961 d7bbef2f Leszek Koltunski
 * @param vector   Final vector of force.
962 e0a16874 Leszek Koltunski
 * @param center   Center of the Effect.
963 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
964 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
965 6a06a912 Leszek Koltunski
 */
966 568b29d8 Leszek Koltunski
  public long deform(Static3D vector, Static2D center, int duration)
967 6a06a912 Leszek Koltunski
    {
968 568b29d8 Leszek Koltunski
    Dynamic3D di = new Dynamic3D();
969 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
970
    di.setDuration(duration);
971 568b29d8 Leszek Koltunski
    di.add(new Static3D(0.0f,0.0f,0.0f));
972 6a06a912 Leszek Koltunski
    di.add(vector);             
973
           
974 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DEFORM, di, null, center);
975 6a06a912 Leszek Koltunski
    }
976
977
///////////////////////////////////////////////////////////////////////////////////////////////////
978
/**
979 e0a16874 Leszek Koltunski
 * Deform the shape of the whole Object with a constant vector of force applied to a constant
980
 * point on the Object.
981 6a06a912 Leszek Koltunski
 * 
982 d7bbef2f Leszek Koltunski
 * @param vector Vector of force.
983 e0a16874 Leszek Koltunski
 * @param center Center of the Effect.
984 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
985 6a06a912 Leszek Koltunski
 */
986 568b29d8 Leszek Koltunski
  public long deform(Static3D vector, Static2D center )
987 6a06a912 Leszek Koltunski
    {
988 568b29d8 Leszek Koltunski
    Dynamic3D di = new Dynamic3D();
989 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
990
    di.setDuration(0);
991 568b29d8 Leszek Koltunski
    di.add(new Static3D(0.0f,0.0f,0.0f));
992 6a06a912 Leszek Koltunski
    di.add(vector);            
993
           
994 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.DEFORM, di, null, center);
995 6a06a912 Leszek Koltunski
    }
996
   
997
///////////////////////////////////////////////////////////////////////////////////////////////////  
998
///////////////////////////////////////////////////////////////////////////////////////////////////
999
// SINK
1000
/**
1001
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
1002
 * away from the center (degree<=1)
1003
 *    
1004 568b29d8 Leszek Koltunski
 * @param sink   1-dimensional Dynamic which, at any given time, returns a Point1D representing
1005 d7bbef2f Leszek Koltunski
 *               the current degree of the effect.
1006
 * @param region Region that masks the effect of the Sink.
1007 568b29d8 Leszek Koltunski
 * @param center 2-dimensional Dynamic that, at any given time, returns a Point2D representing
1008 d7bbef2f Leszek Koltunski
 *               the Center of the Effect.
1009
 * @return       ID of the effect added, or -1 if we failed to add one. 
1010 6a06a912 Leszek Koltunski
 */
1011 568b29d8 Leszek Koltunski
  public long sink(Dynamic1D sink, Static4D region, Dynamic2D center)
1012 6a06a912 Leszek Koltunski
    {
1013 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SINK, sink, region, center);
1014 6a06a912 Leszek Koltunski
    }
1015
1016
///////////////////////////////////////////////////////////////////////////////////////////////////
1017
/**
1018
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
1019
 * away from the center (degree<=1).
1020
 * <p>
1021
 * Here the Center stays constant.
1022
 *      
1023 568b29d8 Leszek Koltunski
 * @param sink   1-dimensional Dynamic which, at any given time, returns a Point1D
1024 d7bbef2f Leszek Koltunski
 *               representing the current degree of the effect.
1025
 * @param region Region that masks the effect of the Sink.
1026 e0a16874 Leszek Koltunski
 * @param center Center of the Effect.
1027 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
1028 6a06a912 Leszek Koltunski
 */
1029 568b29d8 Leszek Koltunski
  public long sink(Dynamic1D sink, Static4D region, Static2D center)
1030 6a06a912 Leszek Koltunski
    {
1031 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SINK, sink, region, center);
1032 6a06a912 Leszek Koltunski
    }
1033
  
1034
///////////////////////////////////////////////////////////////////////////////////////////////////
1035
/**
1036
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
1037
 * away from the center (degree<=1).
1038
 * <p>
1039
 * Here we can only interpolate between 1 and degree.
1040
 * 
1041 e0a16874 Leszek Koltunski
 * @param sink     How much to push or pull. Between 0 and infinity.
1042 d7bbef2f Leszek Koltunski
 * @param region   Region that masks the effect of the Sink.
1043 568b29d8 Leszek Koltunski
 * @param center   2-dimensional Dynamic that, at any given time, returns a Point2D representing
1044 d7bbef2f Leszek Koltunski
 *                 the Center of the Effect.
1045 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1046 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
1047 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
1048 6a06a912 Leszek Koltunski
 */
1049 568b29d8 Leszek Koltunski
  public long sink(float sink, Static4D region, Dynamic2D center, int duration, float count)
1050 6a06a912 Leszek Koltunski
    {
1051 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1052 6a06a912 Leszek Koltunski
    di.setCount(count);
1053
    di.setDuration(duration);
1054 568b29d8 Leszek Koltunski
    di.add(new Static1D(1));
1055
    di.add(new Static1D(sink));
1056 6a06a912 Leszek Koltunski
    
1057 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SINK, di, region, center);
1058 6a06a912 Leszek Koltunski
    }
1059
1060
///////////////////////////////////////////////////////////////////////////////////////////////////
1061
/**
1062
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
1063
 * away from the center (degree<=1).
1064
 *   
1065 e0a16874 Leszek Koltunski
 * @param sink     How much to push or pull. Between 0 and infinity.
1066 d7bbef2f Leszek Koltunski
 * @param region   Region that masks the effect of the Sink.
1067 e0a16874 Leszek Koltunski
 * @param center   Center of the Effect.
1068 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1069 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
1070 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
1071 6a06a912 Leszek Koltunski
 */
1072 568b29d8 Leszek Koltunski
  public long sink(float sink, Static4D region, Static2D center, int duration, float count)
1073 6a06a912 Leszek Koltunski
    {
1074 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1075 6a06a912 Leszek Koltunski
    di.setCount(count);
1076
    di.setDuration(duration);
1077 568b29d8 Leszek Koltunski
    di.add(new Static1D(1));
1078
    di.add(new Static1D(sink));
1079 6a06a912 Leszek Koltunski
    
1080 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SINK, di, region, center);
1081 6a06a912 Leszek Koltunski
    }
1082
1083
///////////////////////////////////////////////////////////////////////////////////////////////////
1084
/**
1085 e0a16874 Leszek Koltunski
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
1086 6a06a912 Leszek Koltunski
 * away from the center (degree<=1).
1087
 * 
1088 e0a16874 Leszek Koltunski
 * @param sink     How much to push or pull. Between 0 and infinity.
1089
 * @param center   Center of the Effect.
1090 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1091 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
1092 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
1093 6a06a912 Leszek Koltunski
 */
1094 568b29d8 Leszek Koltunski
  public long sink(float sink, Static2D center, int duration, float count)
1095 6a06a912 Leszek Koltunski
    {
1096 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1097 6a06a912 Leszek Koltunski
    di.setCount(count);
1098
    di.setDuration(duration);
1099 568b29d8 Leszek Koltunski
    di.add(new Static1D(1));
1100
    di.add(new Static1D(sink));
1101 6a06a912 Leszek Koltunski
         
1102 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SINK, di, null, center);
1103 6a06a912 Leszek Koltunski
    }
1104
1105
///////////////////////////////////////////////////////////////////////////////////////////////////
1106
/**
1107 e0a16874 Leszek Koltunski
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
1108 6a06a912 Leszek Koltunski
 * away from the center (degree<=1).
1109
 * <p>
1110
 * Equivalent to calling the previous method with count=0.5.
1111
 * 
1112 e0a16874 Leszek Koltunski
 * @param sink     How much to push or pull. Between 0 and infinity.
1113
 * @param center   Center of the Effect.
1114 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1115 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
1116 6a06a912 Leszek Koltunski
 */
1117 568b29d8 Leszek Koltunski
  public long sink(float sink, Static2D center, int duration)
1118 6a06a912 Leszek Koltunski
    {
1119 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1120 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
1121
    di.setDuration(duration);
1122 568b29d8 Leszek Koltunski
    di.add(new Static1D(1));
1123
    di.add(new Static1D(sink));
1124 6a06a912 Leszek Koltunski
        
1125 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SINK, di, null, center);
1126 6a06a912 Leszek Koltunski
    }
1127
1128
///////////////////////////////////////////////////////////////////////////////////////////////////
1129
/**
1130 e0a16874 Leszek Koltunski
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
1131 6a06a912 Leszek Koltunski
 * away from the center (degree<=1).
1132
 * <p>
1133
 * Equivalent of calling the previous method with duration=0; i.e. we pull immediately.
1134
 * 
1135 e0a16874 Leszek Koltunski
 * @param sink   How much to push or pull. Between 0 and infinity.
1136
 * @param center Center of the Effect.
1137 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
1138 6a06a912 Leszek Koltunski
 */
1139 568b29d8 Leszek Koltunski
  public long sink(float sink, Static2D center)
1140 6a06a912 Leszek Koltunski
    {
1141 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1142 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
1143
    di.setDuration(0);
1144 568b29d8 Leszek Koltunski
    di.add(new Static1D(1));
1145
    di.add(new Static1D(sink));
1146 6a06a912 Leszek Koltunski
        
1147 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SINK, di, null, center);
1148 6a06a912 Leszek Koltunski
    }
1149
  
1150
///////////////////////////////////////////////////////////////////////////////////////////////////  
1151
///////////////////////////////////////////////////////////////////////////////////////////////////
1152
// SWIRL
1153
/**
1154 e0a16874 Leszek Koltunski
 * Rotate part of the Object around the Center of the Effect by a certain angle (as returned by the
1155 568b29d8 Leszek Koltunski
 * Dynamic).
1156 6a06a912 Leszek Koltunski
 *   
1157 568b29d8 Leszek Koltunski
 * @param swirl  1-dimensional Dynamic which, at any given time, returns a Point1D representing
1158 d7bbef2f Leszek Koltunski
 *               the degree of Swirl.
1159
 * @param region Region that masks the effect of the Swirl.
1160 568b29d8 Leszek Koltunski
 * @param center 2-dimensional Dynamic that, at any given time, returns a Point2D representing
1161 d7bbef2f Leszek Koltunski
 *               the Center of the Effect.
1162
 * @return       ID of the effect added, or -1 if we failed to add one. 
1163 6a06a912 Leszek Koltunski
 */
1164 568b29d8 Leszek Koltunski
  public long swirl(Dynamic1D swirl, Static4D region, Dynamic2D center)
1165 6a06a912 Leszek Koltunski
    {    
1166 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, swirl, region, center);
1167 6a06a912 Leszek Koltunski
    }
1168
1169
///////////////////////////////////////////////////////////////////////////////////////////////////
1170
/**
1171 e0a16874 Leszek Koltunski
 * Rotate part of the Object around the Center of the Effect by a certain angle (as returned by the
1172 568b29d8 Leszek Koltunski
 * Dynamic).
1173 6a06a912 Leszek Koltunski
 * <p>
1174
 * Here the Center stays constant.
1175
 *      
1176 568b29d8 Leszek Koltunski
 * @param swirl  1-dimensional Dynamic which, at any given time, returns a Point1D representing
1177 d7bbef2f Leszek Koltunski
 *               the degree of Swirl.
1178
 * @param region Region that masks the effect of the Swirl.
1179 e0a16874 Leszek Koltunski
 * @param center Center of the Effect.
1180 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
1181 6a06a912 Leszek Koltunski
 */
1182 568b29d8 Leszek Koltunski
  public long swirl(Dynamic1D swirl, Static4D region, Static2D center)
1183 6a06a912 Leszek Koltunski
    {    
1184 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, swirl, region, center);
1185 6a06a912 Leszek Koltunski
    }
1186
 
1187
///////////////////////////////////////////////////////////////////////////////////////////////////
1188
/**
1189 e0a16874 Leszek Koltunski
 * Rotate part of the Object around the Center of the Effect by 'degree' angle.
1190 6a06a912 Leszek Koltunski
 *   
1191 e0a16874 Leszek Koltunski
 * @param swirl    Angle of rotation. Unit: degrees.
1192 d7bbef2f Leszek Koltunski
 * @param region   Region that masks the effect of the Swirl.
1193 568b29d8 Leszek Koltunski
 * @param center   2-dimensional Dynamic that, at any given time, returns a Point2D representing
1194 d7bbef2f Leszek Koltunski
 *                 the Center of the Effect.
1195 b1e91f2c Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one.
1196 6a06a912 Leszek Koltunski
 */
1197 568b29d8 Leszek Koltunski
  public long swirl(int swirl, Static4D region, Dynamic2D center)
1198 6a06a912 Leszek Koltunski
    {
1199 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1200 b1e91f2c Leszek Koltunski
    di.setCount(0.5f);
1201
    di.setDuration(0);
1202 568b29d8 Leszek Koltunski
    di.add(new Static1D(0));
1203
    di.add(new Static1D(swirl));
1204 6a06a912 Leszek Koltunski
    
1205 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, di, region, center);
1206 6a06a912 Leszek Koltunski
    }
1207
1208
///////////////////////////////////////////////////////////////////////////////////////////////////
1209
/**
1210 e0a16874 Leszek Koltunski
 * Rotate part of the Object around the Center of the Effect by 'degree' angle.
1211 6a06a912 Leszek Koltunski
 * <p>
1212
 * Here the Center stays constant.
1213
 *    
1214 e0a16874 Leszek Koltunski
 * @param swirl    Angle of rotation. Unit: degrees.
1215 d7bbef2f Leszek Koltunski
 * @param region   Region that masks the effect of the Swirl.
1216 e0a16874 Leszek Koltunski
 * @param center   Center of the Effect.
1217 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1218 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
1219 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
1220 6a06a912 Leszek Koltunski
 */
1221 568b29d8 Leszek Koltunski
  public long swirl(int swirl, Static4D region, Static2D center, int duration, float count)
1222 6a06a912 Leszek Koltunski
    {
1223 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1224 6a06a912 Leszek Koltunski
    di.setCount(count);
1225
    di.setDuration(duration);
1226 568b29d8 Leszek Koltunski
    di.add(new Static1D(0));
1227
    di.add(new Static1D(swirl));
1228 6a06a912 Leszek Koltunski
    
1229 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, di, region, center);
1230 6a06a912 Leszek Koltunski
    }
1231
1232
///////////////////////////////////////////////////////////////////////////////////////////////////
1233
/**
1234 e0a16874 Leszek Koltunski
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
1235 6a06a912 Leszek Koltunski
 * 
1236 e0a16874 Leszek Koltunski
 * @param swirl    Angle of rotation. Unit: degrees.
1237
 * @param center   Center of the Effect.
1238 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1239 568b29d8 Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Dynamic#setCount(float)}
1240 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
1241 6a06a912 Leszek Koltunski
 */
1242 568b29d8 Leszek Koltunski
  public long swirl(int swirl, Static2D center, int duration, float count)
1243 6a06a912 Leszek Koltunski
    {
1244 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1245 6a06a912 Leszek Koltunski
    di.setCount(count);
1246
    di.setDuration(duration);
1247 568b29d8 Leszek Koltunski
    di.add(new Static1D(0));
1248
    di.add(new Static1D(swirl));
1249 6a06a912 Leszek Koltunski
         
1250 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, di, null, center);
1251 6a06a912 Leszek Koltunski
    }
1252
1253
///////////////////////////////////////////////////////////////////////////////////////////////////
1254
/**
1255 e0a16874 Leszek Koltunski
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
1256 6a06a912 Leszek Koltunski
 * <p>
1257
 * Equivalent to calling the previous method with count=0.5.
1258
 * 
1259 e0a16874 Leszek Koltunski
 * @param swirl    Angle of rotation. Unit: degrees.
1260
 * @param center   Center of the Effect.
1261 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1262 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
1263 6a06a912 Leszek Koltunski
 */
1264 568b29d8 Leszek Koltunski
  public long swirl(int swirl, Static2D center, int duration)
1265 6a06a912 Leszek Koltunski
    {
1266 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1267 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
1268
    di.setDuration(duration);
1269 568b29d8 Leszek Koltunski
    di.add(new Static1D(0));
1270
    di.add(new Static1D(swirl));
1271 6a06a912 Leszek Koltunski
        
1272 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, di, null, center);
1273 6a06a912 Leszek Koltunski
    }
1274
1275
///////////////////////////////////////////////////////////////////////////////////////////////////
1276
/**
1277 e0a16874 Leszek Koltunski
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
1278 6a06a912 Leszek Koltunski
 * <p>
1279
 * Equivalent to calling the previous method with duration=0.
1280
 * 
1281 e0a16874 Leszek Koltunski
 * @param swirl  Angle of rotation. Unit: degrees.
1282
 * @param center Center of the Effect.
1283 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
1284 6a06a912 Leszek Koltunski
 */
1285 568b29d8 Leszek Koltunski
  public long swirl(int swirl, Static2D center)
1286 6a06a912 Leszek Koltunski
    {
1287 568b29d8 Leszek Koltunski
    Dynamic1D di = new Dynamic1D();
1288 6a06a912 Leszek Koltunski
    di.setCount(0.5f);
1289
    di.setDuration(0);
1290 568b29d8 Leszek Koltunski
    di.add(new Static1D(0));
1291
    di.add(new Static1D(swirl));
1292 6a06a912 Leszek Koltunski
        
1293 e0a16874 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, di, null, center);
1294 6a06a912 Leszek Koltunski
    }
1295
1296
///////////////////////////////////////////////////////////////////////////////////////////////////
1297
///////////////////////////////////////////////////////////////////////////////////////////////////
1298
// WAVE
1299
1300
}