Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedEffects.java @ f44ea591

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.content.res.Resources;
23
import android.opengl.GLES20;
24
import android.opengl.Matrix;
25

    
26
import org.distorted.library.message.EffectListener;
27
import org.distorted.library.program.DistortedProgram;
28
import org.distorted.library.program.FragmentCompilationException;
29
import org.distorted.library.program.FragmentUniformsException;
30
import org.distorted.library.program.LinkingException;
31
import org.distorted.library.program.VertexCompilationException;
32
import org.distorted.library.program.VertexUniformsException;
33
import org.distorted.library.type.Data1D;
34
import org.distorted.library.type.Data2D;
35
import org.distorted.library.type.Data3D;
36
import org.distorted.library.type.Data4D;
37
import org.distorted.library.type.Data5D;
38
import org.distorted.library.type.Static3D;
39

    
40
import java.io.InputStream;
41
import java.nio.ByteBuffer;
42
import java.nio.ByteOrder;
43
import java.nio.FloatBuffer;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
/**
47
 * Class containing {@link EffectTypes#LENGTH} queues, each a class derived from EffectQueue.
48
 * <p>
49
 * The queues hold actual effects to be applied to a given (DistortedTexture,MeshObject) combo.
50
 */
51
public class DistortedEffects
52
  {
53
  private static final int POSITION_DATA_SIZE= 3; // Main Program: size of the position data in elements
54
  private static final int NORMAL_DATA_SIZE  = 3; // Main Program: size of the normal data in elements
55
  private static final int TEX_DATA_SIZE     = 2; // Main Program: size of the texture coordinate data in elements.
56

    
57
  private static DistortedProgram mProgram;
58

    
59
  /// DEBUG ONLY /////
60
  private static DistortedProgram mDebugProgram;
61
  private static final FloatBuffer mQuadPositions;
62

    
63
  static
64
    {
65
    float[] positionData= { -0.5f, -0.5f,  -0.5f, 0.5f,  0.5f,-0.5f,  0.5f, 0.5f };
66
    mQuadPositions = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder()).asFloatBuffer();
67
    mQuadPositions.put(positionData).position(0);
68
    }
69

    
70
  private static int mObjDH;
71
  private static int mMVPMatrixH;
72
  /// END DEBUG //////
73

    
74
  private static float[] mMVPMatrix = new float[16];
75
  private static float[] mTmpMatrix = new float[16];
76

    
77
  private static long mNextID =0;
78
  private long mID;
79

    
80
  private static DistortedFramebuffer mBufferFBO = new DistortedFramebuffer(1,1);
81

    
82
  private EffectQueueMatrix      mM;
83
  private EffectQueueFragment    mF;
84
  private EffectQueueVertex      mV;
85
  private EffectQueuePostprocess mP;
86

    
87
  private boolean matrixCloned, vertexCloned, fragmentCloned, postprocessCloned;
88

    
89
private int mL, mR, mT, mB;
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

    
93
  static void createProgram(Resources resources)
94
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
95
    {
96
    final InputStream mainVertexStream   = resources.openRawResource(R.raw.main_vertex_shader);
97
    final InputStream mainFragmentStream = resources.openRawResource(R.raw.main_fragment_shader);
98

    
99
    String mainVertexHeader= ("#version 100\n#define NUM_VERTEX "  + getMaxVertex()+"\n");
100

    
101
    for(EffectNames name: EffectNames.values() )
102
      {
103
      if( name.getType()== EffectTypes.VERTEX)
104
        mainVertexHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
105
      }
106

    
107
    String mainFragmentHeader= ("#version 100\n#define NUM_FRAGMENT "  + getMaxFragment()+"\n");
108

    
109
    for(EffectNames name: EffectNames.values() )
110
      {
111
      if( name.getType()== EffectTypes.FRAGMENT)
112
        mainFragmentHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
113
      }
114

    
115
    mProgram = new DistortedProgram(mainVertexStream,mainFragmentStream, mainVertexHeader, mainFragmentHeader);
116

    
117
    int mainProgramH = mProgram.getProgramHandle();
118
    EffectQueueFragment.getUniforms(mainProgramH);
119
    EffectQueueVertex.getUniforms(mainProgramH);
120
    EffectQueueMatrix.getUniforms(mainProgramH);
121
    DistortedTexture.getUniforms(mainProgramH);
122

    
123
    // DEBUG ONLY //////////////////////////////////////
124
    final InputStream debugVertexStream   = resources.openRawResource(R.raw.test_vertex_shader);
125
    final InputStream debugFragmentStream = resources.openRawResource(R.raw.test_fragment_shader);
126

    
127
    mDebugProgram = new DistortedProgram(debugVertexStream,debugFragmentStream, "#version 100\n", "#version 100\n");
128

    
129
    int debugProgramH = mDebugProgram.getProgramHandle();
130
    mObjDH      = GLES20.glGetUniformLocation( debugProgramH, "u_objD");
131
    mMVPMatrixH = GLES20.glGetUniformLocation( debugProgramH, "u_MVPMatrix");
132
    // END DEBUG  //////////////////////////////////////
133
    }
