Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
package org.distorted.library;
21

    
22
import android.graphics.Bitmap;
23
import android.opengl.GLES20;
24
import android.opengl.GLUtils;
25

    
26
import org.distorted.library.message.EffectListener;
27
import org.distorted.library.type.Float1D;
28
import org.distorted.library.type.Float2D;
29
import org.distorted.library.type.Float3D;
30
import org.distorted.library.type.Float4D;
31
import org.distorted.library.type.Interpolator;
32
import org.distorted.library.type.Interpolator1D;
33
import org.distorted.library.type.Interpolator2D;
34
import org.distorted.library.type.Interpolator3D;
35
import org.distorted.library.type.Interpolator4D;
36
import org.distorted.library.type.InterpolatorQuat;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
/**
40
 * All Objects to which Distorted Graphics effects can be applied need to be extended from here.
41
 */
42
public abstract class DistortedObject 
43
{
44
    private static final Float2D mZero2D = new Float2D(0,0);
45
    private static final Float3D mZero3D = new Float3D(0,0,0);
46

    
47
    private static float[] mViewMatrix   = new float[16];
48
   
49
    protected EffectQueueMatrix    mM;
50
    protected EffectQueueFragment  mF;
51
    protected EffectQueueVertex    mV;
52
    protected EffectQueueOther mO;
53

    
54
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
55
 
56
    protected DistortedObjectGrid mGrid = null;
57
    protected long mID;
58
    protected int mSizeX, mSizeY, mSizeZ, mSize; // in screen space
59

    
60
    protected Bitmap[] mBmp= null; // 
61
    int[] mTextureDataH;           // have to be shared among all the cloned Objects
62
    boolean[] mBitmapSet;          // 
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
    protected abstract DistortedObject deepCopy(int flags);
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
    protected void initializeData(int size)
71
      {
72
      mID             = DistortedObjectList.add(this);
73
      mSize           = size;
74
      mTextureDataH   = new int[1];
75
      mTextureDataH[0]= 0;
76
      mBmp            = new Bitmap[1];
77
      mBmp[0]         = null;
78
      mBitmapSet      = new boolean[1];
79
      mBitmapSet[0]   = false;
80
      
81
      initializeEffectLists(this,0);
82
      
83
      if( Distorted.isInitialized() ) resetTexture();    
84
      }
85
    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87
    
88
    protected void initializeEffectLists(DistortedObject d, int flags)
89
      {
90
      if( (flags & Distorted.CLONE_PRESHADER) != 0 )
91
        {
92
        mM = d.mM;
93
        matrixCloned = true;
94
        } 
95
      else
96
        {
97
        mM = new EffectQueueMatrix(d);
98
        matrixCloned = false;  
99
        }
100
    
101
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
102
        {
103
        mV = d.mV;
104
        vertexCloned = true;
105
        } 
106
      else
107
        {
108
        mV = new EffectQueueVertex(d);
109
        vertexCloned = false;  
110
        }
111
    
112
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
113
        {
114
        mF = d.mF;
115
        fragmentCloned = true;
116
        } 
117
      else
118
        {
119
        mF = new EffectQueueFragment(d);
120
        fragmentCloned = false;   
121
        }
122

    
123
      mO= new EffectQueueOther(d); // Other effects are never cloned.
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
      mO.send();
170
      }
171

    
172
///////////////////////////////////////////////////////////////////////////////////////////////////
173
   
174
    void drawNoEffectsPriv(DistortedProjection dp)
175
      {
176
      GLES20.glViewport(0, 0, dp.width, dp.height);
177
      mM.sendNoEffects(dp);
178
      mV.sendZero();
179
      mF.sendZero();
180
      mGrid.draw();
181
      }
182
    
183
///////////////////////////////////////////////////////////////////////////////////////////////////
184
   
185
    void releasePriv()
186
      {
187
      if( matrixCloned  ==false) mM.abortAll();
188
      if( vertexCloned  ==false) mV.abortAll();
189
      if( fragmentCloned==false) mF.abortAll();
190

    
191
      mO.abortAll();
192

    
193
      mBmp          = null;
194
      mGrid         = null;
195
      mM            = null;
196
      mV            = null;
197
      mF            = null;
198
      mO            = null;
199
      mTextureDataH = null;
200
      }
201
 
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
    long getBitmapID()
205
      {
206
      return mBmp==null ? 0 : mBmp.hashCode();
207
      }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  /**
212
   * Default empty constructor so that derived classes can call it
213
   */
214
    public DistortedObject()
215
      {
216

    
217
      }
218

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220
  /**
221
   * Copy constructor used to create a DistortedObject based on various parts of another object.
222
   * <p>
223
   * Whatever we do not clone gets created just like in the default constructor.
224
   * We only call this from the descendant's classes' constructors where we have to pay attention
225
   * to give it the appropriate type of a DistortedObject!
226
   *
227
   * @param dc    Source object to create our object from
228
   * @param flags A bitmask of values specifying what to copy.
229
   *              For example, CLONE_BITMAP | CLONE_MATRIX.
230
   */
231
    public DistortedObject(DistortedObject dc, int flags)
232
      {
233
      initializeEffectLists(dc,flags);
234

    
235
      mID = DistortedObjectList.add(this);
236

    
237
      mSizeX = dc.mSizeX;
238
      mSizeY = dc.mSizeY;
239
      mSizeZ = dc.mSizeZ;
240
      mSize  = dc.mSize;
241
      mGrid  = dc.mGrid;
242

    
243
      if( (flags & Distorted.CLONE_BITMAP) != 0 )
244
        {
245
        mTextureDataH = dc.mTextureDataH;
246
        mBmp          = dc.mBmp;
247
        mBitmapSet    = dc.mBitmapSet;
248
        }
249
      else
250
        {
251
        mTextureDataH   = new int[1];
252
        mTextureDataH[0]= 0;
253
        mBitmapSet      = new boolean[1];
254
        mBitmapSet[0]   = false;
255
        mBmp            = new Bitmap[1];
256
        mBmp[0]         = null;
257

    
258
        if( Distorted.isInitialized() ) resetTexture();
259
        }
260
      }
261

    
262
///////////////////////////////////////////////////////////////////////////////////////////////////
263
/**
264
 * Draw the DistortedObject to the location specified by current Matrix effects.    
265
 *     
266
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
267
 *        This gets passed on to Interpolators inside the Effects that are currently applied to the 
268
 *        Object.
269
 */
270
   public void draw(long currTime)
271
     {
272
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
273
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
274
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
275
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]); 
276
      
277
     drawPriv(currTime, Distorted.mProjection);
278
     }
279
 
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281
/**
282
 * Releases all resources.
283
 */
284
   public synchronized void release()
285
     {
286
     releasePriv();  
287
     DistortedObjectList.remove(this);
288
     }
289

    
290
///////////////////////////////////////////////////////////////////////////////////////////////////
291
/**
292
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
293
 * <p>
294
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
295
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
296
 * 
297
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
298
 */
299
   
300
   public void setBitmap(Bitmap bmp)
301
     {
302
     mBitmapSet[0] = true; 
303
      
304
     if( Distorted.isInitialized() )
305
       {
306
       GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
307
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);        
308
       GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
309
       }
310
     else
311
       {
312
       mBmp[0] = bmp;  
313
       }
314
     }
315
    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317
/**
318
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
319
 * to one of the Effects that are currently applied to the DistortedObject.
320
 * 
321
 * @param el A class implementing the EffectListener interface that wants to get notifications.
322
 */
323
   public void addEventListener(EffectListener el)
324
     {
325
     mV.addListener(el);
326
     mF.addListener(el);
327
     mM.addListener(el);
328
     mO.addListener(el);
329
     }
330

    
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332
/**
333
 * Removes the calling class from the list of Listeners.
334
 * 
335
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
336
 */
337
   public void removeEventListener(EffectListener el)
338
     {
339
     mV.removeListener(el);
340
     mF.removeListener(el);
341
     mM.removeListener(el);
342
     mO.removeListener(el);
343
     }
344
   
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346
/**
347
 * Returns the height of the DistortedObject.
348
 *    
349
 * @return height of the object, in pixels.
350
 */
351
   public int getWidth()
352
     {
353
     return mSizeX;   
354
     }
355

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357
/**
358
 * Returns the width of the DistortedObject.
359
 * 
360
 * @return width of the Object, in pixels.
361
 */
362
    public int getHeight()
363
      {
364
      return mSizeY;  
365
      }
366
    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368
/**
369
 * Returns the depth of the DistortedObject.
370
 * 
371
 * @return depth of the Object, in pixels.
372
 */
373
    public int getDepth()
374
      {
375
      return mSizeZ;  
376
      }
377
        
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
/**
380
 * Returns unique ID of this instance.
381
 * 
382
 * @return ID of the object.
383
 */
384
    public long getID()
385
      {
386
      return mID;  
387
      }
388
    
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390
/**
391
 * Aborts all Effects.
392
 * @return Number of effects aborted.
393
 */
394
    public int abortAllEffects()
395
      {
396
      return mM.abortAll() + mV.abortAll() + mF.abortAll() + mO.abortAll();
397
      }
398

    
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400
/**
401
 * Aborts all Effects of a given type, for example all MATRIX Effects.
402
 * 
403
 * @param type one of the constants defined in {@link EffectTypes}
404
 * @return Number of effects aborted.
405
 */
406
    public int abortEffects(EffectTypes type)
407
      {
408
      switch(type)
409
        {
410
        case MATRIX  : return mM.abortAll();
411
        case VERTEX  : return mV.abortAll();
412
        case FRAGMENT: return mF.abortAll();
413
        case OTHER   : return mO.abortAll();
414
        default      : return 0;
415
        }
416
      }
417
    
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419
/**
420
 * Aborts a single Effect.
421
 * 
422
 * @param id ID of the Effect we want to abort.
423
 * @return number of Effects aborted. Always either 0 or 1.
424
 */
425
    public int abortEffect(long id)
426
      {
427
      int type = (int)(id&EffectTypes.MASK);
428

    
429
      if( type==EffectTypes.MATRIX.type   ) return mM.removeByID(id>>EffectTypes.LENGTH);
430
      if( type==EffectTypes.VERTEX.type   ) return mV.removeByID(id>>EffectTypes.LENGTH);
431
      if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
432
      if( type==EffectTypes.OTHER.type    ) return mO.removeByID(id>>EffectTypes.LENGTH);
433

    
434
      return 0;
435
      }
436

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438
/**
439
 * Abort all Effects of a given type, for example all rotations.
440
 * 
441
 * @param name one of the constants defined in {@link EffectNames}
442
 * @return number of Effects aborted.
443
 */
444
    public int abortEffects(EffectNames name)
445
      {
446
      switch(name.getType())
447
        {
448
        case MATRIX  : return mM.removeByType(name);
449
        case VERTEX  : return mV.removeByType(name);
450
        case FRAGMENT: return mF.removeByType(name);
451
        case OTHER   : return mO.removeByType(name);
452
        default      : return 0;
453
        }
454
      }
455
    
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457
/**
458
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
459
 * 
460
 * @param id Effect ID we want to print info about
461
 * @return <code>true</code> if a single Effect of type effectType has been found.
462
 */
463
    
464
    public boolean printEffect(long id)
465
      {
466
      int type = (int)(id&EffectTypes.MASK);
467

    
468
      if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
469
      if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
470
      if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
471
      if( type==EffectTypes.OTHER.type    )  return mO.printByID(id>>EffectTypes.LENGTH);
472

    
473
      return false;
474
      }
