Project

General

Profile

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

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

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

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

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

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

    
65
    protected abstract DistortedObject deepCopy(int flags);
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
    protected void initializeData(int size)
70
      {
71
      mID             = DistortedObjectList.add(this);
72
      mSize           = size;
73
      mTextureDataH   = new int[1];
74
      mTextureDataH[0]= 0;
75
      mBmp            = new Bitmap[1];
76
      mBmp[0]         = null;
77
      mBitmapSet      = new boolean[1];
78
      mBitmapSet[0]   = false;
79
      
80
      initializeEffectLists(this,0);
81
      
82
      if( Distorted.isInitialized() ) resetTexture();    
83
      }
84
    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
    
87
    protected void initializeEffectLists(DistortedObject d, int flags)
88
      {
89
      if( (flags & Distorted.CLONE_PRESHADER) != 0 )
90
        {
91
        mM = d.mM;
92
        matrixCloned = true;
93
        } 
94
      else
95
        {
96
        mM = new EffectQueueMatrix(d);
97
        matrixCloned = false;  
98
        }
99
    
100
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
101
        {
102
        mV = d.mV;
103
        vertexCloned = true;
104
        } 
105
      else
106
        {
107
        mV = new EffectQueueVertex(d);
108
        vertexCloned = false;  
109
        }
110
    
111
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
112
        {
113
        mF = d.mF;
114
        fragmentCloned = true;
115
        } 
116
      else
117
        {
118
        mF = new EffectQueueFragment(d);
119
        fragmentCloned = false;   
120
        }
121
      }
122
    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124
// this will be called on startup and every time OpenGL context has been lost
125
// also call this from the constructor if the OpenGL context has been created already.
126
    
127
    void resetTexture()
128
      {
129
      if( mTextureDataH!=null ) 
130
        {
131
        if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
132

    
133
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);       
134
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
135
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
136
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
137
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
138
       
139
        if( mBmp!=null && mBmp[0]!=null)
140
          {
141
          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBmp[0], 0);
142
          mBmp[0] = null;
143
          }
144
        }
145
      }
146
  
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148
   
149
    void drawPriv(long currTime, DistortedProjection dp)
150
      {
151
      GLES20.glViewport(0, 0, dp.width, dp.height); 
152
      
153
      mM.compute(currTime);
154
      mM.send(mViewMatrix, dp);
155
      
156
      mV.compute(currTime);
157
      mV.postprocess();
158
      mV.send();
159
        
160
      mF.compute(currTime);
161
      mF.postprocess(mViewMatrix);
162
      mF.send();
163
       
164
      mGrid.draw();
165
      }
166

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

    
186
      mBmp          = null;
187
      mGrid         = null;
188
      mM            = null;
189
      mV            = null;
190
      mF            = null;
191
      mTextureDataH = null;
192
      }
193
 
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195

    
196
    long getBitmapID()
197
      {
198
      return mBmp==null ? 0 : mBmp.hashCode();
199
      }
200

    
201
///////////////////////////////////////////////////////////////////////////////////////////////////
202

    
203
  /**
204
   * Default empty constructor so that derived classes can call it
205
   */
206
    public DistortedObject()
207
      {
208

    
209
      }
210

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

    
227
      mID = DistortedObjectList.add(this);
228

    
229
      mSizeX = dc.mSizeX;
230
      mSizeY = dc.mSizeY;
231
      mSizeZ = dc.mSizeZ;
232
      mSize  = dc.mSize;
233
      mGrid  = dc.mGrid;
234

    
235
      if( (flags & Distorted.CLONE_BITMAP) != 0 )
236
        {
237
        mTextureDataH = dc.mTextureDataH;
238
        mBmp          = dc.mBmp;
239
        mBitmapSet    = dc.mBitmapSet;
240
        }
241
      else
242
        {
243
        mTextureDataH   = new int[1];
244
        mTextureDataH[0]= 0;
245
        mBitmapSet      = new boolean[1];
246
        mBitmapSet[0]   = false;
247
        mBmp            = new Bitmap[1];
248
        mBmp[0]         = null;
249

    
250
        if( Distorted.isInitialized() ) resetTexture();
251
        }
252
      }
253

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

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

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323
/**
324
 * Removes the calling class from the list of Listeners.
325
 * 
326
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
327
 */
328
   public void removeEventListener(EffectListener el)
329
     {
330
     mV.removeListener(el);
331
     mF.removeListener(el);
332
     mM.removeListener(el);
333
     }
334
   
335
///////////////////////////////////////////////////////////////////////////////////////////////////
336
/**
337
 * Returns the height of the DistortedObject.
338
 *    
339
 * @return height of the object, in pixels.
340
 */
341
   public int getWidth()
342
     {
343
     return mSizeX;   
344
     }
345

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347
/**
348
 * Returns the width of the DistortedObject.
349
 * 
350
 * @return width of the Object, in pixels.
351
 */
352
    public int getHeight()
353
      {
354
      return mSizeY;  
355
      }
356
    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358
/**
359
 * Returns the depth of the DistortedObject.
360
 * 
361
 * @return depth of the Object, in pixels.
362
 */
363
    public int getDepth()
364
      {
365
      return mSizeZ;  
366
      }
367
        
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
/**
370
 * Returns unique ID of this instance.
371
 * 
372
 * @return ID of the object.
373
 */
374
    public long getID()
375
      {
376
      return mID;  
377
      }
378
    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380
/**
381
 * Aborts all Effects.
382
 * @return Number of effects aborted.
383
 */
384
    public int abortAllEffects()
385
      {
386
      return mM.abortAll() + mV.abortAll() + mF.abortAll();
387
      }
388

    
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390
/**
391
 * Aborts all Effects of a given type, for example all MATRIX Effects.
392
 * 
393
 * @param type one of the constants defined in {@link EffectTypes}
394
 * @return Number of effects aborted.
395
 */