134

    
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136

    
137
  private void initializeEffectLists(DistortedEffects d, int flags)
138
    {
139
    if( (flags & Distorted.CLONE_MATRIX) != 0 )
140
      {
141
      mM = d.mM;
142
      matrixCloned = true;
143
      }
144
    else
145
      {
146
      mM = new EffectQueueMatrix(mID);
147
      matrixCloned = false;
148
      }
149
    
150
    if( (flags & Distorted.CLONE_VERTEX) != 0 )
151
      {
152
      mV = d.mV;
153
      vertexCloned = true;
154
      }
155
    else
156
      {
157
      mV = new EffectQueueVertex(mID);
158
      vertexCloned = false;
159
      }
160
    
161
    if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
162
      {
163
      mF = d.mF;
164
      fragmentCloned = true;
165
      }
166
    else
167
      {
168
      mF = new EffectQueueFragment(mID);
169
      fragmentCloned = false;
170
      }
171

    
172
    if( (flags & Distorted.CLONE_POSTPROCESS) != 0 )
173
      {
174
      mP = d.mP;
175
      postprocessCloned = true;
176
      }
177
    else
178
      {
179
      mP = new EffectQueuePostprocess(mID);
180
      postprocessCloned = false;
181
      }
182
    }
183

    
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185
// DEBUG ONLY
186

    
187
  private void displayBoundingRect(float halfX, float halfY, float halfZ, DistortedFramebuffer df, float[] mvp, float[] vertices)
188
    {
189
    int len  = vertices.length/3;
190
    int minx = Integer.MAX_VALUE;
191
    int maxx = Integer.MIN_VALUE;
192
    int miny = Integer.MAX_VALUE;
193
    int maxy = Integer.MIN_VALUE;
194
    int wx,wy;
195

    
196
int l=-1,r=-1,t=-1,b=-1;
197

    
198
    float x,y,z, X,Y,W, ndcX,ndcY;
199

    
200
    for(int i=0; i<len; i++)
201
      {
202
      x = 2*halfX*vertices[3*i  ];
203
      y = 2*halfY*vertices[3*i+1];
204
      z = 2*halfZ*vertices[3*i+2];
205

    
206
      X = mvp[ 0]*x + mvp[ 4]*y + mvp[ 8]*z + mvp[12];
207
      Y = mvp[ 1]*x + mvp[ 5]*y + mvp[ 9]*z + mvp[13];
208
      W = mvp[ 3]*x + mvp[ 7]*y + mvp[11]*z + mvp[15];
209

    
210
      ndcX = X/W;
211
      ndcY = Y/W;
212

    
213
      wx = (int)(df.mWidth *(ndcX+1)/2);
214
      wy = (int)(df.mHeight*(ndcY+1)/2);
215

    
216
      if( wx<minx ) { minx = wx; l = i; }
217
      if( wx>maxx ) { maxx = wx; r = i; }
218
      if( wy<miny ) { miny = wy; t = i; }
219
      if( wy>maxy ) { maxy = wy; b = i; }
220
      }
221

    
222
    mDebugProgram.useProgram();
223
    df.setAsOutput();
224

    
225
    Matrix.setIdentityM(mTmpMatrix, 0);
226
    Matrix.translateM(mTmpMatrix, 0, -df.mWidth/2, df.mHeight/2, -df.mDistance);
227

    
228
    Matrix.translateM(mTmpMatrix, 0, minx, -df.mHeight+maxy, 0.0f);
229
    Matrix.scaleM(mTmpMatrix, 0, (float)(maxx-minx)/(2*halfX), (float)(maxy-miny)/(2*halfY), 1.0f);
230

    
231
    Matrix.translateM(mTmpMatrix, 0, halfX,-halfY, 0);
232
    Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
233

    
234
    GLES20.glUniform2f( mObjDH , 2*halfX, 2*halfY);
235
    GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
236

    
237
    GLES20.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES20.GL_FLOAT, false, 0, mQuadPositions);
238
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
239

    
240
    if( l!=mL )
241
      {
242
      mL = l;
243
      android.util.Log.e("effects", "l="+l+" ("+vertices[3*l]+","+vertices[3*l+1]+","+vertices[3*l+2]+")");
244
      }
245
    }
246

    
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248

    
249
  void drawPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df, long currTime)
250
    {
251
    mM.compute(currTime);
252
    mV.compute(currTime);
253
    mF.compute(currTime);
254
    mP.compute(currTime);
255

    
256
    float halfZ = halfInputW*mesh.zFactor;
257
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
258

    
259
    if( mP.mNumEffects==0 )
260
      {
261
      mProgram.useProgram();
262
      df.setAsOutput();
263
      mM.send(df,halfInputW,halfInputH,halfZ);
264
      mV.send(halfInputW,halfInputH,halfZ);
265
      mF.send(halfInputW,halfInputH);
266
      GLES20.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mesh.mMeshPositions);
267
      GLES20.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mesh.mMeshNormals);