475
   
476
///////////////////////////////////////////////////////////////////////////////////////////////////   
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478
// Individual effect functions.
479
///////////////////////////////////////////////////////////////////////////////////////////////////
480
// Matrix-based effects
481
///////////////////////////////////////////////////////////////////////////////////////////////////
482
// MOVE
483
/**
484
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
485
 * 
486
 * @param vector 3-dimensional Interpolator which at any given time will return a Float3D
487
 *               representing the current coordinates of the vector we want to move the Object with.
488
 * @return       ID of the effect added, or -1 if we failed to add one.
489
 */
490
  public long move(Interpolator3D vector)
491
    {   
492
    return mM.add(EffectNames.MOVE,vector);
493
    }
494

    
495
///////////////////////////////////////////////////////////////////////////////////////////////////
496
/**
497
 * Moves the Object by a vector that smoothly changes from (0,0,0) to (x,y,z).
498
 *  
499
 * @param x        The x-coordinate of the vector we want to move the Object with. 
500
 * @param y        The y-coordinate of the vector we want to move the Object with.
501
 * @param z        The z-coordinate of the vector we want to move the Object with.
502
 * @param duration The time, in milliseconds, it takes to complete the movement.
503
 * @return         ID of the effect added, or -1 if we failed to add one. 
504
 */
505
  public long move(float x,float y,float z, int duration)
506
    {   
507
    Interpolator3D di = new Interpolator3D();  
508
    di.setCount(0.5f);
509
    di.setDuration(duration);
510
    di.add(new Float3D(0.0f,0.0f,0.0f));                             
511
    di.add(new Float3D(x,y,z));                        
512

    
513
    return mM.add(EffectNames.MOVE,di);
514
    }
515

    
516
///////////////////////////////////////////////////////////////////////////////////////////////////
517
/**
518
 * Moves the Object by vector (x,y,z) immediately.
519
 *   
520
 * @param x The x-coordinate of the vector we want to move the Object with. 
521
 * @param y The y-coordinate of the vector we want to move the Object with.
522
 * @param z The z-coordinate of the vector we want to move the Object with.
523
 * @return  ID of the effect added, or -1 if we failed to add one. 
524
 */
525
  public long move(float x,float y,float z)
526
    {   
527
    return mM.add(EffectNames.MOVE,mZero3D,x,y,z,0.0f);
528
    }
529

    
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531
// SCALE
532
/**
533
 * Scales the Object by factors that change in time as returned by the Interpolator.
534
 * 
535
 * @param scale 3-dimensional Interpolator which at any given time returns a Float3D
536
 *              representing the current x- , y- and z- scale factors.
537
 * @return      ID of the effect added, or -1 if we failed to add one.
538
 */
539
  public long scale(Interpolator3D scale)
540
    {   
541
    return mM.add(EffectNames.SCALE,scale);
542
    }
543

    
544
///////////////////////////////////////////////////////////////////////////////////////////////////
545
/**
546
 * Scales the Object by a factor that smoothly changes from (1,1,1) at time 0 to (xscale,yscale,zscale)
547
 * after 'duration' milliseconds. 
548
 *    
549
 * @param xscale   After time 'duration' passes, Object's width will get multiplied by xscale; e.g. if
550
 *                 xscale=2, after 'duration' milliseconds the Object will become twice broader.
551
 * @param yscale   Factor to scale Object's height with.
552
 * @param zscale   Factor to scale Object's depth with.
553
 * @param duration Time, in milliseconds, it takes to interpolate to the full (xscale,yscale,zscale) scaling factors.
554
 * @return         ID of the effect added, or -1 if we failed to add one. 
555
 */
556
  public long scale(float xscale,float yscale,float zscale, int duration)
557
    {   
558
    Interpolator3D di = new Interpolator3D();  
559
    di.setCount(0.5f);
560
    di.setDuration(duration);
561
    di.add(new Float3D(1.0f,1.0f,1.0f));                             
562
    di.add(new Float3D(xscale,yscale,zscale));                        
563

    
564
    return mM.add(EffectNames.SCALE,di);
565
    }
566

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568
/**
569
 * Immediately scales the Object's width by (xscale,yscale,zscale).   
570
 *   
571
 * @param xscale Object's width gets multiplied by this factor; e.g. if 
572
 *               xscale=2, the Object immediately becomes twice broader.
573
 * @param yscale factor to scale Object's height with.
574
 * @param zscale factor to scale Object's depth with. 
575
 * @return       ID of the effect added, or -1 if we failed to add one. 
576
 */
577
  public long scale(float xscale,float yscale,float zscale)
578
    {   
579
    return mM.add(EffectNames.SCALE,mZero3D,xscale,yscale,zscale,0.0f);
580
    }
581

    
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583
/**
584
 * Convenience function - scale the Object by the same factor in all 3 dimensions.   
585
 *   
586
 * @param scale all 3 Object's dimensions get multiplied by this factor; e.g. if 
587
 *              scale=2, the Object immediately becomes twice larger.
588
 * @return      ID of the effect added, or -1 if we failed to add one. 
589
 */
590
  public long scale(float scale)
591
    {   
592
    return mM.add(EffectNames.SCALE,mZero3D,scale,scale,scale,0.0f);
593
    }
594
    
595
///////////////////////////////////////////////////////////////////////////////////////////////////
596
// ROTATE
597
/**
598
 * Rotates the Object around a (possibly moving) point, with angle and axis that change in time.
599
 * 
600
 * @param center    3-dimensional Interpolator which at any given time will return the current center
601
 *                  of the rotation
602
 * @param angleAxis 4-dimensional Interpolator which at any given time will return a Float4D
603
 *                  representing the current rotation in the (angle,axisX,axisY,axisY) form.
604
 * @return          ID of the effect added, or -1 if we failed to add one.
605
 */
606
  public long rotate(Interpolator3D center, Interpolator4D angleAxis)
607
    {   
608
    return mM.add(EffectNames.ROTATE, center, angleAxis);
609
    }
610

    
611
///////////////////////////////////////////////////////////////////////////////////////////////////  
612
/**
613
 * Rotates the Object around a static point, with angle and axis that change in time.
614
 * 
615
 * @param center    Center of the rotation
616
 * @param angleAxis 4-dimensional Interpolator which at any given time will return a Float4D
617
 *                  representing the current rotation in the (angle,axisX,axisY,axisY) form.
618
 * @return          ID of the effect added, or -1 if we failed to add one.
619
 */
620
  public long rotate(Float3D center, Interpolator4D angleAxis)
621
    {   
622
    return mM.add(EffectNames.ROTATE, center , angleAxis);
623
    }
624
  
625
///////////////////////////////////////////////////////////////////////////////////////////////////  
626
/**
627
 * Rotates the Object around a static point, with angle that changes in time, around axis 
628
 * (axisX, axisY, axisZ). 
629
 * 
630
 * @param center Center of the rotation
631
 * @param angle  1-dimensional Interpolator which at any given time will return the current rotation
632
 *               angle.
633
 * @param axisX  Rotation vector: x-coordinate
634
 * @param axisY  Rotation vector: y-coordinate
635
 * @param axisZ  Rotation vector: z-coordinate
636
 * @return       ID of the effect added, or -1 if we failed to add one.
637
 */
638
  public long rotate(Float3D center, Interpolator1D angle, float axisX, float axisY, float axisZ)
639
    {   
640
    return mM.add(EffectNames.ROTATE, center , angle, axisX, axisY, axisZ);
641
    }
642
  
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
/**
645
 * Rotates the Object around a (possibly moving) point, with angle that changes in time.
646
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
647
 * 
648
 * @param center 3-dimensional Interpolator which at any given time will return the current center
649
 *               of the rotation.
650
 * @param angle  1-dimensional Interpolator which returns the current rotation angle.
651
 * @return       ID of the effect added, or -1 if we failed to add one.
652
 */
653
  public long rotate(Interpolator3D center, Interpolator1D angle)
654
    {   
655
    return mM.add(EffectNames.ROTATE, center, angle, 0.0f,0.0f,1.0f);
656
    }
657

    
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659
/**
660
 * Rotates the Object around a constant point, with angle that changes in time.  
661
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
662
 *   
663
 * @param center   Coordinates of the Point we are rotating around.
664
 * @param angle    Angle that we want to rotate the Object to. Unit: degrees
665
 * @param duration Time, in milliseconds, it takes to complete one rotation from 0 to 'angle' degrees.
666
 * @return         ID of the effect added, or -1 if we failed to add one. 
667
 */
668
  public long rotate(Float3D center, int angle, int duration)
669
    {   
670
    Interpolator1D di = new Interpolator1D();  
671
    di.setCount(0.5f);
672
    di.setDuration(duration);
673
    di.add(new Float1D(    0));
674
    di.add(new Float1D(angle));                        
675

    
676
    return mM.add(EffectNames.ROTATE, center, di, 0.0f,0.0f,1.0f);
677
    }
678

    
679
///////////////////////////////////////////////////////////////////////////////////////////////////
680
/**
681
 * Rotates the Object immediately by 'angle' degrees around point p.   
682
 * Axis of rotation is given by the last 3 floats.
683
 *   
684
 * @param center Coordinates of the Point we are rotating around.
685
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
686
 * @param axisX  Axis of rotation: x-coordinate
687
 * @param axisY  Axis of rotation: y-coordinate
688
 * @param axisZ  Axis of rotation: z-coordinate
689
 * @return       ID of the effect added, or -1 if we failed to add one.
690
 */
691
  public long rotate(Float3D center, float angle, float axisX, float axisY, float axisZ)
692
    {   
693
    return mM.add(EffectNames.ROTATE, center, angle, axisX, axisY, axisZ);
694
    }
695
  
696
///////////////////////////////////////////////////////////////////////////////////////////////////
697
/**
698
 * Rotates the Object immediately by 'angle' degrees around point p.   
699
 *   
700
 * @param center Coordinates of the Point we are rotating around.
701
 * @param angle  The angle that we want to rotate the Object to. Unit: degrees
702
 * @return       ID of the effect added, or -1 if we failed to add one. 
703
 */
704
  public long rotate(Float3D center, int angle)
705
    {   
706
    return mM.add(EffectNames.ROTATE, center, angle,0.0f,0.0f,1.0f);
707
    }
708

    
709
///////////////////////////////////////////////////////////////////////////////////////////////////
710
// QUATERNION
711
/**
712
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
713
 *   
714
 * @param center Coordinates of the Point we are rotating around.
715
 * @param qX     Quaternion: x-coordinate
716
 * @param qY     Quaternion: y-coordinate
717
 * @param qZ     Quaternion: z-coordinate
718
 * @param qW     Quaternion: w-coordinate
719
 * @return       ID of the effect added, or -1 if we failed to add one.
720
 */
721
  public long quaternion(Float3D center, float qX, float qY, float qZ, float qW)
722
    {   
723
    return mM.add(EffectNames.QUATERNION,center,qX,qY,qZ,qW);
724
    }
725

    
726
///////////////////////////////////////////////////////////////////////////////////////////////////
727
/**
728
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
729
 *   
730
 * @param center Coordinates of the Point we are rotating around.
731
 * @param quat   Interpolator that's going to, at any given moment, return a quaternion.
732
 * @return       ID of the effect added, or -1 if we failed to add one.
733
 */
734
  public long quaternion(Float3D center, InterpolatorQuat quat)
735
    {   
736
    return mM.add(EffectNames.QUATERNION, center, quat);
737
    }