396
    public int abortEffects(EffectTypes type)
397
      {
398
      switch(type)
399
        {
400
        case MATRIX  : return mM.abortAll();
401
        case VERTEX  : return mV.abortAll();
402
        case FRAGMENT: return mF.abortAll();
403
        default      : return 0;
404
        }
405
      }
406
    
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408
/**
409
 * Aborts a single Effect.
410
 * 
411
 * @param id ID of the Effect we want to abort.
412
 * @return number of Effects aborted. Always either 0 or 1.
413
 */
414
    public int abortEffect(long id)
415
      {
416
      int type = (int)(id&EffectTypes.MASK);
417

    
418
      if( type==EffectTypes.MATRIX.type   ) return mM.removeByID(id>>EffectTypes.LENGTH);
419
      if( type==EffectTypes.VERTEX.type   ) return mV.removeByID(id>>EffectTypes.LENGTH);
420
      if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
421

    
422
      return 0;
423
      }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426
/**
427
 * Abort all Effects of a given type, for example all rotations.
428
 * 
429
 * @param name one of the constants defined in {@link EffectNames}
430
 * @return number of Effects aborted.
431
 */
432
    public int abortEffects(EffectNames name)
433
      {
434
      switch(name.getType())
435
        {
436
        case MATRIX  : return mM.removeByType(name);
437
        case VERTEX  : return mV.removeByType(name);
438
        case FRAGMENT: return mF.removeByType(name);
439
        default      : return 0;
440
        }
441
      }
442
    
443
///////////////////////////////////////////////////////////////////////////////////////////////////
444
/**
445
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
446
 * 
447
 * @param id Effect ID we want to print info about
448
 * @return <code>true</code> if a single Effect of type effectType has been found.
449
 */
450
    
451
    public boolean printEffect(long id)
452
      {
453
      int type = (int)(id&EffectTypes.MASK);
454

    
455
      if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
456
      if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
457
      if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
458

    
459
      return false;
460
      }
461
   
462
///////////////////////////////////////////////////////////////////////////////////////////////////   
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464
// Individual effect functions.
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466
// Matrix-based effects
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468
// MOVE
469
/**
470
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
471
 * 
472
 * @param vector 3-dimensional Interpolator which at any given time will return a Float3D
473
 *               representing the current coordinates of the vector we want to move the Object with.
474
 * @return       ID of the effect added, or -1 if we failed to add one.
475
 */
476
  public long move(Interpolator3D vector)
477
    {   
478
    return mM.add(EffectNames.MOVE,vector);
479
    }
480

    
481
///////////////////////////////////////////////////////////////////////////////////////////////////
482
/**
483
 * Moves the Object by a vector that smoothly changes from (0,0,0) to (x,y,z).
484
 *  
485
 * @param x        The x-coordinate of the vector we want to move the Object with. 
486
 * @param y        The y-coordinate of the vector we want to move the Object with.
487
 * @param z        The z-coordinate of the vector we want to move the Object with.
488
 * @param duration The time, in milliseconds, it takes to complete the movement.
489
 * @return         ID of the effect added, or -1 if we failed to add one. 
490
 */
491
  public long move(float x,float y,float z, int duration)
492
    {   
493
    Interpolator3D di = new Interpolator3D();  
494
    di.setCount(0.5f);
495
    di.setDuration(duration);
496
    di.add(new Float3D(0.0f,0.0f,0.0f));                             
497
    di.add(new Float3D(x,y,z));                        
498

    
499
    return mM.add(EffectNames.MOVE,di);
500
    }
501

    
502
///////////////////////////////////////////////////////////////////////////////////////////////////
503
/**
504
 * Moves the Object by vector (x,y,z) immediately.
505
 *   
506
 * @param x The x-coordinate of the vector we want to move the Object with. 
507
 * @param y The y-coordinate of the vector we want to move the Object with.
508
 * @param z The z-coordinate of the vector we want to move the Object with.
509
 * @return  ID of the effect added, or -1 if we failed to add one. 
510
 */
511
  public long move(float x,float y,float z)
512
    {   
513
    return mM.add(EffectNames.MOVE,mZero3D,x,y,z,0.0f);
514
    }
515

    
516
///////////////////////////////////////////////////////////////////////////////////////////////////
517
// SCALE
518
/**
519
 * Scales the Object by factors that change in time as returned by the Interpolator.
520
 * 
521
 * @param scale 3-dimensional Interpolator which at any given time returns a Float3D
522
 *              representing the current x- , y- and z- scale factors.
523
 * @return      ID of the effect added, or -1 if we failed to add one.
524
 */
525
  public long scale(Interpolator3D scale)
526
    {   
527
    return mM.add(EffectNames.SCALE,scale);
528
    }
529

    
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531
/**
532
 * Scales the Object by a factor that smoothly changes from (1,1,1) at time 0 to (xscale,yscale,zscale)
533
 * after 'duration' milliseconds. 
534
 *    
535
 * @param xscale   After time 'duration' passes, Object's width will get multiplied by xscale; e.g. if
536
 *                 xscale=2, after 'duration' milliseconds the Object will become twice broader.
537
 * @param yscale   Factor to scale Object's height with.
538
 * @param zscale   Factor to scale Object's depth with.
539
 * @param duration Time, in milliseconds, it takes to interpolate to the full (xscale,yscale,zscale) scaling factors.
540
 * @return         ID of the effect added, or -1 if we failed to add one. 
541
 */
542
  public long scale(float xscale,float yscale,float zscale, int duration)
543
    {   
544
    Interpolator3D di = new Interpolator3D();  
545
    di.setCount(0.5f);
546
    di.setDuration(duration);
547
    di.add(new Float3D(1.0f,1.0f,1.0f));                             
548
    di.add(new Float3D(xscale,yscale,zscale));                        
549

    
550
    return mM.add(EffectNames.SCALE,di);
551
    }