268
      GLES20.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mesh.mMeshTexture);
269
      GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
270
      }
271
    else
272
      {
273
      if( mV.mNumEffects==0 && mF.mNumEffects==0 && (mesh instanceof MeshFlat) && mM.canUseShortcut() )
274
        {
275
        mM.constructMatrices(df,halfInputW,halfInputH);
276
        mP.render(2*halfInputW, 2*halfInputH, mM.getMVP(), df);
277
        }
278
      else
279
        {
280
        mProgram.useProgram();
281
        mBufferFBO.resizeFast(df.mWidth, df.mHeight);
282
        mBufferFBO.setAsOutput();
283
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
284
        GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
285
        mM.send(mBufferFBO,halfInputW,halfInputH,halfZ);
286
        mV.send(halfInputW,halfInputH,halfZ);
287
        mF.send(halfInputW,halfInputH);
288
        GLES20.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mesh.mMeshPositions);
289
        GLES20.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mesh.mMeshNormals);
290
        GLES20.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mesh.mMeshTexture);
291
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
292

    
293
        Matrix.setIdentityM(mTmpMatrix, 0);
294
        Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
295
        Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
296

    
297
        mBufferFBO.setAsInput();
298
        mP.render(df.mWidth, df.mHeight, mMVPMatrix, df);
299
        }
300
      }
301

    
302
    /// DEBUG ONLY //////
303
    displayBoundingRect(halfInputH, halfInputW, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
304
    /// END DEBUG ///////
305
    }
306

    
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308
   
309
  static void drawNoEffectsPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df)
310
    {
311
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
312

    
313
    Matrix.setIdentityM(mTmpMatrix, 0);
314
    Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
315
    Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
316

    
317
    EffectQueueMatrix.sendZero(df,halfInputW,halfInputH,halfInputW*mesh.zFactor);
318
    EffectQueueVertex.sendZero();
319
    EffectQueueFragment.sendZero();
320
    EffectQueuePostprocess.sendZero(df.mWidth, df.mHeight, mMVPMatrix);
321

    
322
    GLES20.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mesh.mMeshPositions);
323
    GLES20.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mesh.mMeshNormals);
324
    GLES20.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mesh.mMeshTexture);
325
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
326
    }
327
    
328
///////////////////////////////////////////////////////////////////////////////////////////////////
329
   
330
  private void releasePriv()
331
    {
332
    if( !matrixCloned     ) mM.abortAll(false);
333
    if( !vertexCloned     ) mV.abortAll(false);
334
    if( !fragmentCloned   ) mF.abortAll(false);
335
    if( !postprocessCloned) mP.abortAll(false);
336

    
337
    mM = null;
338
    mV = null;
339
    mF = null;
340
    mP = null;
341
    }
342

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

    
345
  static void onDestroy()
346
    {
347
    mNextID = 0;
348
    }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351
// PUBLIC API
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353
/**
354
 * Create empty effect queue.
355
 */
356
  public DistortedEffects()
357
    {
358
    mID = mNextID++;
359
    initializeEffectLists(this,0);
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363
/**
364
 * Copy constructor.
365
 * <p>
366
 * Whatever we do not clone gets created just like in the default constructor.
367
 *
368
 * @param dc    Source object to create our object from
369
 * @param flags A bitmask of values specifying what to copy.
370
 *              For example, CLONE_VERTEX | CLONE_MATRIX.
371
 */
372
  public DistortedEffects(DistortedEffects dc, int flags)
373
    {
374
    mID = mNextID++;
375
    initializeEffectLists(dc,flags);
376
    }
377

    
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
/**
380
 * Releases all resources. After this call, the queue should not be used anymore.
381
 */
382
  public synchronized void delete()
383
    {
384
    releasePriv();
385
    }
386

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388
/**
389
 * Returns unique ID of this instance.
390
 *
391
 * @return ID of the object.
392
 */
393
  public long getID()
394
      {
395
      return mID;
396
      }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399
/**
400
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
401
 * to one of the Effects in those queues. Nothing will happen if 'el' is already in the list.
402
 * 
403
 * @param el A class implementing the EffectListener interface that wants to get notifications.
404
 */
405
  public void registerForMessages(EffectListener el)
406
    {
407
    mV.registerForMessages(el);
408
    mF.registerForMessages(el);
409
    mM.registerForMessages(el);
410
    mP.registerForMessages(el);
411
    }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414
/**
415
 * Removes the calling class from the list of Listeners.
416
 * 
417
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
418
 */
419
  public void deregisterForMessages(EffectListener el)
420
    {
421
    mV.deregisterForMessages(el);
422
    mF.deregisterForMessages(el);
423
    mM.deregisterForMessages(el);
424
    mP.deregisterForMessages(el);
425
    }
426

    
427
///////////////////////////////////////////////////////////////////////////////////////////////////
428
/**
429
 * Aborts all Effects.
430
 * @return Number of effects aborted.
431
 */
432
  public int abortAllEffects()
433
      {
434
      return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true) + mP.abortAll(true);
435
      }