738

    
739
///////////////////////////////////////////////////////////////////////////////////////////////////
740
/**
741
 * Rotates the Object around a moving point by a quaternion that's at the moment returned by the InterpolatorQuat.
742
 *   
743
 * @param center Interpolator that returns the current center of rotation.
744
 * @param quat   Interpolator that's going to, at any given moment, return a quaternion representing
745
 *               the current rotation.
746
 * @return       ID of the effect added, or -1 if we failed to add one.
747
 */
748
  public long quaternion(Interpolator3D center, InterpolatorQuat quat)
749
    {   
750
    return mM.add(EffectNames.QUATERNION,center,quat);
751
    }
752
  
753
///////////////////////////////////////////////////////////////////////////////////////////////////
754
// SHEAR
755
/**
756
 * Shears the Object. If the Interpolator is 1D, it will shear along the X-axis. 2D Interpolator adds
757
 * shearing along the Y-axis, 3D one along Z axis.
758
 *
759
 * @param center  Center of shearing, i.e. the point which stays unmoved.
760
 * @param shear   1- 2- or 3D Interpolator which, at any given point, returns the ordered 1-, 2-
761
 *                or 3-tuple of shear factors.
762
 * @return        ID of the effect added, or -1 if we failed to add one.
763
 */
764
  public long shear(Float3D center, Interpolator shear)
765
    {
766
    return mM.add(EffectNames.SHEAR, center, shear);
767
    }
768

    
769
///////////////////////////////////////////////////////////////////////////////////////////////////
770
/**
771
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
772
 * 
773
 * @param center Center of shearing, i.e. the point which stays unmoved.
774
 * @param shear  ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with
775
 *               which the X,Y and Z axis get slanted) 
776
 * @return       ID of the effect added, or -1 if we failed to add one. 
777
 */
778
  public long shear(Float3D center, Float3D shear)
779
    {
780
    Interpolator3D di = new Interpolator3D(); 
781
    di.setCount(0.5f);
782
    di.setDuration(0);
783
    di.add(new Float3D(0.0f,0.0f,0.0f));              
784
    di.add(shear);
785
        
786
    return mM.add(EffectNames.SHEAR, center, di );
787
    }
788

    
789
///////////////////////////////////////////////////////////////////////////////////////////////////
790
// Fragment-based effects  
791
///////////////////////////////////////////////////////////////////////////////////////////////////
792
// MACROBLOCK
793
/**
794
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
795
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
796
 * 
797
 * @param size   1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
798
 * @param region Region this Effect is limited to.
799
 *               Null here means 'apply the effect to the whole Object'.
800
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
801
 *               current center of the effect.
802
 * @return       ID of the effect added, or -1 if we failed to add one. 
803
 */
804
  public long macroblock(Interpolator1D size, Float4D region, Interpolator2D center)
805
    {
806
    return mF.add(EffectNames.MACROBLOCK, size, region, center);
807
    }
808

    
809
///////////////////////////////////////////////////////////////////////////////////////////////////
810
/**
811
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
812
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
813
 * <p>
814
 * The difference between this and the previous method is that here the center of the Effect stays constant.
815
 *    
816
 * @param size   1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
817
 * @param region Region this Effect is limited to. 
818
 *               Null here means 'apply the effect to the whole Object'.
819
 * @param center Center of the Effect.
820
 * @return       ID of the effect added, or -1 if we failed to add one. 
821
 */
822
  public long macroblock(Interpolator1D size, Float4D region, Float2D center)
823
    {
824
    return mF.add(EffectNames.MACROBLOCK, size, region, center);
825
    }
826
  
827
///////////////////////////////////////////////////////////////////////////////////////////////////
828
/**
829
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
830
 * <p>
831
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
832
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
833
 * size is 1X1, i.e. 1 pixel).   
834
 * 
835
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
836
 * @param region   Region this Effect is limited to. 
837
 *                 Null here means 'apply the effect to the whole Object'.
838
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D representing the
839
 *                 current center of the effect.
840
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
841
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
842
 * @return         ID of the effect added, or -1 if we failed to add one. 
843
 */
844
  public long macroblock(int pixels, Float4D region, Interpolator2D center, int duration, float count)
845
    {
846
    Interpolator1D di = new Interpolator1D();
847
    di.setCount(count);
848
    di.setDuration(duration);
849
    di.add(new Float1D(1));                             
850
    di.add(new Float1D(pixels));                        
851

    
852
    return mF.add(EffectNames.MACROBLOCK, di, region, center);
853
    }
854

    
855
///////////////////////////////////////////////////////////////////////////////////////////////////
856
/**
857
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
858
 * <p>
859
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
860
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
861
 * size is 1X1, i.e. 1 pixel).   
862
 * <p>
863
 * The difference between this and the previous method is that here the center of the Effect stays constant.
864
 *    
865
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
866
 * @param region   Region this Effect is limited to. 
867
 *                 Null here means 'apply the effect to the whole Object'.
868
 * @param center   Center of the Effect.
869
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
870
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
871
 * @return         ID of the effect added, or -1 if we failed to add one. 
872
 */
873
  public long macroblock(int pixels, Float4D region, Float2D center, int duration, float count)
874
    {
875
    Interpolator1D di = new Interpolator1D();
876
    di.setCount(count);
877
    di.setDuration(duration);
878
    di.add(new Float1D(1));                             
879
    di.add(new Float1D(pixels));                        
880

    
881
    return mF.add(EffectNames.MACROBLOCK, di, region, center);
882
    }
883

    
884
///////////////////////////////////////////////////////////////////////////////////////////////////
885
/**
886
 * Creates macroblocks on the whole Object.
887
 * <p>
888
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
889
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
890
 * size is 1X1, i.e. 1 pixel).   
891
 * <p>
892
 * The difference between this and the previous method is that here there is no masking Region; thus
893
 * there is also no center of the Effect. 
894
 *    
895
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
896
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
897
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
898
 * @return         ID of the effect added, or -1 if we failed to add one. 
899
 */
900
  public long macroblock(int pixels, int duration, float count) 
901
    {
902
    Interpolator1D di = new Interpolator1D(); 
903
    di.setCount(count);
904
    di.setDuration(duration);
905
    di.add(new Float1D(1));                            
906
    di.add(new Float1D(pixels));                        
907
   
908
    return mF.add(EffectNames.MACROBLOCK, di, null, mZero2D);
909
    }
910

    
911
///////////////////////////////////////////////////////////////////////////////////////////////////
912
///////////////////////////////////////////////////////////////////////////////////////////////////
913
// CHROMA
914
/**
915
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
916
 *        
917
 * @param blend  1-dimensional Interpolator that returns the level of blend a given pixel will be
918
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
919
 * @param color  Color to mix. (1,0,0) is RED.
920
 * @param region Region this Effect is limited to. 
921
 *               Null here means 'apply the Effect to the whole Object'.
922
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing
923
 *               the current center of the effect.
924
 * @return       ID of the effect added, or -1 if we failed to add one. 
925
 */
926
  public long chroma(Interpolator1D blend, Float3D color, Float4D region, Interpolator2D center)
927
    {
928
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
929
    }
930

    
931
///////////////////////////////////////////////////////////////////////////////////////////////////
932
/**
933
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
934
 * <p>
935
 * Here the center of the Effect stays constant.
936
 *         
937
 * @param blend  1-dimensional Interpolator that returns the level of blend a given pixel will be
938
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
939
 * @param color  Color to mix. (1,0,0) is RED.
940
 * @param region Region this Effect is limited to. 
941
 *               Null here means 'apply the Effect to the whole Object'.
942
 * @param center Center of the Effect.
943
 * @return       ID of the effect added, or -1 if we failed to add one. 
944
 */
945
  public long chroma(Interpolator1D blend, Float3D color, Float4D region, Float2D center)
946
    {
947
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
948
    }
949

    
950
///////////////////////////////////////////////////////////////////////////////////////////////////  
951
/**
952
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
953
 *        
954
 * @param blend  Level of blend a given pixel will be mixed with the next parameter 'color':
955
 *               pixel = (1-t)*pixel + t*color
956
 * @param color  Color to mix. (1,0,0) is RED.
957
 * @param region Region this Effect is limited to.
958
 *               Null here means 'apply the Effect to the whole Object'.
959
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
960
 *               current center of the effect.
961
 * @return       ID of the effect added, or -1 if we failed to add one. 
962
 */
963
  public long chroma(float blend, Float3D color, Float4D region, Interpolator2D center)
964
    {
965
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
966
    }
967

    
968
///// //////////////////////////////////////////////////////////////////////////////////////////////
969
/**
970
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
971
 * <p>
972
 * Here the center of the Effect stays constant.
973
 *         
974
 * @param blend  Level of blend a given pixel will be mixed with the next parameter 'color':
975
 *               pixel = (1-t)*pixel + t*color
976
 * @param color  Color to mix. (1,0,0) is RED.
977
 * @param region The Region this Effect is limited to. 
978
 *               Null here means 'apply the Effect to the whole Object'.
979
 * @param center Center of the Effect.
980
 * @return       ID of the effect added, or -1 if we failed to add one. 
981
 */
982
  public long chroma(float blend, Float3D color, Float4D region, Float2D center)
983
    {
984
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
985
    }
986

    
987
///////////////////////////////////////////////////////////////////////////////////////////////////
988
/**
989
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
990
 * <p>
991
 * Here the Effect applies to the whole Object.
992
 *         
993
 * @param blend Level of blend a given pixel will be mixed with the next parameter 'color':
994
 *              pixel = (1-t)*pixel + t*color
995
 * @param color Color to mix. (1,0,0) is RED.
996
 * @return      ID of the effect added, or -1 if we failed to add one. 
997
 */
998
  public long chroma(float blend, Float3D color)
999
    {
1000
    return mF.add(EffectNames.CHROMA, blend, color, null, mZero2D);
1001
    }
1002

    
1003
///////////////////////////////////////////////////////////////////////////////////////////////////  
1004
/**
1005
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1006
 * 
1007
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
1008
 */
1009
  public long smooth_chroma(Interpolator1D blend, Float3D color, Float4D region, Interpolator2D center)
1010
    {
1011
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1012
    }
1013

    
1014
///////////////////////////////////////////////////////////////////////////////////////////////////
1015
/**
1016
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1017
 * 
1018
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Float2D)}
1019
 */
1020
  public long smooth_chroma(Interpolator1D blend, Float3D color, Float4D region, Float2D center)
1021
    {
1022
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1023
    }
1024
  
1025
///////////////////////////////////////////////////////////////////////////////////////////////////  
1026
/**
1027
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1028
 * 
1029
 * See {@link #chroma(float, Float3D, Float4D, Interpolator2D)}
1030
 */
1031
  public long smooth_chroma(float blend, Float3D color, Float4D region, Interpolator2D center)
1032
    {
1033
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1034
    }
1035

    
1036
///////////////////////////////////////////////////////////////////////////////////////////////////
1037
/**
1038
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1039
 * 
1040
 * See {@link #chroma(float, Float3D, Float4D, Float2D)}
1041
 */
1042
  public long smooth_chroma(float blend, Float3D color, Float4D region, Float2D center)
1043
    {
1044
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1045
    }
1046
  
1047
///////////////////////////////////////////////////////////////////////////////////////////////////
1048
/**
1049
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1050
 * 
1051
 * See {@link #chroma(float, Float3D)}
1052
 */
1053
  public long smooth_chroma(float blend, Float3D color)