552

    
553
///////////////////////////////////////////////////////////////////////////////////////////////////
554
/**
555
 * Immediately scales the Object's width by (xscale,yscale,zscale).   
556
 *   
557
 * @param xscale Object's width gets multiplied by this factor; e.g. if 
558
 *               xscale=2, the Object immediately becomes twice broader.
559
 * @param yscale factor to scale Object's height with.
560
 * @param zscale factor to scale Object's depth with. 
561
 * @return       ID of the effect added, or -1 if we failed to add one. 
562
 */
563
  public long scale(float xscale,float yscale,float zscale)
564
    {   
565
    return mM.add(EffectNames.SCALE,mZero3D,xscale,yscale,zscale,0.0f);
566
    }
567

    
568
///////////////////////////////////////////////////////////////////////////////////////////////////
569
/**
570
 * Convenience function - scale the Object by the same factor in all 3 dimensions.   
571
 *   
572
 * @param scale all 3 Object's dimensions get multiplied by this factor; e.g. if 
573
 *              scale=2, the Object immediately becomes twice larger.
574
 * @return      ID of the effect added, or -1 if we failed to add one. 
575
 */
576
  public long scale(float scale)
577
    {   
578
    return mM.add(EffectNames.SCALE,mZero3D,scale,scale,scale,0.0f);
579
    }
580
    
581
///////////////////////////////////////////////////////////////////////////////////////////////////
582
// ROTATE
583
/**
584
 * Rotates the Object around a (possibly moving) point, with angle and axis that change in time.
585
 * 
586
 * @param center    3-dimensional Interpolator which at any given time will return the current center
587
 *                  of the rotation
588
 * @param angleAxis 4-dimensional Interpolator which at any given time will return a Float4D
589
 *                  representing the current rotation in the (angle,axisX,axisY,axisY) form.
590
 * @return          ID of the effect added, or -1 if we failed to add one.
591
 */
592
  public long rotate(Interpolator3D center, Interpolator4D angleAxis)
593
    {   
594
    return mM.add(EffectNames.ROTATE, center, angleAxis);
595
    }
596

    
597
///////////////////////////////////////////////////////////////////////////////////////////////////  
598
/**
599
 * Rotates the Object around a static point, with angle and axis that change in time.
600
 * 
601
 * @param center    Center 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(Float3D 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 that changes in time, around axis 
614
 * (axisX, axisY, axisZ). 
615
 * 
616
 * @param center Center of the rotation
617
 * @param angle  1-dimensional Interpolator which at any given time will return the current rotation
618
 *               angle.
619
 * @param axisX  Rotation vector: x-coordinate
620
 * @param axisY  Rotation vector: y-coordinate
621
 * @param axisZ  Rotation vector: z-coordinate
622
 * @return       ID of the effect added, or -1 if we failed to add one.
623
 */
624
  public long rotate(Float3D center, Interpolator1D angle, float axisX, float axisY, float axisZ)
625
    {   
626
    return mM.add(EffectNames.ROTATE, center , angle, axisX, axisY, axisZ);
627
    }
628
  
629
///////////////////////////////////////////////////////////////////////////////////////////////////
630
/**
631
 * Rotates the Object around a (possibly moving) point, with angle that changes in time.
632
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
633
 * 
634
 * @param center 3-dimensional Interpolator which at any given time will return the current center
635
 *               of the rotation.
636
 * @param angle  1-dimensional Interpolator which returns the current rotation angle.
637
 * @return       ID of the effect added, or -1 if we failed to add one.
638
 */
639
  public long rotate(Interpolator3D center, Interpolator1D angle)
640
    {   
641
    return mM.add(EffectNames.ROTATE, center, angle, 0.0f,0.0f,1.0f);
642
    }
643

    
644
///////////////////////////////////////////////////////////////////////////////////////////////////
645
/**
646
 * Rotates the Object around a constant point, with angle that changes in time.  
647
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
648
 *   
649
 * @param center   Coordinates of the Point we are rotating around.
650
 * @param angle    Angle that we want to rotate the Object to. Unit: degrees
651
 * @param duration Time, in milliseconds, it takes to complete one rotation from 0 to 'angle' degrees.
652
 * @return         ID of the effect added, or -1 if we failed to add one. 
653
 */
654
  public long rotate(Float3D center, int angle, int duration)
655
    {   
656
    Interpolator1D di = new Interpolator1D();  
657
    di.setCount(0.5f);
658
    di.setDuration(duration);
659
    di.add(new Float1D(    0));
660
    di.add(new Float1D(angle));                        
661

    
662
    return mM.add(EffectNames.ROTATE, center, di, 0.0f,0.0f,1.0f);
663
    }
664

    
665
///////////////////////////////////////////////////////////////////////////////////////////////////
666
/**
667
 * Rotates the Object immediately by 'angle' degrees around point p.   
668
 * Axis of rotation is given by the last 3 floats.
669
 *   
670
 * @param center Coordinates of the Point we are rotating around.
671
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
672
 * @param axisX  Axis of rotation: x-coordinate
673
 * @param axisY  Axis of rotation: y-coordinate
674
 * @param axisZ  Axis of rotation: z-coordinate
675
 * @return       ID of the effect added, or -1 if we failed to add one.
676
 */
677
  public long rotate(Float3D center, float angle, float axisX, float axisY, float axisZ)
678
    {   
679
    return mM.add(EffectNames.ROTATE, center, angle, axisX, axisY, axisZ);
680
    }
681
  
682
///////////////////////////////////////////////////////////////////////////////////////////////////
683
/**
684
 * Rotates the Object immediately by 'angle' degrees around point p.   
685
 *   
686
 * @param center Coordinates of the Point we are rotating around.
687
 * @param angle  The angle that we want to rotate the Object to. Unit: degrees
688
 * @return       ID of the effect added, or -1 if we failed to add one. 
689
 */
690
  public long rotate(Float3D center, int angle)