436

    
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438
/**
439
 * Aborts all Effects of a given type, for example all MATRIX Effects.
440
 * 
441
 * @param type one of the constants defined in {@link EffectTypes}
442
 * @return Number of effects aborted.
443
 */
444
  public int abortEffects(EffectTypes type)
445
    {
446
    switch(type)
447
      {
448
      case MATRIX     : return mM.abortAll(true);
449
      case VERTEX     : return mV.abortAll(true);
450
      case FRAGMENT   : return mF.abortAll(true);
451
      case POSTPROCESS: return mP.abortAll(true);
452
      default         : return 0;
453
      }
454
    }
455
    
456
///////////////////////////////////////////////////////////////////////////////////////////////////
457
/**
458
 * Aborts a single Effect.
459
 * 
460
 * @param id ID of the Effect we want to abort.
461
 * @return number of Effects aborted. Always either 0 or 1.
462
 */
463
  public int abortEffect(long id)
464
    {
465
    int type = (int)(id&EffectTypes.MASK);
466

    
467
    if( type==EffectTypes.MATRIX.type      ) return mM.removeByID(id>>EffectTypes.LENGTH);
468
    if( type==EffectTypes.VERTEX.type      ) return mV.removeByID(id>>EffectTypes.LENGTH);
469
    if( type==EffectTypes.FRAGMENT.type    ) return mF.removeByID(id>>EffectTypes.LENGTH);
470
    if( type==EffectTypes.POSTPROCESS.type ) return mP.removeByID(id>>EffectTypes.LENGTH);
471

    
472
    return 0;
473
    }
474

    
475
///////////////////////////////////////////////////////////////////////////////////////////////////
476
/**
477
 * Abort all Effects of a given name, for example all rotations.
478
 * 
479
 * @param name one of the constants defined in {@link EffectNames}
480
 * @return number of Effects aborted.
481
 */
482
  public int abortEffects(EffectNames name)
483
    {
484
    switch(name.getType())
485
      {
486
      case MATRIX     : return mM.removeByType(name);
487
      case VERTEX     : return mV.removeByType(name);
488
      case FRAGMENT   : return mF.removeByType(name);
489
      case POSTPROCESS: return mP.removeByType(name);
490
      default         : return 0;
491
      }
492
    }
493
    
494
///////////////////////////////////////////////////////////////////////////////////////////////////
495
/**
496
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
497
 * 
498
 * @param id Effect ID we want to print info about
499
 * @return <code>true</code> if a single Effect of type effectType has been found.
500
 */
501
    
502
  public boolean printEffect(long id)
503
    {
504
    int type = (int)(id&EffectTypes.MASK);
505

    
506
    if( type==EffectTypes.MATRIX.type      )  return mM.printByID(id>>EffectTypes.LENGTH);
507
    if( type==EffectTypes.VERTEX.type      )  return mV.printByID(id>>EffectTypes.LENGTH);
508
    if( type==EffectTypes.FRAGMENT.type    )  return mF.printByID(id>>EffectTypes.LENGTH);
509
    if( type==EffectTypes.POSTPROCESS.type )  return mP.printByID(id>>EffectTypes.LENGTH);
510

    
511
    return false;
512
    }
513

    
514
///////////////////////////////////////////////////////////////////////////////////////////////////
515
/**
516
 * Returns the maximum number of Matrix effects.
517
 *
518
 * @return The maximum number of Matrix effects
519
 */
520
  public static int getMaxMatrix()
521
    {
522
    return EffectQueue.getMax(EffectTypes.MATRIX.ordinal());
523
    }
524

    
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526
/**
527
 * Returns the maximum number of Vertex effects.
528
 *
529
 * @return The maximum number of Vertex effects
530
 */
531
  public static int getMaxVertex()
532
    {
533
    return EffectQueue.getMax(EffectTypes.VERTEX.ordinal());
534
    }
535

    
536
///////////////////////////////////////////////////////////////////////////////////////////////////
537
/**
538
 * Returns the maximum number of Fragment effects.
539
 *
540
 * @return The maximum number of Fragment effects
541
 */
542
  public static int getMaxFragment()
543
    {
544
    return EffectQueue.getMax(EffectTypes.FRAGMENT.ordinal());
545
    }
546

    
547
///////////////////////////////////////////////////////////////////////////////////////////////////
548
/**
549
 * Returns the maximum number of Postprocess effects.
550
 *
551
 * @return The maximum number of Postprocess effects
552
 */