1054
    {
1055
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, null, mZero2D);
1056
    }
1057
  
1058
///////////////////////////////////////////////////////////////////////////////////////////////////
1059
///////////////////////////////////////////////////////////////////////////////////////////////////
1060
// ALPHA
1061
/**
1062
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1063
 *        
1064
 * @param alpha  1-dimensional Interpolator that returns the level of transparency we want to have at any given
1065
 *               moment.
1066
 * @param region Region this Effect is limited to. 
1067
 *               Null here means 'apply the Effect to the whole Object'.
1068
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1069
 *               current center of the effect.
1070
 * @return       ID of the effect added, or -1 if we failed to add one. 
1071
 */
1072
  public long alpha(Interpolator1D alpha, Float4D region, Interpolator2D center)
1073
    {
1074
    return mF.add(EffectNames.ALPHA, alpha, region, center);
1075
    }
1076

    
1077
///////////////////////////////////////////////////////////////////////////////////////////////////
1078
/**
1079
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1080
 * <p>
1081
 * Here the center of the Effect stays constant.
1082
 *         
1083
 * @param alpha  1-dimensional Interpolator that returns the level of transparency we want to have at any given
1084
 *               moment.
1085
 * @param region Region this Effect is limited to. 
1086
 *               Null here means 'apply the Effect to the whole Object'.
1087
 * @param center Center of the Effect.
1088
 * @return       ID of the effect added, or -1 if we failed to add one. 
1089
 */
1090
  public long alpha(Interpolator1D alpha, Float4D region, Float2D center)
1091
    {
1092
    return mF.add(EffectNames.ALPHA, alpha, region, center);
1093
    }
1094

    
1095
///////////////////////////////////////////////////////////////////////////////////////////////////  
1096
/**
1097
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1098
 *        
1099
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1100
 * @param region Region this Effect is limited to. 
1101
 *               Null here means 'apply the Effect to the whole Object'.
1102
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1103
 *               current center of the effect.
1104
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1105
 * @param count  Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1106
 * @return       ID of the effect added, or -1 if we failed to add one. 
1107
 */
1108
  public long alpha(float alpha, Float4D region, Interpolator2D center, int duration, float count)
1109
    {
1110
    Interpolator1D di = new Interpolator1D(); 
1111
    di.setCount(count);
1112
    di.setDuration(duration);
1113
    di.add(new Float1D(1));                          
1114
    di.add(new Float1D(alpha));                         
1115
   
1116
    return mF.add(EffectNames.ALPHA, di, region, center);
1117
    }
1118

    
1119
///////////////////////////////////////////////////////////////////////////////////////////////////
1120
/**
1121
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1122
 * <p>
1123
 * Here the center of the Effect stays constant.
1124
 *         
1125
 * @param alpha    Level of Alpha (between 0 and 1) we want to interpolate to.
1126
 * @param region   Region this Effect is limited to.
1127
 *                 Null here means 'apply the Effect to the whole Object'.
1128
 * @param center   Center of the Effect.
1129
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1130
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1131
 * @return         ID of the effect added, or -1 if we failed to add one.
1132
 */
1133
  public long alpha(float alpha, Float4D region, Float2D center, int duration, float count)
1134
    {
1135
    Interpolator1D di = new Interpolator1D(); 
1136
    di.setCount(count);
1137
    di.setDuration(duration);
1138
    di.add(new Float1D(1));                          
1139
    di.add(new Float1D(alpha));                         
1140
   
1141
    return mF.add(EffectNames.ALPHA, di, region, center);
1142
    }
1143

    
1144
///////////////////////////////////////////////////////////////////////////////////////////////////
1145
/**
1146
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1147
 * <p>
1148
 * Here the center of the Effect stays constant and the effect for now change in time.
1149
 *         
1150
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1151
 * @param region Region this Effect is limited to.
1152
 *               Null here means 'apply the Effect to the whole Object'.
1153
 * @param center Center of the Effect.
1154
 * @return       ID of the effect added, or -1 if we failed to add one. 
1155
 */
1156
  public long alpha(float alpha, Float4D region, Float2D center)
1157
    {
1158
    Interpolator1D di = new Interpolator1D(); 
1159
    di.setCount(0.5f);
1160
    di.setDuration(0);
1161
    di.add(new Float1D(1));                          
1162
    di.add(new Float1D(alpha));                         
1163
   
1164
    return mF.add(EffectNames.ALPHA, di, region, center);
1165
    }
1166
  
1167
///////////////////////////////////////////////////////////////////////////////////////////////////
1168
/**
1169
 * Makes the whole Object change its transparency level.
1170
 * 
1171
 * @param alpha    Level of Alpha (between 0 and 1) we want to interpolate to.
1172
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1173
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1174
 * @return         ID of the effect added, or -1 if we failed to add one. 
1175
 */
1176
  public long alpha(float alpha, int duration, float count) 
1177
    {
1178
    Interpolator1D di = new Interpolator1D(); 
1179
    di.setCount(count);
1180
    di.setDuration(duration);
1181
    di.add(new Float1D(1));                            
1182
    di.add(new Float1D(alpha));                        
1183
         
1184
    return mF.add(EffectNames.ALPHA, di,null, mZero2D);
1185
    }
1186

    
1187
///////////////////////////////////////////////////////////////////////////////////////////////////  
1188
/**
1189
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1190
 * 
1191
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1192
 */
1193
  public long smooth_alpha(Interpolator1D alpha, Float4D region, Interpolator2D center)
1194
    {
1195
    return mF.add(EffectNames.SMOOTH_ALPHA, alpha, region, center);
1196
    }
1197

    
1198
///////////////////////////////////////////////////////////////////////////////////////////////////
1199
/**
1200
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1201
 * 
1202
 * See {@link #alpha(Interpolator1D, Float4D, Float2D)}
1203
 */
1204
  public long smooth_alpha(Interpolator1D alpha, Float4D region, Float2D center)
1205
    {
1206
    return mF.add(EffectNames.SMOOTH_ALPHA, alpha, region, center);
1207
    }
1208
  
1209
///////////////////////////////////////////////////////////////////////////////////////////////////  
1210
/**
1211
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1212
 * 
1213
 * See {@link #alpha(float, Float4D, Interpolator2D, int, float)}
1214
 */
1215
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D center, int duration, float count)
1216
    {
1217
    Interpolator1D di = new Interpolator1D(); 
1218
    di.setCount(count);
1219
    di.setDuration(duration);
1220
    di.add(new Float1D(1));                          
1221
    di.add(new Float1D(alpha));                         
1222
   
1223
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, center);
1224
    }
1225

    
1226
///////////////////////////////////////////////////////////////////////////////////////////////////
1227
/**
1228
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1229
 * 
1230
 * See {@link #alpha(float, Float4D, Float2D, int, float)}
1231
 */
1232
  public long smooth_alpha(float alpha, Float4D region, Float2D center, int duration, float count)
1233
    {
1234
    Interpolator1D di = new Interpolator1D(); 
1235
    di.setCount(count);
1236
    di.setDuration(duration);
1237
    di.add(new Float1D(1));                          
1238
    di.add(new Float1D(alpha));                         
1239
   
1240
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, center);
1241
    }
1242
  
1243
///////////////////////////////////////////////////////////////////////////////////////////////////
1244
/**
1245
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1246
 * 
1247
 * See {@link #alpha(float, Float4D, Float2D)}
1248
 */
1249
  public long smooth_alpha(float alpha, Float4D region, Float2D center)
1250
    {
1251
    Interpolator1D di = new Interpolator1D(); 
1252
    di.setCount(0.5f);
1253
    di.setDuration(0);
1254
    di.add(new Float1D(1));                          
1255
    di.add(new Float1D(alpha));                         
1256
   
1257
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, center);
1258
    }
1259
  
1260
///////////////////////////////////////////////////////////////////////////////////////////////////
1261
///////////////////////////////////////////////////////////////////////////////////////////////////
1262
// BRIGHTNESS
1263
/**
1264
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1265
 *        
1266
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1267
 *                   at any given moment.
1268
 * @param region     Region this Effect is limited to.
1269
 *                   Null here means 'apply the Effect to the whole Object'.
1270
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D representing
1271
 *                   the current center of the effect.
1272
 * @return           ID of the effect added, or -1 if we failed to add one.
1273
 */
1274
  public long brightness(Interpolator1D brightness, Float4D region, Interpolator2D center)
1275
    {
1276
    return mF.add(EffectNames.BRIGHTNESS, brightness, region, center);
1277
    }
1278

    
1279
///////////////////////////////////////////////////////////////////////////////////////////////////
1280
/**
1281
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1282
 * <p>
1283
 * Here the center of the Effect stays constant.
1284
 *         
1285
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1286
 *                   at any given moment.
1287
 * @param region     Region this Effect is limited to.
1288
 *                   Null here means 'apply the Effect to the whole Object'.
1289
 * @param center     Center of the Effect.
1290
 * @return           ID of the effect added, or -1 if we failed to add one.
1291
 */
1292
  public long brightness(Interpolator1D brightness, Float4D region, Float2D center)
1293
    {
1294
    return mF.add(EffectNames.BRIGHTNESS, brightness, region, center);
1295
    }
1296

    
1297
///////////////////////////////////////////////////////////////////////////////////////////////////  
1298
/**
1299
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1300
 *        
1301
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1302
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1303
 *                   anything more than 1- lighten it up. 
1304
 * @param region     Region this Effect is limited to.
1305
 *                   Null here means 'apply the Effect to the whole Object'.
1306
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1307
 *                   representing the current center of the effect.
1308
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1309
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1310
 * @return           ID of the effect added, or -1 if we failed to add one. 
1311
 */
1312
  public long brightness(float brightness, Float4D region, Interpolator2D center, int duration, float count)
1313
    {
1314
    Interpolator1D di = new Interpolator1D(); 
1315
    di.setCount(count);
1316
    di.setDuration(duration);
1317
    di.add(new Float1D(1));                          
1318
    di.add(new Float1D(brightness));                         
1319
   
1320
    return mF.add(EffectNames.BRIGHTNESS, di, region, center);
1321
    }
1322

    
1323
///////////////////////////////////////////////////////////////////////////////////////////////////
1324
/**
1325
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1326
 * <p>
1327
 * Here the center of the Effect stays constant.
1328
 *         
1329
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1330
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1331
 *                   anything more than 1 - lighten it up.
1332
 * @param region     Region this Effect is limited to. 
1333
 *                   Null here means 'apply the Effect to the whole Object'.
1334
 * @param center     Center of the Effect.
1335
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1336
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1337
 * @return           ID of the effect added, or -1 if we failed to add one. 
1338
 */
1339
  public long brightness(float brightness, Float4D region, Float2D center, int duration, float count)
1340
    {
1341
    Interpolator1D di = new Interpolator1D(); 
1342
    di.setCount(count);
1343
    di.setDuration(duration);
1344
    di.add(new Float1D(1));                          
1345
    di.add(new Float1D(brightness));                         
1346
   
1347
    return mF.add(EffectNames.BRIGHTNESS, di, region, center);
1348
    }
1349

    
1350
///////////////////////////////////////////////////////////////////////////////////////////////////
1351
/**
1352
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1353
 * <p>
1354
 * Here the center of the Effect stays constant and the effect for now change in time.
1355
 *         
1356
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1357
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1358
 *                   anything more than 1 - lighten it up.
1359
 * @param region     Region this Effect is limited to.
1360
 *                   Null here means 'apply the Effect to the whole Object'.
1361
 * @param center     Center of the Effect.
1362
 * @return           ID of the effect added, or -1 if we failed to add one. 
1363
 */