691
    {   
692
    return mM.add(EffectNames.ROTATE, center, angle,0.0f,0.0f,1.0f);
693
    }
694

    
695
///////////////////////////////////////////////////////////////////////////////////////////////////
696
// QUATERNION
697
/**
698
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
699
 *   
700
 * @param center Coordinates of the Point we are rotating around.
701
 * @param qX     Quaternion: x-coordinate
702
 * @param qY     Quaternion: y-coordinate
703
 * @param qZ     Quaternion: z-coordinate
704
 * @param qW     Quaternion: w-coordinate
705
 * @return       ID of the effect added, or -1 if we failed to add one.
706
 */
707
  public long quaternion(Float3D center, float qX, float qY, float qZ, float qW)
708
    {   
709
    return mM.add(EffectNames.QUATERNION,center,qX,qY,qZ,qW);
710
    }
711

    
712
///////////////////////////////////////////////////////////////////////////////////////////////////
713
/**
714
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
715
 *   
716
 * @param center Coordinates of the Point we are rotating around.
717
 * @param quat   Interpolator that's going to, at any given moment, return a quaternion.
718
 * @return       ID of the effect added, or -1 if we failed to add one.
719
 */
720
  public long quaternion(Float3D center, InterpolatorQuat quat)
721
    {   
722
    return mM.add(EffectNames.QUATERNION, center, quat);
723
    }
724

    
725
///////////////////////////////////////////////////////////////////////////////////////////////////
726
/**
727
 * Rotates the Object around a moving point by a quaternion that's at the moment returned by the InterpolatorQuat.
728
 *   
729
 * @param center Interpolator that returns the current center of rotation.
730
 * @param quat   Interpolator that's going to, at any given moment, return a quaternion representing
731
 *               the current rotation.
732
 * @return       ID of the effect added, or -1 if we failed to add one.
733
 */
734
  public long quaternion(Interpolator3D center, InterpolatorQuat quat)
735
    {   
736
    return mM.add(EffectNames.QUATERNION,center,quat);
737
    }
738
  
739
///////////////////////////////////////////////////////////////////////////////////////////////////
740
// SHEAR
741
/**
742
 * Shears the Object. If the Interpolator is 1D, it will shear along the X-axis. 2D Interpolator adds
743
 * shearing along the Y-axis, 3D one along Z axis.
744
 *
745
 * @param center  Center of shearing, i.e. the point which stays unmoved.
746
 * @param shear   1- 2- or 3D Interpolator which, at any given point, returns the ordered 1-, 2-
747
 *                or 3-tuple of shear factors.
748
 * @return        ID of the effect added, or -1 if we failed to add one.
749
 */
750
  public long shear(Float3D center, Interpolator shear)
751
    {
752
    return mM.add(EffectNames.SHEAR, center, shear);
753
    }
754

    
755
///////////////////////////////////////////////////////////////////////////////////////////////////
756
/**
757
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
758
 * 
759
 * @param center Center of shearing, i.e. the point which stays unmoved.
760
 * @param shear  ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with
761
 *               which the X,Y and Z axis get slanted) 
762
 * @return       ID of the effect added, or -1 if we failed to add one. 
763
 */
764
  public long shear(Float3D center, Float3D shear)
765
    {
766
    Interpolator3D di = new Interpolator3D(); 
767
    di.setCount(0.5f);
768
    di.setDuration(0);
769
    di.add(new Float3D(0.0f,0.0f,0.0f));              
770
    di.add(shear);
771
        
772
    return mM.add(EffectNames.SHEAR, center, di );
773
    }
774

    
775
///////////////////////////////////////////////////////////////////////////////////////////////////
776
// Fragment-based effects  
777
///////////////////////////////////////////////////////////////////////////////////////////////////
778
// MACROBLOCK
779
/**
780
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
781
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
782
 * 
783
 * @param size   1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
784
 * @param region Region this Effect is limited to.
785
 *               Null here means 'apply the effect to the whole Object'.
786
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
787
 *               current center of the effect.
788
 * @return       ID of the effect added, or -1 if we failed to add one. 
789
 */
790
  public long macroblock(Interpolator1D size, Float4D region, Interpolator2D center)
791
    {
792
    return mF.add(EffectNames.MACROBLOCK, size, region, center);
793
    }
794

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

    
838
    return mF.add(EffectNames.MACROBLOCK, di, region, center);
839
    }
840

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

    
867
    return mF.add(EffectNames.MACROBLOCK, di, region, center);
868
    }
869

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

    
897
///////////////////////////////////////////////////////////////////////////////////////////////////
898
///////////////////////////////////////////////////////////////////////////////////////////////////
899
// CHROMA
900
/**
901
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
902
 *        
903
 * @param blend  1-dimensional Interpolator that returns the level of blend a given pixel will be
904
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
905
 * @param color  Color to mix. (1,0,0) is RED.
906
 * @param region Region this Effect is limited to. 
907
 *               Null here means 'apply the Effect to the whole Object'.
908
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing
909
 *               the current center of the effect.
910
 * @return       ID of the effect added, or -1 if we failed to add one. 
911
 */
912
  public long chroma(Interpolator1D blend, Float3D color, Float4D region, Interpolator2D center)
913
    {
914
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
915
    }
916

    
917
///////////////////////////////////////////////////////////////////////////////////////////////////
918
/**
919
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
920
 * <p>
921
 * Here the center of the Effect stays constant.
922
 *         
923
 * @param blend  1-dimensional Interpolator that returns the level of blend a given pixel will be
924
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
925
 * @param color  Color to mix. (1,0,0) is RED.
926
 * @param region Region this Effect is limited to. 
927
 *               Null here means 'apply the Effect to the whole Object'.
928
 * @param center Center of the Effect.
929
 * @return       ID of the effect added, or -1 if we failed to add one. 
930
 */
931
  public long chroma(Interpolator1D blend, Float3D color, Float4D region, Float2D center)