553
  public static int getMaxPostprocess()
554
    {
555
    return EffectQueue.getMax(EffectTypes.POSTPROCESS.ordinal());
556
    }
557

    
558
///////////////////////////////////////////////////////////////////////////////////////////////////
559
/**
560
 * Sets the maximum number of Matrix effects that can be stored in a single EffectQueue at one time.
561
 * This can fail if:
562
 * <ul>
563
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
564
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
565
 *     before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
566
 *     time only decreasing the value of 'max' is permitted.
567
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
568
 * </ul>
569
 *
570
 * @param max new maximum number of simultaneous Matrix Effects. Has to be a non-negative number not greater
571
 *            than Byte.MAX_VALUE
572
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
573
 */
574
  public static boolean setMaxMatrix(int max)
575
    {
576
    return EffectQueue.setMax(EffectTypes.MATRIX.ordinal(),max);
577
    }
578

    
579
///////////////////////////////////////////////////////////////////////////////////////////////////
580
/**
581
 * Sets the maximum number of Vertex effects that can be stored in a single EffectQueue at one time.
582
 * This can fail if:
583
 * <ul>
584
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
585
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
586
 *     before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
587
 *     time only decreasing the value of 'max' is permitted.
588
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
589
 * </ul>
590
 *
591
 * @param max new maximum number of simultaneous Vertex Effects. Has to be a non-negative number not greater
592
 *            than Byte.MAX_VALUE
593
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
594
 */
595
  public static boolean setMaxVertex(int max)
596
    {
597
    return EffectQueue.setMax(EffectTypes.VERTEX.ordinal(),max);
598
    }
599

    
600
///////////////////////////////////////////////////////////////////////////////////////////////////
601
/**
602
 * Sets the maximum number of Fragment effects that can be stored in a single EffectQueue at one time.
603
 * This can fail if:
604
 * <ul>
605
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
606
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
607
 *     before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
608
 *     time only decreasing the value of 'max' is permitted.
609
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
610
 * </ul>
611
 *
612
 * @param max new maximum number of simultaneous Fragment Effects. Has to be a non-negative number not greater
613
 *            than Byte.MAX_VALUE
614
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
615
 */
616
  public static boolean setMaxFragment(int max)
617
    {
618
    return EffectQueue.setMax(EffectTypes.FRAGMENT.ordinal(),max);
619
    }
620

    
621
///////////////////////////////////////////////////////////////////////////////////////////////////
622
/**
623
 * Sets the maximum number of Postprocess effects that can be stored in a single EffectQueue at one time.
624
 * This can fail if:
625
 * <ul>
626
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
627
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
628
 *     before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
629
 *     time only decreasing the value of 'max' is permitted.
630
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
631
 * </ul>
632
 *
633
 * @param max new maximum number of simultaneous Postprocess Effects. Has to be a non-negative number not greater
634
 *            than Byte.MAX_VALUE
635
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
636
 */
637
  public static boolean setMaxPostprocess(int max)
638
    {
639
    return EffectQueue.setMax(EffectTypes.POSTPROCESS.ordinal(),max);
640
    }
641

    
642
///////////////////////////////////////////////////////////////////////////////////////////////////   
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
// Individual effect functions.
645
///////////////////////////////////////////////////////////////////////////////////////////////////
646
// Matrix-based effects
647
///////////////////////////////////////////////////////////////////////////////////////////////////
648
/**
649
 * Moves the Object by a (possibly changing in time) vector.
650
 * 
651
 * @param vector 3-dimensional Data which at any given time will return a Static3D
652
 *               representing the current coordinates of the vector we want to move the Object with.
653
 * @return       ID of the effect added, or -1 if we failed to add one.
654
 */
655
  public long move(Data3D vector)
656
    {   
657
    return mM.add(EffectNames.MOVE,vector);
658
    }
659

    
660
///////////////////////////////////////////////////////////////////////////////////////////////////
661
/**
662
 * Scales the Object by (possibly changing in time) 3D scale factors.
663
 * 
664
 * @param scale 3-dimensional Data which at any given time returns a Static3D
665
 *              representing the current x- , y- and z- scale factors.
666
 * @return      ID of the effect added, or -1 if we failed to add one.
667
 */
668
  public long scale(Data3D scale)
669
    {   
670
    return mM.add(EffectNames.SCALE,scale);
671
    }
672

    
673
///////////////////////////////////////////////////////////////////////////////////////////////////
674
/**
675
 * Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
676
 *
677
 * @param scale The factor to scale all 3 dimensions with.
678
 * @return      ID of the effect added, or -1 if we failed to add one.
679
 */
680
  public long scale(float scale)
681
    {
682
    return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
683
    }