1364
  public long brightness(float brightness, Float4D region, Float2D center)
1365
    {
1366
    Interpolator1D di = new Interpolator1D(); 
1367
    di.setCount(0.5f);
1368
    di.setDuration(0);
1369
    di.add(new Float1D(1));                          
1370
    di.add(new Float1D(brightness));                         
1371
   
1372
    return mF.add(EffectNames.BRIGHTNESS, di, region, center);
1373
    }
1374
 
1375
///////////////////////////////////////////////////////////////////////////////////////////////////
1376
///////////////////////////////////////////////////////////////////////////////////////////////////
1377
// SMOOTH BRIGHTNESS
1378
/**
1379
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1380
 *        
1381
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1382
 *                   at any given moment.
1383
 * @param region     Region this Effect is limited to.
1384
 *                   Null here means 'apply the Effect to the whole Object'.
1385
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1386
 *                   representing the current center of the effect.
1387
 * @return           ID of the effect added, or -1 if we failed to add one.
1388
 */
1389
  public long smooth_brightness(Interpolator1D brightness, Float4D region, Interpolator2D center)
1390
    {
1391
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, brightness, region, center);
1392
    }
1393

    
1394
///////////////////////////////////////////////////////////////////////////////////////////////////
1395
/**
1396
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1397
 * <p>
1398
 * Here the center of the Effect stays constant.
1399
 *         
1400
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1401
 *                   at any given moment.
1402
 * @param region     Region this Effect is limited to.
1403
 *                   Null here means 'apply the Effect to the whole Object'.
1404
 * @param center     Center of the Effect.
1405
 * @return           ID of the effect added, or -1 if we failed to add one.
1406
 */
1407
  public long smooth_brightness(Interpolator1D brightness, Float4D region, Float2D center)
1408
    {
1409
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, brightness, region, center);
1410
    }
1411

    
1412
///////////////////////////////////////////////////////////////////////////////////////////////////  
1413
/**
1414
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1415
 *        
1416
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1417
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1418
 *                   anything more than 1 - lighten it up. 
1419
 * @param region     Region this Effect is limited to. 
1420
 *                   Null here means 'apply the Effect to the whole Object'.
1421
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1422
 *                   represention the current center of the effect.
1423
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1424
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1425
 * @return           ID of the effect added, or -1 if we failed to add one. 
1426
 */
1427
  public long smooth_brightness(float brightness, Float4D region, Interpolator2D center, int duration, float count)
1428
    {
1429
    Interpolator1D di = new Interpolator1D(); 
1430
    di.setCount(count);
1431
    di.setDuration(duration);
1432
    di.add(new Float1D(1));                          
1433
    di.add(new Float1D(brightness));                         
1434
   
1435
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, center);
1436
    }
1437

    
1438
///////////////////////////////////////////////////////////////////////////////////////////////////
1439
/**
1440
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1441
 * <p>
1442
 * Here the center of the Effect stays constant.
1443
 *         
1444
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1445
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1446
 *                   anything more than 1 - lighten it up.
1447
 * @param region     Region this Effect is limited to. 
1448
 *                   Null here means 'apply the Effect to the whole Object'.
1449
 * @param center     Center of the Effect.
1450
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1451
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1452
 * @return           ID of the effect added, or -1 if we failed to add one. 
1453
 */
1454
  public long smooth_brightness(float brightness, Float4D region, Float2D center, int duration, float count)
1455
    {
1456
    Interpolator1D di = new Interpolator1D(); 
1457
    di.setCount(count);
1458
    di.setDuration(duration);
1459
    di.add(new Float1D(1));                          
1460
    di.add(new Float1D(brightness));                         
1461
   
1462
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, center);
1463
    }
1464

    
1465
///////////////////////////////////////////////////////////////////////////////////////////////////
1466
/**
1467
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1468
 * <p>
1469
 * Here the center of the Effect stays constant and the effect for now change in time.
1470
 *         
1471
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1472
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1473
 *                   anything more than 1 - lighten it up.
1474
 * @param region     Region this Effect is limited to. 
1475
 *                   Null here means 'apply the Effect to the whole Object'.
1476
 * @param center     Center of the Effect.
1477
 * @return           ID of the effect added, or -1 if we failed to add one. 
1478
 */
1479
  public long smooth_brightness(float brightness, Float4D region, Float2D center)
1480
    {
1481
    Interpolator1D di = new Interpolator1D(); 
1482
    di.setCount(0.5f);
1483
    di.setDuration(0);
1484
    di.add(new Float1D(1));                          
1485
    di.add(new Float1D(brightness));                         
1486
   
1487
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, center);
1488
    }
1489
    
1490
///////////////////////////////////////////////////////////////////////////////////////////////////
1491
/**
1492
 * Makes the whole Object change its brightness level.
1493
 * 
1494
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1495
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1496
 *                   anything more than 1- lighten it up.
1497
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1498
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1499
 * @return           ID of the effect added, or -1 if we failed to add one. 
1500
 */
1501
  public long smooth_brightness(float brightness, int duration, float count) 
1502
    {
1503
    Interpolator1D di = new Interpolator1D(); 
1504
    di.setCount(count);
1505
    di.setDuration(duration);
1506
    di.add(new Float1D(1));                            
1507
    di.add(new Float1D(brightness));                        
1508
         
1509
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di,null, mZero2D);
1510
    }
1511

    
1512
///////////////////////////////////////////////////////////////////////////////////////////////////
1513
///////////////////////////////////////////////////////////////////////////////////////////////////
1514
// CONTRAST
1515
/**
1516
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1517
 *        
1518
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1519
 *                 at any given moment.
1520
 * @param region   Region this Effect is limited to.
1521
 *                 Null here means 'apply the Effect to the whole Object'.
1522
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D
1523
 *                 representing the current center of the effect.
1524
 * @return         ID of the effect added, or -1 if we failed to add one.
1525
 */
1526
  public long contrast(Interpolator1D contrast, Float4D region, Interpolator2D center)
1527
    {
1528
    return mF.add(EffectNames.CONTRAST, contrast, region, center);
1529
    }
1530

    
1531
///////////////////////////////////////////////////////////////////////////////////////////////////
1532
/**
1533
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1534
 * <p>
1535
 * Here the center of the Effect stays constant.
1536
 *         
1537
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1538
 *                 at any given moment.
1539
 * @param region   Region this Effect is limited to.
1540
 *                 Null here means 'apply the Effect to the whole Object'.
1541
 * @param center  Center of the Effect.
1542
 * @return        ID of the effect added, or -1 if we failed to add one.
1543
 */
1544
  public long contrast(Interpolator1D contrast, Float4D region, Float2D center)
1545
    {
1546
    return mF.add(EffectNames.CONTRAST, contrast, region, center);
1547
    }
1548

    
1549
///////////////////////////////////////////////////////////////////////////////////////////////////  
1550
/**
1551
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1552
 *        
1553
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1554
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1555
 *                 anything more than 1 - increase the contrast. 
1556
 * @param region   Region this Effect is limited to.
1557
 *                 Null here means 'apply the Effect to the whole Object'.
1558
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D
1559
 *                 represention the current center of the effect.
1560
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1561
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1562
 * @return         ID of the effect added, or -1 if we failed to add one. 
1563
 */
1564
  public long contrast(float contrast, Float4D region, Interpolator2D center, int duration, float count)
1565
    {
1566
    Interpolator1D di = new Interpolator1D(); 
1567
    di.setCount(count);
1568
    di.setDuration(duration);
1569
    di.add(new Float1D(1));                          
1570
    di.add(new Float1D(contrast));                         
1571
   
1572
    return mF.add(EffectNames.CONTRAST, di, region, center);
1573
    }
1574

    
1575
///////////////////////////////////////////////////////////////////////////////////////////////////
1576
/**
1577
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1578
 * <p>
1579
 * Here the center of the Effect stays constant.
1580
 *         
1581
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1582
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1583
 *                 anything more than 1 -increase the contrast. 
1584
 * @param region   Region this Effect is limited to. 
1585
 *                 Null here means 'apply the Effect to the whole Object'.
1586
 * @param center   Center of the Effect.
1587
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1588
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1589
 * @return         ID of the effect added, or -1 if we failed to add one. 
1590
 */
1591
  public long contrast(float contrast, Float4D region, Float2D center, int duration, float count)
1592
    {
1593
    Interpolator1D di = new Interpolator1D(); 
1594
    di.setCount(count);
1595
    di.setDuration(duration);
1596
    di.add(new Float1D(1));                          
1597
    di.add(new Float1D(contrast));                         
1598
   
1599
    return mF.add(EffectNames.CONTRAST, di, region, center);
1600
    }
1601

    
1602
///////////////////////////////////////////////////////////////////////////////////////////////////
1603
/**
1604
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1605
 * <p>
1606
 * Here the center of the Effect stays constant and the effect for now change in time.
1607
 *         
1608
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1609
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1610
 *                 anything more than 1 - increase the contrast. 
1611
 * @param region   Region this Effect is limited to. 
1612
 *                 Null here means 'apply the Effect to the whole Object'.
1613
 * @param center   Center of the Effect.
1614
 * @return         ID of the effect added, or -1 if we failed to add one. 
1615
 */
1616
  public long contrast(float contrast, Float4D region, Float2D center)
1617
    {
1618
    Interpolator1D di = new Interpolator1D(); 
1619
    di.setCount(0.5f);
1620
    di.setDuration(0);
1621
    di.add(new Float1D(1));                          
1622
    di.add(new Float1D(contrast));                         
1623
   
1624
    return mF.add(EffectNames.CONTRAST, di, region, center);
1625
    }
1626
 
1627
///////////////////////////////////////////////////////////////////////////////////////////////////
1628
///////////////////////////////////////////////////////////////////////////////////////////////////
1629
// SMOOTH CONTRAST
1630
/**
1631
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1632
 *        
1633
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1634
 *                 at any given moment.
1635
 * @param region   Region this Effect is limited to.
1636
 *                 Null here means 'apply the Effect to the whole Object'.
1637
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D
1638
 *                 representing the current center of the effect.
1639
 * @return         ID of the effect added, or -1 if we failed to add one.
1640
 */
1641
  public long smooth_contrast(Interpolator1D contrast, Float4D region, Interpolator2D center)
1642
    {
1643
    return mF.add(EffectNames.SMOOTH_CONTRAST, contrast, region, center);
1644
    }
1645

    
1646
///////////////////////////////////////////////////////////////////////////////////////////////////
1647
/**
1648
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1649
 * <p>
1650
 * Here the center of the Effect stays constant.
1651
 *         
1652
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1653
 *                 at any given moment.
1654
 * @param region   Region this Effect is limited to.
1655
 *                 Null here means 'apply the Effect to the whole Object'.
1656
 * @param center   Center of the Effect.
1657
 * @return         ID of the effect added, or -1 if we failed to add one.
1658
 */
1659
  public long smooth_contrast(Interpolator1D contrast, Float4D region, Float2D center)
1660
    {
1661
    return mF.add(EffectNames.SMOOTH_CONTRAST, contrast, region, center);
1662
    }