932
    {
933
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
934
    }
935

    
936
///////////////////////////////////////////////////////////////////////////////////////////////////  
937
/**
938
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
939
 *        
940
 * @param blend  Level of blend a given pixel will be mixed with the next parameter 'color':
941
 *               pixel = (1-t)*pixel + t*color
942
 * @param color  Color to mix. (1,0,0) is RED.
943
 * @param region Region this Effect is limited to.
944
 *               Null here means 'apply the Effect to the whole Object'.
945
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
946
 *               current center of the effect.
947
 * @return       ID of the effect added, or -1 if we failed to add one. 
948
 */
949
  public long chroma(float blend, Float3D color, Float4D region, Interpolator2D center)
950
    {
951
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
952
    }
953

    
954
///// //////////////////////////////////////////////////////////////////////////////////////////////
955
/**
956
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
957
 * <p>
958
 * Here the center of the Effect stays constant.
959
 *         
960
 * @param blend  Level of blend a given pixel will be mixed with the next parameter 'color':
961
 *               pixel = (1-t)*pixel + t*color
962
 * @param color  Color to mix. (1,0,0) is RED.
963
 * @param region The Region this Effect is limited to. 
964
 *               Null here means 'apply the Effect to the whole Object'.
965
 * @param center Center of the Effect.
966
 * @return       ID of the effect added, or -1 if we failed to add one. 
967
 */
968
  public long chroma(float blend, Float3D color, Float4D region, Float2D center)
969
    {
970
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
971
    }
972

    
973
///////////////////////////////////////////////////////////////////////////////////////////////////
974
/**
975
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
976
 * <p>
977
 * Here the Effect applies to the whole Object.
978
 *         
979
 * @param blend Level of blend a given pixel will be mixed with the next parameter 'color':
980
 *              pixel = (1-t)*pixel + t*color
981
 * @param color Color to mix. (1,0,0) is RED.
982
 * @return      ID of the effect added, or -1 if we failed to add one. 
983
 */
984
  public long chroma(float blend, Float3D color)
985
    {
986
    return mF.add(EffectNames.CHROMA, blend, color, null, mZero2D);
987
    }
988

    
989
///////////////////////////////////////////////////////////////////////////////////////////////////  
990
/**
991
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
992
 * 
993
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
994
 */
995
  public long smooth_chroma(Interpolator1D blend, Float3D color, Float4D region, Interpolator2D center)
996
    {
997
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
998
    }
999

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

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

    
1063
///////////////////////////////////////////////////////////////////////////////////////////////////
1064
/**
1065
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1066
 * <p>
1067
 * Here the center of the Effect stays constant.
1068
 *         
1069
 * @param alpha  1-dimensional Interpolator that returns the level of transparency we want to have at any given
1070
 *               moment.
1071
 * @param region Region this Effect is limited to. 
1072
 *               Null here means 'apply the Effect to the whole Object'.
1073
 * @param center Center of the Effect.
1074
 * @return       ID of the effect added, or -1 if we failed to add one. 
1075
 */
1076
  public long alpha(Interpolator1D alpha, Float4D region, Float2D center)
1077
    {
1078
    return mF.add(EffectNames.ALPHA, alpha, region, center);
1079
    }
1080

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

    
1105
///////////////////////////////////////////////////////////////////////////////////////////////////
1106
/**
1107
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1108
 * <p>
1109
 * Here the center of the Effect stays constant.
1110
 *         
1111
 * @param alpha    Level of Alpha (between 0 and 1) we want to interpolate to.
1112
 * @param region   Region this Effect is limited to.
1113
 *                 Null here means 'apply the Effect to the whole Object'.
1114
 * @param center   Center of the Effect.
1115
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1116
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1117
 * @return         ID of the effect added, or -1 if we failed to add one.
1118
 */
1119
  public long alpha(float alpha, Float4D region, Float2D center, int duration, float count)
1120
    {
1121
    Interpolator1D di = new Interpolator1D(); 
1122
    di.setCount(count);
1123
    di.setDuration(duration);
1124
    di.add(new Float1D(1));                          
1125
    di.add(new Float1D(alpha));                         
1126
   
1127
    return mF.add(EffectNames.ALPHA, di, region, center);
1128
    }
1129

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

    
1173
///////////////////////////////////////////////////////////////////////////////////////////////////  
1174
/**
1175
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1176
 * 
1177
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1178
 */
1179
  public long smooth_alpha(Interpolator1D alpha, Float4D region, Interpolator2D center)
1180
    {
1181
    return mF.add(EffectNames.SMOOTH_ALPHA, alpha, region, center);
1182
    }
1183

    
1184
///////////////////////////////////////////////////////////////////////////////////////////////////
1185
/**
1186
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1187
 * 
1188
 * See {@link #alpha(Interpolator1D, Float4D, Float2D)}
1189
 */
1190
  public long smooth_alpha(Interpolator1D alpha, Float4D region, Float2D center)
1191
    {
1192
    return mF.add(EffectNames.SMOOTH_ALPHA, alpha, region, center);
1193
    }
1194
  
1195
///////////////////////////////////////////////////////////////////////////////////////////////////  
1196
/**
1197
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1198
 * 
1199
 * See {@link #alpha(float, Float4D, Interpolator2D, int, float)}
1200
 */
1201
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D center, int duration, float count)
1202
    {
1203
    Interpolator1D di = new Interpolator1D(); 
1204
    di.setCount(count);
1205
    di.setDuration(duration);
1206
    di.add(new Float1D(1));                          
1207
    di.add(new Float1D(alpha));                         
1208
   
1209
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, center);
1210
    }
1211

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

    
1265
///////////////////////////////////////////////////////////////////////////////////////////////////
1266
/**
1267
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1268
 * <p>
1269
 * Here the center of the Effect stays constant.
1270
 *         
1271
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1272
 *                   at any given moment.
1273
 * @param region     Region this Effect is limited to.
1274
 *                   Null here means 'apply the Effect to the whole Object'.
1275
 * @param center     Center of the Effect.
1276
 * @return           ID of the effect added, or -1 if we failed to add one.
1277
 */