684

    
685
///////////////////////////////////////////////////////////////////////////////////////////////////
686
/**
687
 * Rotates the Object by 'angle' degrees around the center.
688
 * Static axis of rotation is given by the last parameter.
689
 *
690
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
691
 * @param axis   Axis of rotation
692
 * @param center Coordinates of the Point we are rotating around.
693
 * @return       ID of the effect added, or -1 if we failed to add one.
694
 */
695
  public long rotate(Data1D angle, Static3D axis, Data3D center )
696
    {   
697
    return mM.add(EffectNames.ROTATE, angle, axis, center);
698
    }
699

    
700
///////////////////////////////////////////////////////////////////////////////////////////////////
701
/**
702
 * Rotates the Object by 'angle' degrees around the center.
703
 * Here both angle and axis can dynamically change.
704
 *
705
 * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
706
 * @param center    Coordinates of the Point we are rotating around.
707
 * @return          ID of the effect added, or -1 if we failed to add one.
708
 */
709
  public long rotate(Data4D angleaxis, Data3D center)
710
    {
711
    return mM.add(EffectNames.ROTATE, angleaxis, center);
712
    }
713

    
714
///////////////////////////////////////////////////////////////////////////////////////////////////
715
/**
716
 * Rotates the Object by quaternion.
717
 *
718
 * @param quaternion The quaternion describing the rotation.
719
 * @param center     Coordinates of the Point we are rotating around.
720
 * @return           ID of the effect added, or -1 if we failed to add one.
721
 */
722
  public long quaternion(Data4D quaternion, Data3D center )
723
    {
724
    return mM.add(EffectNames.QUATERNION,quaternion,center);
725
    }
726

    
727
///////////////////////////////////////////////////////////////////////////////////////////////////
728
/**
729
 * Shears the Object.
730
 *
731
 * @param shear   The 3-tuple of shear factors. The first controls level
732
 *                of shearing in the X-axis, second - Y-axis and the third -
733
 *                Z-axis. Each is the tangens of the shear angle, i.e 0 -
734
 *                no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
735
 * @param center  Center of shearing, i.e. the point which stays unmoved.
736
 * @return        ID of the effect added, or -1 if we failed to add one.
737
 */
738
  public long shear(Data3D shear, Data3D center)
739
    {
740
    return mM.add(EffectNames.SHEAR, shear, center);
741
    }
742

    
743
///////////////////////////////////////////////////////////////////////////////////////////////////
744
// Fragment-based effects  
745
///////////////////////////////////////////////////////////////////////////////////////////////////
746
/**
747
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
748
 *        
749
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
750
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
751
 *               Valid range: <0,1>
752
 * @param color  Color to mix. (1,0,0) is RED.
753
 * @param region Region this Effect is limited to.
754
 * @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
755
 * @return       ID of the effect added, or -1 if we failed to add one.
756
 */
757
  public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
758
    {
759
    return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
760
    }
761

    
762
///////////////////////////////////////////////////////////////////////////////////////////////////
763
/**
764
 * Makes the whole Object smoothly change all three of its RGB components.
765
 *
766
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
767
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
768
 *               Valid range: <0,1>
769
 * @param color  Color to mix. (1,0,0) is RED.
770
 * @return       ID of the effect added, or -1 if we failed to add one.
771
 */
772
  public long chroma(Data1D blend, Data3D color)
773
    {
774
    return mF.add(EffectNames.CHROMA, blend, color);
775
    }
776

    
777
///////////////////////////////////////////////////////////////////////////////////////////////////
778
/**
779
 * Makes a certain sub-region of the Object smoothly change its transparency level.
780
 *        
781
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any given
782
 *               moment: pixel.a *= alpha.
783
 *               Valid range: <0,1>
784
 * @param region Region this Effect is limited to. 
785
 * @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
786
 * @return       ID of the effect added, or -1 if we failed to add one. 
787
 */
788
  public long alpha(Data1D alpha, Data4D region, boolean smooth)
789
    {
790
    return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
791
    }
792

    
793
///////////////////////////////////////////////////////////////////////////////////////////////////
794
/**
795
 * Makes the whole Object smoothly change its transparency level.
796
 *
797
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any
798
 *               given moment: pixel.a *= alpha.
799
 *               Valid range: <0,1>
800
 * @return       ID of the effect added, or -1 if we failed to add one.
801
 */
802
  public long alpha(Data1D alpha)
803
    {
804
    return mF.add(EffectNames.ALPHA, alpha);
805
    }
806

    
807
///////////////////////////////////////////////////////////////////////////////////////////////////
808
/**
809
 * Makes a certain sub-region of the Object smoothly change its brightness level.
810
 *        
811
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
812
 *                   at any given moment. Valid range: <0,infinity)
813
 * @param region     Region this Effect is limited to.
814
 * @param smooth     If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
815
 * @return           ID of the effect added, or -1 if we failed to add one.
816
 */
817
  public long brightness(Data1D brightness, Data4D region, boolean smooth)
818
    {
819
    return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
820
    }