1663

    
1664
///////////////////////////////////////////////////////////////////////////////////////////////////  
1665
/**
1666
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1667
 *        
1668
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1669
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1670
 *                 anything more than 1 - increase the contrast. 
1671
 * @param region   Region this Effect is limited to. 
1672
 *                 Null here means 'apply the Effect to the whole Object'.
1673
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D
1674
 *                 representing the current center of the effect.
1675
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1676
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1677
 * @return         ID of the effect added, or -1 if we failed to add one. 
1678
 */
1679
  public long smooth_contrast(float contrast, Float4D region, Interpolator2D center, int duration, float count)
1680
    {
1681
    Interpolator1D di = new Interpolator1D(); 
1682
    di.setCount(count);
1683
    di.setDuration(duration);
1684
    di.add(new Float1D(1));                          
1685
    di.add(new Float1D(contrast));                         
1686
   
1687
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, center);
1688
    }
1689

    
1690
///////////////////////////////////////////////////////////////////////////////////////////////////
1691
/**
1692
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1693
 * <p>
1694
 * Here the center of the Effect stays constant.
1695
 *         
1696
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1697
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1698
 *                 anything more than 1 - increase the contrast. 
1699
 * @param region   Region this Effect is limited to. 
1700
 *                 Null here means 'apply the Effect to the whole Object'.
1701
 * @param center   Center of the Effect.
1702
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1703
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1704
 * @return         ID of the effect added, or -1 if we failed to add one. 
1705
 */
1706
  public long smooth_contrast(float contrast, Float4D region, Float2D center, int duration, float count)
1707
    {
1708
    Interpolator1D di = new Interpolator1D(); 
1709
    di.setCount(count);
1710
    di.setDuration(duration);
1711
    di.add(new Float1D(1));                          
1712
    di.add(new Float1D(contrast));                         
1713
   
1714
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, center);
1715
    }
1716

    
1717
///////////////////////////////////////////////////////////////////////////////////////////////////
1718
/**
1719
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1720
 * <p>
1721
 * Here the center of the Effect stays constant and the effect for now change in time.
1722
 *         
1723
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1724
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1725
 *                 anything more than 1 - increase the contrast. 
1726
 * @param region   Region this Effect is limited to. 
1727
 *                 Null here means 'apply the Effect to the whole Object'.
1728
 * @param center   Center of the Effect.
1729
 * @return         ID of the effect added, or -1 if we failed to add one. 
1730
 */
1731
  public long smooth_contrast(float contrast, Float4D region, Float2D center)
1732
    {
1733
    Interpolator1D di = new Interpolator1D(); 
1734
    di.setCount(0.5f);
1735
    di.setDuration(0);
1736
    di.add(new Float1D(1));                          
1737
    di.add(new Float1D(contrast));                         
1738
   
1739
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, center);
1740
    }
1741
    
1742
///////////////////////////////////////////////////////////////////////////////////////////////////
1743
/**
1744
 * Makes the whole Object change its contrast level.
1745
 * 
1746
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1747
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1748
 *                 anything more than 1 - increase the contrast.
1749
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1750
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1751
 * @return         ID of the effect added, or -1 if we failed to add one. 
1752
 */
1753
  public long smooth_contrast(float contrast, int duration, float count) 
1754
    {
1755
    Interpolator1D di = new Interpolator1D(); 
1756
    di.setCount(count);
1757
    di.setDuration(duration);
1758
    di.add(new Float1D(1));                            
1759
    di.add(new Float1D(contrast));                        
1760
         
1761
    return mF.add(EffectNames.SMOOTH_CONTRAST, di,null, mZero2D);
1762
    }
1763

    
1764

    
1765
///////////////////////////////////////////////////////////////////////////////////////////////////
1766
///////////////////////////////////////////////////////////////////////////////////////////////////
1767
// SATURATION
1768
/**
1769
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1770
 *        
1771
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1772
 *                   at any given moment.
1773
 * @param region     Region this Effect is limited to.
1774
 *                   Null here means 'apply the Effect to the whole Object'.
1775
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1776
 *                   representing the current center of the effect.
1777
 * @return           ID of the effect added, or -1 if we failed to add one.
1778
 */
1779
  public long saturation(Interpolator1D saturation, Float4D region, Interpolator2D center)
1780
    {
1781
    return mF.add(EffectNames.SATURATION, saturation, region, center);
1782
    }
1783

    
1784
///////////////////////////////////////////////////////////////////////////////////////////////////
1785
/**
1786
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1787
 * <p>
1788
 * Here the center of the Effect stays constant.
1789
 *         
1790
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1791
 *                   at any given moment.
1792
 * @param region     Region this Effect is limited to.
1793
 *                   Null here means 'apply the Effect to the whole Object'.
1794
 * @param center     Center of the Effect.
1795
 * @return           ID of the effect added, or -1 if we failed to add one.
1796
 */
1797
  public long saturation(Interpolator1D saturation, Float4D region, Float2D center)
1798
    {
1799
    return mF.add(EffectNames.SATURATION, saturation, region, center);
1800
    }
1801

    
1802
///////////////////////////////////////////////////////////////////////////////////////////////////  
1803
/**
1804
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1805
 *        
1806
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1807
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1808
 *                   anything more than 1 - increase the saturation. 
1809
 * @param region     Region this Effect is limited to.
1810
 *                   Null here means 'apply the Effect to the whole Object'.
1811
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1812
 *                   representing the current center of the effect.
1813
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1814
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1815
 * @return           ID of the effect added, or -1 if we failed to add one. 
1816
 */
1817
  public long saturation(float saturation, Float4D region, Interpolator2D center, int duration, float count)
1818
    {
1819
    Interpolator1D di = new Interpolator1D(); 
1820
    di.setCount(count);
1821
    di.setDuration(duration);
1822
    di.add(new Float1D(1));                          
1823
    di.add(new Float1D(saturation));                         
1824
   
1825
    return mF.add(EffectNames.SATURATION, di, region, center);
1826
    }
1827

    
1828
///////////////////////////////////////////////////////////////////////////////////////////////////
1829
/**
1830
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1831
 * <p>
1832
 * Here the center of the Effect stays constant.
1833
 *         
1834
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1835
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1836
 *                   anything more than 1 - increase the saturation. 
1837
 * @param region     Region this Effect is limited to. 
1838
 *                   Null here means 'apply the Effect to the whole Object'.
1839
 * @param center     Center of the Effect.
1840
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1841
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1842
 * @return           ID of the effect added, or -1 if we failed to add one. 
1843
 */
1844
  public long saturation(float saturation, Float4D region, Float2D center, int duration, float count)
1845
    {
1846
    Interpolator1D di = new Interpolator1D(); 
1847
    di.setCount(count);
1848
    di.setDuration(duration);
1849
    di.add(new Float1D(1));                          
1850
    di.add(new Float1D(saturation));                         
1851
   
1852
    return mF.add(EffectNames.SATURATION, di, region, center);
1853
    }
1854

    
1855
///////////////////////////////////////////////////////////////////////////////////////////////////
1856
/**
1857
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1858
 * <p>
1859
 * Here the center of the Effect stays constant and the effect for now change in time.
1860
 *         
1861
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1862
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1863
 *                   anything more than 1- increase the saturation. 
1864
 * @param region     Region this Effect is limited to. 
1865
 *                   Null here means 'apply the Effect to the whole Object'.
1866
 * @param center     Center of the Effect.
1867
 * @return           ID of the effect added, or -1 if we failed to add one. 
1868
 */
1869
  public long saturation(float saturation, Float4D region, Float2D center)
1870
    {
1871
    Interpolator1D di = new Interpolator1D(); 
1872
    di.setCount(0.5f);
1873
    di.setDuration(0);
1874
    di.add(new Float1D(1));                          
1875
    di.add(new Float1D(saturation));                         
1876
   
1877
    return mF.add(EffectNames.SATURATION, di, region, center);
1878
    }
1879
 
1880
///////////////////////////////////////////////////////////////////////////////////////////////////
1881
///////////////////////////////////////////////////////////////////////////////////////////////////
1882
// SMOOTH_SATURATION
1883
/**
1884
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1885
 *        
1886
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1887
 *                   at any given moment.
1888
 * @param region     Region this Effect is limited to.
1889
 *                   Null here means 'apply the Effect to the whole Object'.
1890
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1891
 *                   representing the current center of the effect.
1892
 * @return           ID of the effect added, or -1 if we failed to add one.
1893
 */
1894
  public long smooth_saturation(Interpolator1D saturation, Float4D region, Interpolator2D center)
1895
    {
1896
    return mF.add(EffectNames.SMOOTH_SATURATION, saturation, region, center);
1897
    }
1898

    
1899
///////////////////////////////////////////////////////////////////////////////////////////////////
1900
/**
1901
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1902
 * <p>
1903
 * Here the center of the Effect stays constant.
1904
 *         
1905
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1906
 *                   at any given moment.
1907
 * @param region     Region this Effect is limited to.
1908
 *                   Null here means 'apply the Effect to the whole Object'.
1909
 * @param center     Center of the Effect.
1910
 * @return           ID of the effect added, or -1 if we failed to add one.
1911
 */
1912
  public long smooth_saturation(Interpolator1D saturation, Float4D region, Float2D center)
1913
    {
1914
    return mF.add(EffectNames.SMOOTH_SATURATION, saturation, region, center);
1915
    }
1916

    
1917
///////////////////////////////////////////////////////////////////////////////////////////////////  
1918
/**
1919
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1920
 *        
1921
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1922
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1923
 *                   anything more than 1 -increase the saturation. 
1924
 * @param region     Region this Effect is limited to. 
1925
 *                   Null here means 'apply the Effect to the whole Object'.
1926
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1927
 *                   representing the current center of the effect.
1928
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1929
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1930
 * @return           ID of the effect added, or -1 if we failed to add one. 
1931
 */
1932
  public long smooth_saturation(float saturation, Float4D region, Interpolator2D center, int duration, float count)
1933
    {
1934
    Interpolator1D di = new Interpolator1D(); 
1935
    di.setCount(count);
1936
    di.setDuration(duration);
1937
    di.add(new Float1D(1));                          
1938
    di.add(new Float1D(saturation));                         
1939
   
1940
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, center);
1941
    }
1942

    
1943
///////////////////////////////////////////////////////////////////////////////////////////////////
1944
/**
1945
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1946
 * <p>
1947
 * Here the center of the Effect stays constant.
1948
 *         
1949
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1950
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1951
 *                   anything more than 1 - increase the saturation. 
1952
 * @param region     Region this Effect is limited to. 
1953
 *                   Null here means 'apply the Effect to the whole Object'.
1954
 * @param center     Center of the Effect.
1955
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1956
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1957
 * @return           ID of the effect added, or -1 if we failed to add one. 
1958
 */
1959
  public long smooth_saturation(float saturation, Float4D region, Float2D center, int duration, float count)
1960
    {
1961
    Interpolator1D di = new Interpolator1D(); 
1962
    di.setCount(count);
1963
    di.setDuration(duration);
1964
    di.add(new Float1D(1));                          
1965
    di.add(new Float1D(saturation));                         
1966
   
1967
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, center);
1968
    }
1969

    
1970
///////////////////////////////////////////////////////////////////////////////////////////////////
1971
/**
1972
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1973
 * <p>
1974
 * Here the center of the Effect stays constant and the effect for now change in time.
1975
 *         
1976
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1977
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1978
 *                   anything more than 1 - increase the saturation. 
1979
 * @param region     Region this Effect is limited to. 
1980
 *                   Null here means 'apply the Effect to the whole Object'.
1981
 * @param center     Center of the Effect.
1982
 * @return           ID of the effect added, or -1 if we failed to add one. 
1983
 */