1278
  public long brightness(Interpolator1D brightness, Float4D region, Float2D center)
1279
    {
1280
    return mF.add(EffectNames.BRIGHTNESS, brightness, region, center);
1281
    }
1282

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

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

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

    
1380
///////////////////////////////////////////////////////////////////////////////////////////////////
1381
/**
1382
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1383
 * <p>
1384
 * Here the center of the Effect stays constant.
1385
 *         
1386
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1387
 *                   at any given moment.
1388
 * @param region     Region this Effect is limited to.
1389
 *                   Null here means 'apply the Effect to the whole Object'.
1390
 * @param center     Center of the Effect.
1391
 * @return           ID of the effect added, or -1 if we failed to add one.
1392
 */
1393
  public long smooth_brightness(Interpolator1D brightness, Float4D region, Float2D center)
1394
    {
1395
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, brightness, region, center);
1396
    }
1397

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

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

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

    
1498
///////////////////////////////////////////////////////////////////////////////////////////////////
1499
///////////////////////////////////////////////////////////////////////////////////////////////////
1500
// CONTRAST
1501
/**
1502
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1503
 *        
1504
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1505
 *                 at any given moment.
1506
 * @param region   Region this Effect is limited to.
1507
 *                 Null here means 'apply the Effect to the whole Object'.
1508
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D
1509
 *                 representing the current center of the effect.
1510
 * @return         ID of the effect added, or -1 if we failed to add one.
1511
 */
1512
  public long contrast(Interpolator1D contrast, Float4D region, Interpolator2D center)
1513
    {
1514
    return mF.add(EffectNames.CONTRAST, contrast, region, center);
1515
    }
1516

    
1517
///////////////////////////////////////////////////////////////////////////////////////////////////
1518
/**
1519
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1520
 * <p>
1521
 * Here the center of the Effect stays constant.
1522
 *         
1523
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1524
 *                 at any given moment.
1525
 * @param region   Region this Effect is limited to.
1526
 *                 Null here means 'apply the Effect to the whole Object'.
1527
 * @param center  Center of the Effect.
1528
 * @return        ID of the effect added, or -1 if we failed to add one.
1529
 */
1530
  public long contrast(Interpolator1D contrast, Float4D region, Float2D center)
1531
    {
1532
    return mF.add(EffectNames.CONTRAST, contrast, region, center);
1533
    }
1534

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

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

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

    
1632
///////////////////////////////////////////////////////////////////////////////////////////////////
1633
/**
1634
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1635
 * <p>
1636
 * Here the center of the Effect stays constant.
1637
 *         
1638
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1639
 *                 at any given moment.
1640
 * @param region   Region this Effect is limited to.
1641
 *                 Null here means 'apply the Effect to the whole Object'.
1642
 * @param center   Center of the Effect.
1643
 * @return         ID of the effect added, or -1 if we failed to add one.
1644
 */
1645
  public long smooth_contrast(Interpolator1D contrast, Float4D region, Float2D center)
1646
    {
1647
    return mF.add(EffectNames.SMOOTH_CONTRAST, contrast, region, center);
1648
    }
1649

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

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

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

    
1750

    
1751
///////////////////////////////////////////////////////////////////////////////////////////////////
1752
///////////////////////////////////////////////////////////////////////////////////////////////////
1753
// SATURATION
1754
/**
1755
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1756
 *        
1757
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1758
 *                   at any given moment.
1759
 * @param region     Region this Effect is limited to.
1760
 *                   Null here means 'apply the Effect to the whole Object'.
1761
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1762
 *                   representing the current center of the effect.
1763
 * @return           ID of the effect added, or -1 if we failed to add one.
1764
 */
1765
  public long saturation(Interpolator1D saturation, Float4D region, Interpolator2D center)
1766
    {
1767
    return mF.add(EffectNames.SATURATION, saturation, region, center);
1768
    }
1769

    
1770
///////////////////////////////////////////////////////////////////////////////////////////////////
1771
/**
1772
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1773
 * <p>
1774
 * Here the center of the Effect stays constant.
1775
 *         
1776
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1777
 *                   at any given moment.
1778
 * @param region     Region this Effect is limited to.
1779
 *                   Null here means 'apply the Effect to the whole Object'.
1780
 * @param center     Center of the Effect.
1781
 * @return           ID of the effect added, or -1 if we failed to add one.
1782
 */
1783
  public long saturation(Interpolator1D saturation, Float4D region, Float2D center)
1784
    {
1785
    return mF.add(EffectNames.SATURATION, saturation, region, center);
1786
    }
1787

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

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

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

    
1885
///////////////////////////////////////////////////////////////////////////////////////////////////
1886
/**
1887
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1888
 * <p>
1889
 * Here the center of the Effect stays constant.
1890
 *         
1891
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1892
 *                   at any given moment.
1893
 * @param region     Region this Effect is limited to.
1894
 *                   Null here means 'apply the Effect to the whole Object'.
1895
 * @param center     Center of the Effect.
1896
 * @return           ID of the effect added, or -1 if we failed to add one.
1897
 */
1898
  public long smooth_saturation(Interpolator1D saturation, Float4D region, Float2D center)
1899
    {
1900
    return mF.add(EffectNames.SMOOTH_SATURATION, saturation, region, center);
1901
    }
1902

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

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

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

    
2022
///////////////////////////////////////////////////////////////////////////////////////////////////
2023
/**
2024
 * Distort part of the Object by a (possibly changing in time) vector of force.
2025
 * <p>
2026
 * Difference between this and the previous method is that here the center of the Effect stays constant.
2027
 *   
2028
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2029
 *               represents the vector the Center of the Effect is currently being dragged with.
2030
 * @param region Region that masks the effect of the Distortion.
2031
 * @param center Center of the Effect.
2032
 * @return       ID of the effect added, or -1 if we failed to add one. 
2033
 */