821

    
822
///////////////////////////////////////////////////////////////////////////////////////////////////
823
/**
824
 * Makes the whole Object smoothly change its brightness level.
825
 *
826
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
827
 *                   at any given moment. Valid range: <0,infinity)
828
 * @return           ID of the effect added, or -1 if we failed to add one.
829
 */
830
  public long brightness(Data1D brightness)
831
    {
832
    return mF.add(EffectNames.BRIGHTNESS, brightness);
833
    }
834

    
835
///////////////////////////////////////////////////////////////////////////////////////////////////
836
/**
837
 * Makes a certain sub-region of the Object smoothly change its contrast level.
838
 *        
839
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
840
 *                 at any given moment. Valid range: <0,infinity)
841
 * @param region   Region this Effect is limited to.
842
 * @param smooth   If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
843
 * @return         ID of the effect added, or -1 if we failed to add one.
844
 */
845
  public long contrast(Data1D contrast, Data4D region, boolean smooth)
846
    {
847
    return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
848
    }
849

    
850
///////////////////////////////////////////////////////////////////////////////////////////////////
851
/**
852
 * Makes the whole Object smoothly change its contrast level.
853
 *
854
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
855
 *                 at any given moment. Valid range: <0,infinity)
856
 * @return         ID of the effect added, or -1 if we failed to add one.
857
 */
858
  public long contrast(Data1D contrast)
859
    {
860
    return mF.add(EffectNames.CONTRAST, contrast);
861
    }
862

    
863
///////////////////////////////////////////////////////////////////////////////////////////////////
864
/**
865
 * Makes a certain sub-region of the Object smoothly change its saturation level.
866
 *        
867
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
868
 *                   at any given moment. Valid range: <0,infinity)
869
 * @param region     Region this Effect is limited to.
870
 * @param smooth     If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
871
 * @return           ID of the effect added, or -1 if we failed to add one.
872
 */
873
  public long saturation(Data1D saturation, Data4D region, boolean smooth)
874
    {
875
    return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
876
    }
877

    
878
///////////////////////////////////////////////////////////////////////////////////////////////////
879
/**
880
 * Makes the whole Object smoothly change its saturation level.
881
 *
882
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
883
 *                   at any given moment. Valid range: <0,infinity)
884
 * @return           ID of the effect added, or -1 if we failed to add one.
885
 */
886
  public long saturation(Data1D saturation)
887
    {
888
    return mF.add(EffectNames.SATURATION, saturation);
889
    }
890

    
891
///////////////////////////////////////////////////////////////////////////////////////////////////
892
// Vertex-based effects  
893
///////////////////////////////////////////////////////////////////////////////////////////////////
894
/**
895
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
896
 *
897
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
898
 *               currently being dragged with.
899
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
900
 * @param region Region that masks the Effect.
901
 * @return       ID of the effect added, or -1 if we failed to add one.
902
 */
903
  public long distort(Data3D vector, Data3D center, Data4D region)
904
    {  
905
    return mV.add(EffectNames.DISTORT, vector, center, region);
906
    }
907

    
908
///////////////////////////////////////////////////////////////////////////////////////////////////
909
/**
910
 * Distort the whole Object by a (possibly changing in time) vector of force.
911
 *
912
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
913
 *               currently being dragged with.
914
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
915
 * @return       ID of the effect added, or -1 if we failed to add one.
916
 */
917
  public long distort(Data3D vector, Data3D center)
918
    {
919
    return mV.add(EffectNames.DISTORT, vector, center, null);
920
    }
921

    
922
///////////////////////////////////////////////////////////////////////////////////////////////////
923
/**
924
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
925
 * a (possibly changing in time) point on the Object.
926
 *
927
 * @param vector Vector of force that deforms the shape of the whole Object.
928
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
929
 * @param region Region that masks the Effect.
930
 * @return       ID of the effect added, or -1 if we failed to add one.
931
 */
932
  public long deform(Data3D vector, Data3D center, Data4D region)
933
    {
934
    return mV.add(EffectNames.DEFORM, vector, center, region);
935
    }
936

    
937
///////////////////////////////////////////////////////////////////////////////////////////////////
938
/**
939
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
940
 * a (possibly changing in time) point on the Object.
941
 *     
942
 * @param vector Vector of force that deforms the shape of the whole Object.
943
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
944
 * @return       ID of the effect added, or -1 if we failed to add one.
945
 */
946
  public long deform(Data3D vector, Data3D center)
947
    {  
948
    return mV.add(EffectNames.DEFORM, vector, center, null);
949
    }
950

    
951
///////////////////////////////////////////////////////////////////////////////////////////////////  
952
/**
953
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
954
 * away from the center (degree<=1)
955
 *
956
 * @param sink   The current degree of the Effect.
957
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
958
 * @param region Region that masks the Effect.
959
 * @return       ID of the effect added, or -1 if we failed to add one.
960
 */