1984
  public long smooth_saturation(float saturation, Float4D region, Float2D center)
1985
    {
1986
    Interpolator1D di = new Interpolator1D(); 
1987
    di.setCount(0.5f);
1988
    di.setDuration(0);
1989
    di.add(new Float1D(1));                          
1990
    di.add(new Float1D(saturation));                         
1991
   
1992
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, center);
1993
    }
1994
    
1995
///////////////////////////////////////////////////////////////////////////////////////////////////
1996
/**
1997
 * Makes the whole Object change its saturation level.
1998
 * 
1999
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
2000
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
2001
 *                   anything more than 1 - increase the saturation. 
2002
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
2003
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2004
 * @return           ID of the effect added, or -1 if we failed to add one. 
2005
 */
2006
  public long smooth_saturation(float saturation, int duration, float count) 
2007
    {
2008
    Interpolator1D di = new Interpolator1D(); 
2009
    di.setCount(count);
2010
    di.setDuration(duration);
2011
    di.add(new Float1D(1));                            
2012
    di.add(new Float1D(saturation));                        
2013
         
2014
    return mF.add(EffectNames.SMOOTH_SATURATION, di,null, mZero2D);
2015
    }
2016
            
2017
///////////////////////////////////////////////////////////////////////////////////////////////////
2018
// Vertex-based effects  
2019
///////////////////////////////////////////////////////////////////////////////////////////////////
2020
// DISTORT
2021
/**
2022
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
2023
 * 
2024
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2025
 *               represents the vector the Center of the Effect is currently being dragged with.
2026
 * @param region Region that masks the effect of the Distortion.
2027
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2028
 *               the Center of the Effect.
2029
 * @return       ID of the effect added, or -1 if we failed to add one. 
2030
 */
2031
  public long distort(Interpolator vector, Float4D region, Interpolator2D center)
2032
    {  
2033
    return mV.add(EffectNames.DISTORT, vector, region, center);
2034
    }
2035

    
2036
///////////////////////////////////////////////////////////////////////////////////////////////////
2037
/**
2038
 * Distort part of the Object by a (possibly changing in time) vector of force.
2039
 * <p>
2040
 * Difference between this and the previous method is that here the center of the Effect stays constant.
2041
 *   
2042
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2043
 *               represents the vector the Center of the Effect is currently being dragged with.
2044
 * @param region Region that masks the effect of the Distortion.
2045
 * @param center Center of the Effect.
2046
 * @return       ID of the effect added, or -1 if we failed to add one. 
2047
 */
2048
  public long distort(Interpolator vector, Float4D region, Float2D center)
2049
    {  
2050
    return mV.add(EffectNames.DISTORT, vector, region, center);
2051
    }
2052

    
2053
///////////////////////////////////////////////////////////////////////////////////////////////////
2054
/**
2055
 * Distort the whole Object by a (possibly changing in time) vector of force.
2056
 * 
2057
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2058
 *               represents the vector the Center of the Effect is currently being dragged with.
2059
 * @param center Center of the Effect.
2060
 * @return       ID of the effect added, or -1 if we failed to add one.
2061
 */
2062
  public long distort(Interpolator vector, Float2D center)
2063
    {
2064
    return mV.add(EffectNames.DISTORT, vector, null, center);
2065
    }
2066

    
2067
///////////////////////////////////////////////////////////////////////////////////////////////////
2068
/**
2069
 * Distort part of the Object by a vector of force that changes from (0,0,0) to v.
2070
 * 
2071
 * @param vector   Maximum vector of force. 
2072
 * @param region   Region that masks the effect of the Distortion.
2073
 * @param center   Center of the Effect.
2074
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2075
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2076
 * @return         ID of the effect added, or -1 if we failed to add one. 
2077
 */
2078
  public long distort(Float3D vector, Float4D region, Float2D center, int duration, float count)
2079
    {  
2080
    Interpolator3D di = new Interpolator3D(); 
2081
    di.setCount(count);
2082
    di.setDuration(duration);
2083
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2084
    di.add(vector);                                                  
2085
           
2086
    return mV.add(EffectNames.DISTORT, di, region, center);
2087
    }
2088

    
2089
///////////////////////////////////////////////////////////////////////////////////////////////////
2090
/**
2091
 * Distort the whole Object by a vector of force that changes from (0,0,0) to v.
2092
 * 
2093
 * @param vector   Maximum vector of force.
2094
 * @param center   Center of the Effect.
2095
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2096
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2097
 * @return         ID of the effect added, or -1 if we failed to add one. 
2098
 */
2099
  public long distort(Float3D vector, Float2D center, int duration, float count)
2100
    {
2101
    Interpolator3D di = new Interpolator3D(); 
2102
    di.setCount(count);
2103
    di.setDuration(duration);
2104
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2105
    di.add(vector);                                                 
2106
           
2107
    return mV.add(EffectNames.DISTORT, di, null, center);
2108
    }
2109

    
2110
///////////////////////////////////////////////////////////////////////////////////////////////////
2111
/**
2112
 * Distort the whole Object by a vector of force that changes from (0,0,0) to v.
2113
 * <p>
2114
 * Difference between this and the previous method is that here the vector of force will get interpolated
2115
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
2116
 * 
2117
 * @param vector   Maximum, final vector of force.
2118
 * @param center   Center of the Effect.
2119
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2120
 * @return         ID of the effect added, or -1 if we failed to add one. 
2121
 */
2122
  public long distort(Float3D vector, Float2D center, int duration)
2123
    {
2124
    Interpolator3D di = new Interpolator3D();  
2125
    di.setCount(0.5f);
2126
    di.setDuration(duration);
2127
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2128
    di.add(vector);                 
2129
           
2130
    return mV.add(EffectNames.DISTORT, di, null, center);
2131
    }
2132

    
2133
///////////////////////////////////////////////////////////////////////////////////////////////////
2134
/**
2135
 * Distort the whole Object by a vector of force v.
2136
 * <p>
2137
 * Here we apply a constant vector of force.
2138
 * 
2139
 * @param vector Vector of force.
2140
 * @param center Center of the Effect.
2141
 * @return       ID of the effect added, or -1 if we failed to add one. 
2142
 */
2143
  public long distort(Float3D vector, Float2D center )
2144
    {
2145
    Interpolator3D di = new Interpolator3D(); 
2146
    di.setCount(0.5f);
2147
    di.setDuration(0);
2148
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2149
    di.add(vector);           
2150
           
2151
    return mV.add(EffectNames.DISTORT, di, null, center);
2152
    }
2153

    
2154
///////////////////////////////////////////////////////////////////////////////////////////////////
2155
///////////////////////////////////////////////////////////////////////////////////////////////////
2156
// DEFORM
2157
/**
2158
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
2159
 * a (possibly changing in time) point on the Object.
2160
 *     
2161
 * @param vector Interpolator that, at any given time, returns a Float2D representing vector of
2162
 *               force that deforms the shape of the whole Object.
2163
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2164
 *               the Center of the Effect.
2165
 * @return       ID of the effect added, or -1 if we failed to add one.
2166
 */
2167
  public long deform(Interpolator vector, Interpolator2D center)
2168
    {  
2169
    return mV.add(EffectNames.DEFORM, vector, null, center);
2170
    }
2171

    
2172
///////////////////////////////////////////////////////////////////////////////////////////////////
2173
/**
2174
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
2175
 * a constant point on the Object.
2176
 * 
2177
 * @param vector Interpolator that, at any given time, returns a Float2D representing
2178
 *               vector of force that deforms the shape of the whole Object.
2179
 * @param center Center of the Effect.
2180
 * @return       ID of the effect added, or -1 if we failed to add one.
2181
 */
2182
  public long deform(Interpolator vector, Float2D center)
2183
    {
2184
    return mV.add(EffectNames.DEFORM, vector, null, center);
2185
    }
2186

    
2187
///////////////////////////////////////////////////////////////////////////////////////////////////
2188
/**
2189
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
2190
 * applied to a constant point on the Object.
2191
 * 
2192
 * @param vector   Vector of force.
2193
 * @param center   Center of the Effect.
2194
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2195
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2196
 * @return         ID of the effect added, or -1 if we failed to add one. 
2197
 */
2198
  public long deform(Float3D vector, Float2D center, int duration, float count)
2199
    {
2200
    Interpolator3D di = new Interpolator3D(); 
2201
    di.setCount(count);
2202
    di.setDuration(duration);
2203
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2204
    di.add(vector);                
2205
           
2206
    return mV.add(EffectNames.DEFORM, di, null, center);
2207
    }
2208

    
2209
///////////////////////////////////////////////////////////////////////////////////////////////////
2210
/**
2211
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
2212
 * applied to a constant point on the Object.
2213
 * <p>
2214
 * Identical to calling the previous method with count=0.5.
2215
 * 
2216
 * @param vector   Final vector of force.
2217
 * @param center   Center of the Effect.
2218
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2219
 * @return         ID of the effect added, or -1 if we failed to add one. 
2220
 */
2221
  public long deform(Float3D vector, Float2D center, int duration)
2222
    {
2223
    Interpolator3D di = new Interpolator3D();  
2224
    di.setCount(0.5f);
2225
    di.setDuration(duration);
2226
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2227
    di.add(vector);             
2228
           
2229
    return mV.add(EffectNames.DEFORM, di, null, center);
2230
    }
2231

    
2232
///////////////////////////////////////////////////////////////////////////////////////////////////
2233
/**
2234
 * Deform the shape of the whole Object with a constant vector of force applied to a constant
2235
 * point on the Object.
2236
 * 
2237
 * @param vector Vector of force.
2238
 * @param center Center of the Effect.
2239
 * @return       ID of the effect added, or -1 if we failed to add one. 
2240
 */
2241
  public long deform(Float3D vector, Float2D center )
2242
    {
2243
    Interpolator3D di = new Interpolator3D(); 
2244
    di.setCount(0.5f);
2245
    di.setDuration(0);
2246
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2247
    di.add(vector);            
2248
           
2249
    return mV.add(EffectNames.DEFORM, di, null, center);
2250
    }
2251
   
2252
///////////////////////////////////////////////////////////////////////////////////////////////////  
2253
///////////////////////////////////////////////////////////////////////////////////////////////////
2254
// SINK
2255
/**
2256
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2257
 * away from the center (degree<=1)
2258
 *    
2259
 * @param sink   1-dimensional Interpolator which, at any given time, returns a Point1D representing
2260
 *               the current degree of the effect.
2261
 * @param region Region that masks the effect of the Sink.
2262
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2263
 *               the Center of the Effect.
2264
 * @return       ID of the effect added, or -1 if we failed to add one. 
2265
 */
2266
  public long sink(Interpolator1D sink, Float4D region, Interpolator2D center)
2267
    {
2268
    return mV.add(EffectNames.SINK, sink, region, center);
2269
    }
2270

    
2271
///////////////////////////////////////////////////////////////////////////////////////////////////
2272
/**
2273
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2274
 * away from the center (degree<=1).
2275
 * <p>
2276
 * Here the Center stays constant.
2277
 *      
2278
 * @param sink   1-dimensional Interpolator which, at any given time, returns a Point1D
2279
 *               representing the current degree of the effect.
2280
 * @param region Region that masks the effect of the Sink.
2281
 * @param center Center of the Effect.
2282
 * @return       ID of the effect added, or -1 if we failed to add one. 
2283
 */
2284
  public long sink(Interpolator1D sink, Float4D region, Float2D center)