2034
  public long distort(Interpolator vector, Float4D region, Float2D center)
2035
    {  
2036
    return mV.add(EffectNames.DISTORT, vector, region, center);
2037
    }
2038

    
2039
///////////////////////////////////////////////////////////////////////////////////////////////////
2040
/**
2041
 * Distort the whole Object by a (possibly changing in time) vector of force.
2042
 * 
2043
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2044
 *               represents the vector the Center of the Effect is currently being dragged with.
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, Float2D center)
2049
    {
2050
    return mV.add(EffectNames.DISTORT, vector, null, center);
2051
    }
2052

    
2053
///////////////////////////////////////////////////////////////////////////////////////////////////
2054
/**
2055
 * Distort part of the Object by a vector of force that changes from (0,0,0) to v.
2056
 * 
2057
 * @param vector   Maximum vector of force. 
2058
 * @param region   Region that masks the effect of the Distortion.
2059
 * @param center   Center of the Effect.
2060
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2061
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2062
 * @return         ID of the effect added, or -1 if we failed to add one. 
2063
 */
2064
  public long distort(Float3D vector, Float4D region, Float2D center, int duration, float count)
2065
    {  
2066
    Interpolator3D di = new Interpolator3D(); 
2067
    di.setCount(count);
2068
    di.setDuration(duration);
2069
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2070
    di.add(vector);                                                  
2071
           
2072
    return mV.add(EffectNames.DISTORT, di, region, center);
2073
    }
2074

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

    
2096
///////////////////////////////////////////////////////////////////////////////////////////////////
2097
/**
2098
 * Distort the whole Object by a vector of force that changes from (0,0,0) to v.
2099
 * <p>
2100
 * Difference between this and the previous method is that here the vector of force will get interpolated
2101
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
2102
 * 
2103
 * @param vector   Maximum, final vector of force.
2104
 * @param center   Center of the Effect.
2105
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2106
 * @return         ID of the effect added, or -1 if we failed to add one. 
2107
 */
2108
  public long distort(Float3D vector, Float2D center, int duration)
2109
    {
2110
    Interpolator3D di = new Interpolator3D();  
2111
    di.setCount(0.5f);
2112
    di.setDuration(duration);
2113
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2114
    di.add(vector);                 
2115
           
2116
    return mV.add(EffectNames.DISTORT, di, null, center);
2117
    }
2118

    
2119
///////////////////////////////////////////////////////////////////////////////////////////////////
2120
/**
2121
 * Distort the whole Object by a vector of force v.
2122
 * <p>
2123
 * Here we apply a constant vector of force.
2124
 * 
2125
 * @param vector Vector of force.
2126
 * @param center Center of the Effect.
2127
 * @return       ID of the effect added, or -1 if we failed to add one. 
2128
 */
2129
  public long distort(Float3D vector, Float2D center )
2130
    {
2131
    Interpolator3D di = new Interpolator3D(); 
2132
    di.setCount(0.5f);
2133
    di.setDuration(0);
2134
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2135
    di.add(vector);           
2136
           
2137
    return mV.add(EffectNames.DISTORT, di, null, center);
2138
    }
2139

    
2140
///////////////////////////////////////////////////////////////////////////////////////////////////
2141
///////////////////////////////////////////////////////////////////////////////////////////////////
2142
// DEFORM
2143
/**
2144
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
2145
 * a (possibly changing in time) point on the Object.
2146
 *     
2147
 * @param vector Interpolator that, at any given time, returns a Float2D representing vector of
2148
 *               force that deforms the shape of the whole Object.
2149
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2150
 *               the Center of the Effect.
2151
 * @return       ID of the effect added, or -1 if we failed to add one.
2152
 */
2153
  public long deform(Interpolator vector, Interpolator2D center)
2154
    {  
2155
    return mV.add(EffectNames.DEFORM, vector, null, center);
2156
    }
2157

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

    
2173
///////////////////////////////////////////////////////////////////////////////////////////////////
2174
/**
2175
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
2176
 * applied to a constant point on the Object.
2177
 * 
2178
 * @param vector   Vector of force.
2179
 * @param center   Center of the Effect.
2180
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2181
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2182
 * @return         ID of the effect added, or -1 if we failed to add one. 
2183
 */
2184
  public long deform(Float3D vector, Float2D center, int duration, float count)
2185
    {
2186
    Interpolator3D di = new Interpolator3D(); 
2187
    di.setCount(count);
2188
    di.setDuration(duration);
2189
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2190
    di.add(vector);                
2191
           
2192
    return mV.add(EffectNames.DEFORM, di, null, center);
2193
    }
2194

    
2195
///////////////////////////////////////////////////////////////////////////////////////////////////
2196
/**
2197
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
2198
 * applied to a constant point on the Object.
2199
 * <p>
2200
 * Identical to calling the previous method with count=0.5.
2201
 * 
2202
 * @param vector   Final vector of force.
2203
 * @param center   Center of the Effect.
2204
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2205
 * @return         ID of the effect added, or -1 if we failed to add one. 
2206
 */
2207
  public long deform(Float3D vector, Float2D center, int duration)
2208
    {
2209
    Interpolator3D di = new Interpolator3D();  
2210
    di.setCount(0.5f);
2211
    di.setDuration(duration);
2212
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2213
    di.add(vector);             
2214
           
2215
    return mV.add(EffectNames.DEFORM, di, null, center);
2216
    }
2217

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

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

    
2301
///////////////////////////////////////////////////////////////////////////////////////////////////
2302
/**
2303
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2304
 * away from the center (degree<=1).
2305
 *   
2306
 * @param sink     How much to push or pull. Between 0 and infinity.
2307
 * @param region   Region that masks the effect of the Sink.
2308
 * @param center   Center of the Effect.
2309
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2310
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2311
 * @return         ID of the effect added, or -1 if we failed to add one. 
2312
 */