961
  public long sink(Data1D sink, Data3D center, Data4D region)
962
    {
963
    return mV.add(EffectNames.SINK, sink, center, region);
964
    }
965

    
966
///////////////////////////////////////////////////////////////////////////////////////////////////
967
/**
968
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
969
 * away from the center (degree<=1)
970
 *
971
 * @param sink   The current degree of the Effect.
972
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
973
 * @return       ID of the effect added, or -1 if we failed to add one.
974
 */
975
  public long sink(Data1D sink, Data3D center)
976
    {
977
    return mV.add(EffectNames.SINK, sink, center);
978
    }
979

    
980
///////////////////////////////////////////////////////////////////////////////////////////////////
981
/**
982
 * Pull all points around the center of the Effect towards a line passing through the center
983
 * (that's if degree>=1) or push them away from the line (degree<=1)
984
 *
985
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
986
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
987
 * @param region Region that masks the Effect.
988
 * @return       ID of the effect added, or -1 if we failed to add one.
989
 */
990
  public long pinch(Data2D pinch, Data3D center, Data4D region)
991
    {
992
    return mV.add(EffectNames.PINCH, pinch, center, region);
993
    }
994

    
995
///////////////////////////////////////////////////////////////////////////////////////////////////
996
/**
997
 * Pull all points around the center of the Effect towards a line passing through the center
998
 * (that's if degree>=1) or push them away from the line (degree<=1)
999
 *
1000
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
1001
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1002
 * @return       ID of the effect added, or -1 if we failed to add one.
1003
 */
1004
  public long pinch(Data2D pinch, Data3D center)
1005
    {
1006
    return mV.add(EffectNames.PINCH, pinch, center);
1007
    }
1008

    
1009
///////////////////////////////////////////////////////////////////////////////////////////////////  
1010
/**
1011
 * Rotate part of the Object around the Center of the Effect by a certain angle.
1012
 *
1013
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
1014
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1015
 * @param region Region that masks the Effect.
1016
 * @return       ID of the effect added, or -1 if we failed to add one.
1017
 */
1018
  public long swirl(Data1D swirl, Data3D center, Data4D region)
1019
    {    
1020
    return mV.add(EffectNames.SWIRL, swirl, center, region);
1021
    }
1022

    
1023
///////////////////////////////////////////////////////////////////////////////////////////////////
1024
/**
1025
 * Rotate the whole Object around the Center of the Effect by a certain angle.
1026
 *
1027
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
1028
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1029
 * @return       ID of the effect added, or -1 if we failed to add one.
1030
 */
1031
  public long swirl(Data1D swirl, Data3D center)
1032
    {
1033
    return mV.add(EffectNames.SWIRL, swirl, center);
1034
    }
1035

    
1036
///////////////////////////////////////////////////////////////////////////////////////////////////
1037
/**
1038
 * Directional, sinusoidal wave effect.
1039
 *
1040
 * @param wave   A 5-dimensional data structure describing the wave: first member is the amplitude,
1041
 *               second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
1042
 *               wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
1043
 *               describe the 'direction' of the wave.
1044
 *               <p>
1045
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
1046
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
1047
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
1048
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
1049
 *               <p>
1050
 *               <p>
1051
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
1052
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
1053
 *               will be sine shapes.
1054
 *               <p>
1055
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
1056
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
1057
 *               YZ-plane with be sine shapes.
1058
 *               <p>
1059
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
1060
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
1061
 *               value if sin at this point.
1062
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1063
 * @return       ID of the effect added, or -1 if we failed to add one.
1064
 */
1065
  public long wave(Data5D wave, Data3D center)
1066
    {
1067
    return mV.add(EffectNames.WAVE, wave, center, null);
1068
    }
1069

    
1070
///////////////////////////////////////////////////////////////////////////////////////////////////
1071
/**
1072
 * Directional, sinusoidal wave effect.
1073
 *
1074
 * @param wave   see {@link DistortedEffects#wave(Data5D,Data3D)}
1075
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1076
 * @param region Region that masks the Effect.
1077
 * @return       ID of the effect added, or -1 if we failed to add one.
1078
 */
1079
  public long wave(Data5D wave, Data3D center, Data4D region)
1080
    {
1081
    return mV.add(EffectNames.WAVE, wave, center, region);
1082
    }
1083

    
1084
///////////////////////////////////////////////////////////////////////////////////////////////////
1085
// Postprocess-based effects
1086
///////////////////////////////////////////////////////////////////////////////////////////////////
1087
/**
1088
 * Blur the object.
1089
 *
1090
 * @param radius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
1091
 *               take into account 10 pixels in each direction.
1092
 * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
1093
 * @return ID of the effect added, or -1 if we failed to add one.
1094
 */
1095
  public long blur(Data1D radius, Data2D center)
1096
    {
1097
    return mP.add(EffectNames.BLUR, radius, center);
1098
    }
1099
  }
(2-2/16)