2285
    {
2286
    return mV.add(EffectNames.SINK, sink, region, center);
2287
    }
2288
  
2289
///////////////////////////////////////////////////////////////////////////////////////////////////
2290
/**
2291
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2292
 * away from the center (degree<=1).
2293
 * <p>
2294
 * Here we can only interpolate between 1 and degree.
2295
 * 
2296
 * @param sink     How much to push or pull. Between 0 and infinity.
2297
 * @param region   Region that masks the effect of the Sink.
2298
 * @param center   2-dimensional Interpolator that, at any given time, returns a Point2D representing
2299
 *                 the Center of the Effect.
2300
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2301
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2302
 * @return         ID of the effect added, or -1 if we failed to add one. 
2303
 */
2304
  public long sink(float sink, Float4D region, Interpolator2D center, int duration, float count)
2305
    {
2306
    Interpolator1D di = new Interpolator1D(); 
2307
    di.setCount(count);
2308
    di.setDuration(duration);
2309
    di.add(new Float1D(1));                                
2310
    di.add(new Float1D(sink));
2311
    
2312
    return mV.add(EffectNames.SINK, di, region, center);
2313
    }
2314

    
2315
///////////////////////////////////////////////////////////////////////////////////////////////////
2316
/**
2317
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2318
 * away from the center (degree<=1).
2319
 *   
2320
 * @param sink     How much to push or pull. Between 0 and infinity.
2321
 * @param region   Region that masks the effect of the Sink.
2322
 * @param center   Center of the Effect.
2323
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2324
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2325
 * @return         ID of the effect added, or -1 if we failed to add one. 
2326
 */
2327
  public long sink(float sink, Float4D region, Float2D center, int duration, float count)
2328
    {
2329
    Interpolator1D di = new Interpolator1D(); 
2330
    di.setCount(count);
2331
    di.setDuration(duration);
2332
    di.add(new Float1D(1));                                
2333
    di.add(new Float1D(sink));
2334
    
2335
    return mV.add(EffectNames.SINK, di, region, center);
2336
    }
2337

    
2338
///////////////////////////////////////////////////////////////////////////////////////////////////
2339
/**
2340
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2341
 * away from the center (degree<=1).
2342
 * 
2343
 * @param sink     How much to push or pull. Between 0 and infinity.
2344
 * @param center   Center of the Effect.
2345
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2346
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2347
 * @return         ID of the effect added, or -1 if we failed to add one. 
2348
 */
2349
  public long sink(float sink, Float2D center, int duration, float count)
2350
    {
2351
    Interpolator1D di = new Interpolator1D();  
2352
    di.setCount(count);
2353
    di.setDuration(duration);
2354
    di.add(new Float1D(1));                                
2355
    di.add(new Float1D(sink));
2356
         
2357
    return mV.add(EffectNames.SINK, di, null, center);
2358
    }
2359

    
2360
///////////////////////////////////////////////////////////////////////////////////////////////////
2361
/**
2362
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2363
 * away from the center (degree<=1).
2364
 * <p>
2365
 * Equivalent to calling the previous method with count=0.5.
2366
 * 
2367
 * @param sink     How much to push or pull. Between 0 and infinity.
2368
 * @param center   Center of the Effect.
2369
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2370
 * @return         ID of the effect added, or -1 if we failed to add one. 
2371
 */
2372
  public long sink(float sink, Float2D center, int duration)
2373
    {
2374
    Interpolator1D di = new Interpolator1D(); 
2375
    di.setCount(0.5f);
2376
    di.setDuration(duration);
2377
    di.add(new Float1D(1));                               
2378
    di.add(new Float1D(sink));
2379
        
2380
    return mV.add(EffectNames.SINK, di, null, center);
2381
    }
2382

    
2383
///////////////////////////////////////////////////////////////////////////////////////////////////
2384
/**
2385
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2386
 * away from the center (degree<=1).
2387
 * <p>
2388
 * Equivalent of calling the previous method with duration=0; i.e. we pull immediately.
2389
 * 
2390
 * @param sink   How much to push or pull. Between 0 and infinity.
2391
 * @param center Center of the Effect.
2392
 * @return       ID of the effect added, or -1 if we failed to add one. 
2393
 */
2394
  public long sink(float sink, Float2D center)
2395
    {
2396
    Interpolator1D di = new Interpolator1D(); 
2397
    di.setCount(0.5f);
2398
    di.setDuration(0);
2399
    di.add(new Float1D(1));                               
2400
    di.add(new Float1D(sink));
2401
        
2402
    return mV.add(EffectNames.SINK, di, null, center);
2403
    }
2404
  
2405
///////////////////////////////////////////////////////////////////////////////////////////////////  
2406
///////////////////////////////////////////////////////////////////////////////////////////////////
2407
// SWIRL
2408
/**
2409
 * Rotate part of the Object around the Center of the Effect by a certain angle (as returned by the
2410
 * Interpolator). 
2411
 *   
2412
 * @param swirl  1-dimensional Interpolator which, at any given time, returns a Point1D representing
2413
 *               the degree of Swirl.
2414
 * @param region Region that masks the effect of the Swirl.
2415
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2416
 *               the Center of the Effect.
2417
 * @return       ID of the effect added, or -1 if we failed to add one. 
2418
 */
2419
  public long swirl(Interpolator1D swirl, Float4D region, Interpolator2D center)
2420
    {    
2421
    return mV.add(EffectNames.SWIRL, swirl, region, center);
2422
    }
2423

    
2424
///////////////////////////////////////////////////////////////////////////////////////////////////
2425
/**
2426
 * Rotate part of the Object around the Center of the Effect by a certain angle (as returned by the
2427
 * Interpolator).
2428
 * <p>
2429
 * Here the Center stays constant.
2430
 *      
2431
 * @param swirl  1-dimensional Interpolator which, at any given time, returns a Point1D representing
2432
 *               the degree of Swirl.
2433
 * @param region Region that masks the effect of the Swirl.
2434
 * @param center Center of the Effect.
2435
 * @return       ID of the effect added, or -1 if we failed to add one. 
2436
 */
2437
  public long swirl(Interpolator1D swirl, Float4D region, Float2D center)
2438
    {    
2439
    return mV.add(EffectNames.SWIRL, swirl, region, center);
2440
    }
2441
 
2442
///////////////////////////////////////////////////////////////////////////////////////////////////
2443
/**
2444
 * Rotate part of the Object around the Center of the Effect by 'degree' angle.
2445
 *   
2446
 * @param swirl    Angle of rotation. Unit: degrees.
2447
 * @param region   Region that masks the effect of the Swirl.
2448
 * @param center   2-dimensional Interpolator that, at any given time, returns a Point2D representing
2449
 *                 the Center of the Effect.
2450
 * @return         ID of the effect added, or -1 if we failed to add one.
2451
 */
2452
  public long swirl(int swirl, Float4D region, Interpolator2D center)
2453
    {
2454
    Interpolator1D di = new Interpolator1D();
2455
    di.setCount(0.5f);
2456
    di.setDuration(0);
2457
    di.add(new Float1D(0));                                
2458
    di.add(new Float1D(swirl));
2459
    
2460
    return mV.add(EffectNames.SWIRL, di, region, center);
2461
    }
2462

    
2463
///////////////////////////////////////////////////////////////////////////////////////////////////
2464
/**
2465
 * Rotate part of the Object around the Center of the Effect by 'degree' angle.
2466
 * <p>
2467
 * Here the Center stays constant.
2468
 *    
2469
 * @param swirl    Angle of rotation. Unit: degrees.
2470
 * @param region   Region that masks the effect of the Swirl.
2471
 * @param center   Center of the Effect.
2472
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2473
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2474
 * @return         ID of the effect added, or -1 if we failed to add one. 
2475
 */
2476
  public long swirl(int swirl, Float4D region, Float2D center, int duration, float count)
2477
    {
2478
    Interpolator1D di = new Interpolator1D(); 
2479
    di.setCount(count);
2480
    di.setDuration(duration);
2481
    di.add(new Float1D(0));                                
2482
    di.add(new Float1D(swirl));
2483
    
2484
    return mV.add(EffectNames.SWIRL, di, region, center);
2485
    }
2486

    
2487
///////////////////////////////////////////////////////////////////////////////////////////////////
2488
/**
2489
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2490
 * 
2491
 * @param swirl    Angle of rotation. Unit: degrees.
2492
 * @param center   Center of the Effect.
2493
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2494
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2495
 * @return         ID of the effect added, or -1 if we failed to add one. 
2496
 */
2497
  public long swirl(int swirl, Float2D center, int duration, float count)
2498
    {
2499
    Interpolator1D di = new Interpolator1D();  
2500
    di.setCount(count);
2501
    di.setDuration(duration);
2502
    di.add(new Float1D(0));                                
2503
    di.add(new Float1D(swirl));
2504
         
2505
    return mV.add(EffectNames.SWIRL, di, null, center);
2506
    }
2507

    
2508
///////////////////////////////////////////////////////////////////////////////////////////////////
2509
/**
2510
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2511
 * <p>
2512
 * Equivalent to calling the previous method with count=0.5.
2513
 * 
2514
 * @param swirl    Angle of rotation. Unit: degrees.
2515
 * @param center   Center of the Effect.
2516
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2517
 * @return         ID of the effect added, or -1 if we failed to add one. 
2518
 */
2519
  public long swirl(int swirl, Float2D center, int duration)
2520
    {
2521
    Interpolator1D di = new Interpolator1D(); 
2522
    di.setCount(0.5f);
2523
    di.setDuration(duration);
2524
    di.add(new Float1D(0));                               
2525
    di.add(new Float1D(swirl));
2526
        
2527
    return mV.add(EffectNames.SWIRL, di, null, center);
2528
    }
2529

    
2530
///////////////////////////////////////////////////////////////////////////////////////////////////
2531
/**
2532
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2533
 * <p>
2534
 * Equivalent to calling the previous method with duration=0.
2535
 * 
2536
 * @param swirl  Angle of rotation. Unit: degrees.
2537
 * @param center Center of the Effect.
2538
 * @return       ID of the effect added, or -1 if we failed to add one. 
2539
 */
2540
  public long swirl(int swirl, Float2D center)
2541
    {
2542
    Interpolator1D di = new Interpolator1D(); 
2543
    di.setCount(0.5f);
2544
    di.setDuration(0);
2545
    di.add(new Float1D(0));                               
2546
    di.add(new Float1D(swirl));
2547
        
2548
    return mV.add(EffectNames.SWIRL, di, null, center);
2549
    }
2550

    
2551
///////////////////////////////////////////////////////////////////////////////////////////////////
2552
///////////////////////////////////////////////////////////////////////////////////////////////////
2553
// WAVE
2554

    
2555
///////////////////////////////////////////////////////////////////////////////////////////////////   
2556
///////////////////////////////////////////////////////////////////////////////////////////////////
2557
// Other-based effects
2558
///////////////////////////////////////////////////////////////////////////////////////////////////
2559
// SAVE_PNG
2560
/**
2561
 * Save the current state of the Object that's backing up our DistortedObject to a PNG file.
2562
 *
2563
 * @param filename Full path to the file.
2564
 * @return         ID of the effect added, or -1 if we failed to add one.
2565
 */
2566
 public long savePNG(String filename, int left, int top, int width, int height)
2567
   {
2568
   return mO.add(EffectNames.SAVE_PNG, filename, left, top, width, height);
2569
   }
2570
}
(7-7/18)