2313
  public long sink(float sink, Float4D region, Float2D center, int duration, float count)
2314
    {
2315
    Interpolator1D di = new Interpolator1D(); 
2316
    di.setCount(count);
2317
    di.setDuration(duration);
2318
    di.add(new Float1D(1));                                
2319
    di.add(new Float1D(sink));
2320
    
2321
    return mV.add(EffectNames.SINK, di, region, center);
2322
    }
2323

    
2324
///////////////////////////////////////////////////////////////////////////////////////////////////
2325
/**
2326
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2327
 * away from the center (degree<=1).
2328
 * 
2329
 * @param sink     How much to push or pull. Between 0 and infinity.
2330
 * @param center   Center of the Effect.
2331
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2332
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2333
 * @return         ID of the effect added, or -1 if we failed to add one. 
2334
 */
2335
  public long sink(float sink, Float2D center, int duration, float count)
2336
    {
2337
    Interpolator1D di = new Interpolator1D();  
2338
    di.setCount(count);
2339
    di.setDuration(duration);
2340
    di.add(new Float1D(1));                                
2341
    di.add(new Float1D(sink));
2342
         
2343
    return mV.add(EffectNames.SINK, di, null, center);
2344
    }
2345

    
2346
///////////////////////////////////////////////////////////////////////////////////////////////////
2347
/**
2348
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2349
 * away from the center (degree<=1).
2350
 * <p>
2351
 * Equivalent to calling the previous method with count=0.5.
2352
 * 
2353
 * @param sink     How much to push or pull. Between 0 and infinity.
2354
 * @param center   Center of the Effect.
2355
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2356
 * @return         ID of the effect added, or -1 if we failed to add one. 
2357
 */
2358
  public long sink(float sink, Float2D center, int duration)
2359
    {
2360
    Interpolator1D di = new Interpolator1D(); 
2361
    di.setCount(0.5f);
2362
    di.setDuration(duration);
2363
    di.add(new Float1D(1));                               
2364
    di.add(new Float1D(sink));
2365
        
2366
    return mV.add(EffectNames.SINK, di, null, center);
2367
    }
2368

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

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

    
2449
///////////////////////////////////////////////////////////////////////////////////////////////////
2450
/**
2451
 * Rotate part of the Object around the Center of the Effect by 'degree' angle.
2452
 * <p>
2453
 * Here the Center stays constant.
2454
 *    
2455
 * @param swirl    Angle of rotation. Unit: degrees.
2456
 * @param region   Region that masks the effect of the Swirl.
2457
 * @param center   Center of the Effect.
2458
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2459
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2460
 * @return         ID of the effect added, or -1 if we failed to add one. 
2461
 */
2462
  public long swirl(int swirl, Float4D region, Float2D center, int duration, float count)
2463
    {
2464
    Interpolator1D di = new Interpolator1D(); 
2465
    di.setCount(count);
2466
    di.setDuration(duration);
2467
    di.add(new Float1D(0));                                
2468
    di.add(new Float1D(swirl));
2469
    
2470
    return mV.add(EffectNames.SWIRL, di, region, center);
2471
    }
2472

    
2473
///////////////////////////////////////////////////////////////////////////////////////////////////
2474
/**
2475
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2476
 * 
2477
 * @param swirl    Angle of rotation. Unit: degrees.
2478
 * @param center   Center of the Effect.
2479
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2480
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2481
 * @return         ID of the effect added, or -1 if we failed to add one. 
2482
 */
2483
  public long swirl(int swirl, Float2D center, int duration, float count)
2484
    {
2485
    Interpolator1D di = new Interpolator1D();  
2486
    di.setCount(count);
2487
    di.setDuration(duration);
2488
    di.add(new Float1D(0));                                
2489
    di.add(new Float1D(swirl));
2490
         
2491
    return mV.add(EffectNames.SWIRL, di, null, center);
2492
    }
2493

    
2494
///////////////////////////////////////////////////////////////////////////////////////////////////
2495
/**
2496
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2497
 * <p>
2498
 * Equivalent to calling the previous method with count=0.5.
2499
 * 
2500
 * @param swirl    Angle of rotation. Unit: degrees.
2501
 * @param center   Center of the Effect.
2502
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2503
 * @return         ID of the effect added, or -1 if we failed to add one. 
2504
 */
2505
  public long swirl(int swirl, Float2D center, int duration)
2506
    {
2507
    Interpolator1D di = new Interpolator1D(); 
2508
    di.setCount(0.5f);
2509
    di.setDuration(duration);
2510
    di.add(new Float1D(0));                               
2511
    di.add(new Float1D(swirl));
2512
        
2513
    return mV.add(EffectNames.SWIRL, di, null, center);
2514
    }
2515

    
2516
///////////////////////////////////////////////////////////////////////////////////////////////////
2517
/**
2518
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2519
 * <p>
2520
 * Equivalent to calling the previous method with duration=0.
2521
 * 
2522
 * @param swirl  Angle of rotation. Unit: degrees.
2523
 * @param center Center of the Effect.
2524
 * @return       ID of the effect added, or -1 if we failed to add one. 
2525
 */
2526
  public long swirl(int swirl, Float2D center)
2527
    {
2528
    Interpolator1D di = new Interpolator1D(); 
2529
    di.setCount(0.5f);
2530
    di.setDuration(0);
2531
    di.add(new Float1D(0));                               
2532
    di.add(new Float1D(swirl));
2533
        
2534
    return mV.add(EffectNames.SWIRL, di, null, center);
2535
    }
2536

    
2537
///////////////////////////////////////////////////////////////////////////////////////////////////
2538
///////////////////////////////////////////////////////////////////////////////////////////////////
2539
// WAVE
2540

    
2541
}
(7-7/17)