Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedEffects.java @ 135be991

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.GLES30;
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.Buffer;
42
import java.nio.ByteBuffer;
43
import java.nio.ByteOrder;
44
import java.nio.FloatBuffer;
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47
/**
48
 * Class containing Matrix,Vertex and Fragment effect queues. Postprocessing queue is held in a separate
49
 * class.
50
 * <p>
51
 * The queues hold actual effects to be applied to a given (DistortedTexture,MeshObject) combo.
52
 */
53
public class DistortedEffects
54
  {
55
  /// MAIN PROGRAM ///
56
  private static DistortedProgram mMainProgram;
57
  private static int mMainTextureH;
58
  private static boolean[] mEffectEnabled = new boolean[EffectNames.size()];
59

    
60
  static
61
    {
62
    int len = EffectNames.size();
63

    
64
    for(int i=0; i<len; i++)
65
      {
66
      mEffectEnabled[i] = false;
67
      }
68
    }
69

    
70
  /// BLIT PROGRAM ///
71
  private static DistortedProgram mBlitProgram;
72
  private static int mBlitTextureH;
73
  private static int mBlitDepthH;
74
  private static final FloatBuffer mQuadPositions;
75

    
76
  static
77
    {
78
    float[] positionData= { -0.5f, -0.5f,  -0.5f, 0.5f,  0.5f,-0.5f,  0.5f, 0.5f };
79
    mQuadPositions = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder()).asFloatBuffer();
80
    mQuadPositions.put(positionData).position(0);
81
    }
82

    
83
  /// DEBUG ONLY /////
84
  private static DistortedProgram mDebugProgram;
85

    
86
  private static int mDebugObjDH;
87
  private static int mDebugMVPMatrixH;
88
  /// END DEBUG //////
89

    
90
  private static float[] mMVPMatrix = new float[16];
91
  private static float[] mTmpMatrix = new float[16];
92

    
93
  private static long mNextID =0;
94
  private long mID;
95

    
96
  private EffectQueueMatrix      mM;
97
  private EffectQueueFragment    mF;
98
  private EffectQueueVertex      mV;
99

    
100
  private boolean matrixCloned, vertexCloned, fragmentCloned;
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  static void createProgram(Resources resources)
105
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
106
    {
107
    final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
108
    final InputStream mainFragStream = resources.openRawResource(R.raw.main_fragment_shader);
109

    
110
    String mainVertHeader= Distorted.GLSL_VERSION;
111
    String mainFragHeader= Distorted.GLSL_VERSION;
112

    
113
    EffectNames name;
114
    EffectTypes type;
115
    boolean foundF = false;
116
    boolean foundV = false;
117

    
118
    for(int i=0; i<mEffectEnabled.length; i++)
119
      {
120
      if( mEffectEnabled[i] )
121
        {
122
        name = EffectNames.getName(i);
123
        type = EffectNames.getType(i);
124

    
125
        if( type == EffectTypes.VERTEX )
126
          {
127
          mainVertHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
128
          foundV = true;
129
          }
130
        else if( type == EffectTypes.FRAGMENT )
131
          {
132
          mainFragHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
133
          foundF = true;
134
          }
135
        }
136
      }
137

    
138
    mainVertHeader += ("#define NUM_VERTEX "   + ( foundV ? getMaxVertex()   : 0 ) + "\n");
139
    mainFragHeader += ("#define NUM_FRAGMENT " + ( foundF ? getMaxFragment() : 0 ) + "\n");
140

    
141
    //android.util.Log.e("Effects", "vertHeader= "+mainVertHeader);
142
    //android.util.Log.e("Effects", "fragHeader= "+mainFragHeader);
143

    
144
    String[] feedback = { "v_Position" };
145

    
146
    mMainProgram = new DistortedProgram(mainVertStream,mainFragStream, mainVertHeader, mainFragHeader, Distorted.GLSL, feedback);
147

    
148
    int mainProgramH = mMainProgram.getProgramHandle();
149
    EffectQueueFragment.getUniforms(mainProgramH);
150
    EffectQueueVertex.getUniforms(mainProgramH);
151
    EffectQueueMatrix.getUniforms(mainProgramH);
152
    mMainTextureH= GLES30.glGetUniformLocation( mainProgramH, "u_Texture");
153

    
154
    // BLIT PROGRAM ////////////////////////////////////
155
    final InputStream blitVertStream = resources.openRawResource(R.raw.blit_vertex_shader);
156
    final InputStream blitFragStream = resources.openRawResource(R.raw.blit_fragment_shader);
157

    
158
    String blitVertHeader= (Distorted.GLSL_VERSION + "#define NUM_VERTEX 0\n"  );
159
    String blitFragHeader= (Distorted.GLSL_VERSION + "#define NUM_FRAGMENT 0\n");
160

    
161
    try
162
      {
163
      mBlitProgram = new DistortedProgram(blitVertStream,blitFragStream,blitVertHeader,blitFragHeader, Distorted.GLSL);
164
      }
165
    catch(Exception e)
166
      {
167
      android.util.Log.e("EFFECTS", "exception trying to compile BLIT program: "+e.getMessage());
168
      throw new RuntimeException(e.getMessage());
169
      }
170

    
171
    int blitProgramH = mBlitProgram.getProgramHandle();
172
    mBlitTextureH  = GLES30.glGetUniformLocation( blitProgramH, "u_Texture");
173
    mBlitDepthH    = GLES30.glGetUniformLocation( blitProgramH, "u_Depth");
174

    
175
    // DEBUG ONLY //////////////////////////////////////
176
    final InputStream debugVertexStream   = resources.openRawResource(R.raw.test_vertex_shader);
177
    final InputStream debugFragmentStream = resources.openRawResource(R.raw.test_fragment_shader);
178

    
179
    try
180
      {
181
      mDebugProgram = new DistortedProgram(debugVertexStream,debugFragmentStream, Distorted.GLSL_VERSION, Distorted.GLSL_VERSION, Distorted.GLSL);
182
      }
183
    catch(Exception e)
184
      {
185
      android.util.Log.e("EFFECTS", "exception trying to compile DEBUG program: "+e.getMessage());
186
      throw new RuntimeException(e.getMessage());
187
      }
188

    
189
    int debugProgramH = mDebugProgram.getProgramHandle();
190
    mDebugObjDH = GLES30.glGetUniformLocation( debugProgramH, "u_objD");
191
    mDebugMVPMatrixH = GLES30.glGetUniformLocation( debugProgramH, "u_MVPMatrix");
192
    // END DEBUG  //////////////////////////////////////
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

    
197
  private void initializeEffectLists(DistortedEffects d, int flags)
198
    {
199
    if( (flags & Distorted.CLONE_MATRIX) != 0 )
200
      {
201
      mM = d.mM;
202
      matrixCloned = true;
203
      }
204
    else
205
      {
206
      mM = new EffectQueueMatrix(mID);
207
      matrixCloned = false;
208
      }
209
    
210
    if( (flags & Distorted.CLONE_VERTEX) != 0 )
211
      {
212
      mV = d.mV;
213
      vertexCloned = true;
214
      }
215
    else
216
      {
217
      mV = new EffectQueueVertex(mID);
218
      vertexCloned = false;
219
      }
220
    
221
    if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
222
      {
223
      mF = d.mF;
224
      fragmentCloned = true;
225
      }
226
    else
227
      {
228
      mF = new EffectQueueFragment(mID);
229
      fragmentCloned = false;
230
      }
231
    }
232

    
233
///////////////////////////////////////////////////////////////////////////////////////////////////
234
// DEBUG ONLY
235

    
236
  @SuppressWarnings("unused")
237
  private void displayBoundingRect(float halfX, float halfY, float halfZ, DistortedOutputSurface surface, float[] mvp, float[] vertices, long currTime)
238
    {
239
    int len  = vertices.length/3;
240
    int minx = Integer.MAX_VALUE;
241
    int maxx = Integer.MIN_VALUE;
242
    int miny = Integer.MAX_VALUE;
243
    int maxy = Integer.MIN_VALUE;
244
    int wx,wy;
245

    
246
    float x,y,z, X,Y,W, ndcX,ndcY;
247

    
248
    for(int i=0; i<len; i++)
249
      {
250
      x = 2*halfX*vertices[3*i  ];
251
      y = 2*halfY*vertices[3*i+1];
252
      z = 2*halfZ*vertices[3*i+2];
253

    
254
      X = mvp[ 0]*x + mvp[ 4]*y + mvp[ 8]*z + mvp[12];
255
      Y = mvp[ 1]*x + mvp[ 5]*y + mvp[ 9]*z + mvp[13];
256
      W = mvp[ 3]*x + mvp[ 7]*y + mvp[11]*z + mvp[15];
257

    
258
      ndcX = X/W;
259
      ndcY = Y/W;
260

    
261
      wx = (int)(surface.mWidth *(ndcX+1)/2);
262
      wy = (int)(surface.mHeight*(ndcY+1)/2);
263

    
264
      if( wx<minx ) minx = wx;
265
      if( wx>maxx ) maxx = wx;
266
      if( wy<miny ) miny = wy;
267
      if( wy>maxy ) maxy = wy;
268
      }
269

    
270
    mDebugProgram.useProgram();
271
    surface.setAsOutput(currTime);
272

    
273
    Matrix.setIdentityM( mTmpMatrix, 0);
274
    Matrix.translateM  ( mTmpMatrix, 0, minx-surface.mWidth/2, maxy-surface.mHeight/2, -surface.mDistance);
275
    Matrix.scaleM      ( mTmpMatrix, 0, (float)(maxx-minx)/(2*halfX), (float)(maxy-miny)/(2*halfY), 1.0f);
276
    Matrix.translateM  ( mTmpMatrix, 0, halfX,-halfY, 0);
277
    Matrix.multiplyMM  ( mMVPMatrix, 0, surface.mProjectionMatrix, 0, mTmpMatrix, 0);
278

    
279
    GLES30.glUniform2f(mDebugObjDH, 2*halfX, 2*halfY);
280
    GLES30.glUniformMatrix4fv(mDebugMVPMatrixH, 1, false, mMVPMatrix , 0);
281

    
282
    GLES30.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions);
283
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
284
    }
285

    
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287

    
288
  void drawPriv(float halfW, float halfH, MeshObject mesh, DistortedOutputSurface surface, long currTime)
289
    {
290
    mM.compute(currTime);
291
    mV.compute(currTime);
292
    mF.compute(currTime);
293

    
294
    float halfZ = halfW*mesh.zFactor;
295

    
296
    GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
297

    
298
    mMainProgram.useProgram();
299
    GLES30.glUniform1i(mMainTextureH, 0);
300
    surface.setAsOutput(currTime);
301
    mM.send(surface,halfW,halfH,halfZ);
302
    mM.send(surface,halfW,halfH,halfZ);
303
    mV.send(halfW,halfH,halfZ);
304
    mF.send(halfW,halfH);
305

    
306
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosVBO[0]);
307
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0);
308
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mNorVBO[0]);
309
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE  , GLES30.GL_FLOAT, false, 0, 0);
310
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
311
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
312

    
313
    GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]);
314

    
315
    GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
316
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
317

    
318
    int error = GLES30.glGetError();
319

    
320
    if (error != GLES30.GL_NO_ERROR)
321
      {
322
      throw new RuntimeException("glError 0x" + Integer.toHexString(error));
323
      }
324

    
325
    GLES30.glEndTransformFeedback();
326
    GLES30.glFlush();
327

    
328
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
329

    
330
int len = 3*(mesh.dataLength-2)*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
331

    
332
Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, len, GLES30.GL_MAP_READ_BIT);
333
FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer();
334
FloatBuffer bb = mesh.mMeshPositions;
335

    
336
String msgB = "";
337
for(int d=0; d<mesh.dataLength; d++)
338
  {
339
  msgB+="("+(2*halfW*bb.get(3*d+0))+","+(2*halfH*bb.get(3*d+1))+","+(2*halfZ*bb.get(3*d+2))+")";
340
  }
341
android.util.Log.d( "Feedback", msgB);
342

    
343
String msgA = "";
344
for(int d=0; d<3*(mesh.dataLength-2); d++)
345
  {
346
  if( d==0 || d==1 || ((d-2)%3)==0)
347
     msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")";
348
  }
349
android.util.Log.d( "Feedback", msgA);
350

    
351
android.util.Log.e( "Feedback",msgA.equalsIgnoreCase(msgB) ? "identical":"not identical");
352

    
353

    
354
    /// DEBUG ONLY //////
355
    // displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime );
356
    /// END DEBUG ///////
357

    
358
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER);
359

    
360
    }
361

    
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363
   
364
  static void blitPriv(DistortedOutputSurface surface)
365
    {
366
    mBlitProgram.useProgram();
367

    
368
    GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
369
    GLES30.glUniform1i(mBlitTextureH, 0);
370
    GLES30.glUniform1f( mBlitDepthH , 1.0f-surface.mNear);
371
    GLES30.glVertexAttribPointer(mBlitProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions);
372
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
373
    }
374
    
375
///////////////////////////////////////////////////////////////////////////////////////////////////
376
   
377
  private void releasePriv()
378
    {
379
    if( !matrixCloned     ) mM.abortAll(false);
380
    if( !vertexCloned     ) mV.abortAll(false);
381
    if( !fragmentCloned   ) mF.abortAll(false);
382

    
383
    mM = null;
384
    mV = null;
385
    mF = null;
386
    }
387

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389

    
390
  static void onDestroy()
391
    {
392
    mNextID = 0;
393

    
394
    int len = EffectNames.size();
395

    
396
    for(int i=0; i<len; i++)
397
      {
398
      mEffectEnabled[i] = false;
399
      }
400
    }
401

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403
// PUBLIC API
404
///////////////////////////////////////////////////////////////////////////////////////////////////
405
/**
406
 * Create empty effect queue.
407
 */
408
  public DistortedEffects()
409
    {
410
    mID = ++mNextID;
411
    initializeEffectLists(this,0);
412
    }
413

    
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415
/**
416
 * Copy constructor.
417
 * <p>
418
 * Whatever we do not clone gets created just like in the default constructor.
419
 *
420
 * @param dc    Source object to create our object from
421
 * @param flags A bitmask of values specifying what to copy.
422
 *              For example, CLONE_VERTEX | CLONE_MATRIX.
423
 */
424
  public DistortedEffects(DistortedEffects dc, int flags)
425
    {
426
    mID = ++mNextID;
427
    initializeEffectLists(dc,flags);
428
    }
429

    
430
///////////////////////////////////////////////////////////////////////////////////////////////////
431
/**
432
 * Releases all resources. After this call, the queue should not be used anymore.
433
 */
434
  @SuppressWarnings("unused")
435
  public synchronized void delete()
436
    {
437
    releasePriv();
438
    }
439

    
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441
/**
442
 * Returns unique ID of this instance.
443
 *
444
 * @return ID of the object.
445
 */
446
  public long getID()
447
      {
448
      return mID;
449
      }
450

    
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452
/**
453
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
454
 * to one of the Effects in those queues. Nothing will happen if 'el' is already in the list.
455
 * 
456
 * @param el A class implementing the EffectListener interface that wants to get notifications.
457
 */
458
  @SuppressWarnings("unused")
459
  public void registerForMessages(EffectListener el)
460
    {
461
    mV.registerForMessages(el);
462
    mF.registerForMessages(el);
463
    mM.registerForMessages(el);
464
    }
465

    
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467
/**
468
 * Removes the calling class from the list of Listeners.
469
 * 
470
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
471
 */
472
  @SuppressWarnings("unused")
473
  public void deregisterForMessages(EffectListener el)
474
    {
475
    mV.deregisterForMessages(el);
476
    mF.deregisterForMessages(el);
477
    mM.deregisterForMessages(el);
478
    }
479

    
480
///////////////////////////////////////////////////////////////////////////////////////////////////
481
/**
482
 * Aborts all Effects.
483
 * @return Number of effects aborted.
484
 */
485
  public int abortAllEffects()
486
    {
487
    return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true);
488
    }
489

    
490
///////////////////////////////////////////////////////////////////////////////////////////////////
491
/**
492
 * Aborts all Effects of a given type, for example all MATRIX Effects.
493
 * 
494
 * @param type one of the constants defined in {@link EffectTypes}
495
 * @return Number of effects aborted.
496
 */
497
  public int abortEffects(EffectTypes type)
498
    {
499
    switch(type)
500
      {
501
      case MATRIX     : return mM.abortAll(true);
502
      case VERTEX     : return mV.abortAll(true);
503
      case FRAGMENT   : return mF.abortAll(true);
504
      default         : return 0;
505
      }
506
    }
507
    
508
///////////////////////////////////////////////////////////////////////////////////////////////////
509
/**
510
 * Aborts a single Effect.
511
 * 
512
 * @param id ID of the Effect we want to abort.
513
 * @return number of Effects aborted. Always either 0 or 1.
514
 */
515
  public int abortEffect(long id)
516
    {
517
    int type = (int)(id&EffectTypes.MASK);
518

    
519
    if( type==EffectTypes.MATRIX.type      ) return mM.removeByID(id>>EffectTypes.LENGTH);
520
    if( type==EffectTypes.VERTEX.type      ) return mV.removeByID(id>>EffectTypes.LENGTH);
521
    if( type==EffectTypes.FRAGMENT.type    ) return mF.removeByID(id>>EffectTypes.LENGTH);
522

    
523
    return 0;
524
    }
525

    
526
///////////////////////////////////////////////////////////////////////////////////////////////////
527
/**
528
 * Abort all Effects of a given name, for example all rotations.
529
 * 
530
 * @param name one of the constants defined in {@link EffectNames}
531
 * @return number of Effects aborted.
532
 */
533
  public int abortEffects(EffectNames name)
534
    {
535
    switch(name.getType())
536
      {
537
      case MATRIX     : return mM.removeByType(name);
538
      case VERTEX     : return mV.removeByType(name);
539
      case FRAGMENT   : return mF.removeByType(name);
540
      default         : return 0;
541
      }
542
    }
543
    
544
///////////////////////////////////////////////////////////////////////////////////////////////////
545
/**
546
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
547
 * 
548
 * @param id Effect ID we want to print info about
549
 * @return <code>true</code> if a single Effect of type effectType has been found.
550
 */
551
  @SuppressWarnings("unused")
552
  public boolean printEffect(long id)
553
    {
554
    int type = (int)(id&EffectTypes.MASK);
555

    
556
    if( type==EffectTypes.MATRIX.type  )  return mM.printByID(id>>EffectTypes.LENGTH);
557
    if( type==EffectTypes.VERTEX.type  )  return mV.printByID(id>>EffectTypes.LENGTH);
558
    if( type==EffectTypes.FRAGMENT.type)  return mF.printByID(id>>EffectTypes.LENGTH);
559

    
560
    return false;
561
    }
562

    
563
///////////////////////////////////////////////////////////////////////////////////////////////////
564
/**
565
 * Enables a given Effect.
566
 * <p>
567
 * By default, all effects are disabled. One has to explicitly enable each effect one intends to use.
568
 * This needs to be called BEFORE shaders get compiled, i.e. before the call to Distorted.onCreate().
569
 * The point: by enabling only the effects we need, we can optimize the shaders.
570
 *
571
 * @param name Name of the Effect to enable.
572
 */
573
  public static void enableEffect(EffectNames name)
574
    {
575
    mEffectEnabled[name.ordinal()] = true;
576
    }
577

    
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579
/**
580
 * Returns the maximum number of Matrix effects.
581
 *
582
 * @return The maximum number of Matrix effects
583
 */
584
  @SuppressWarnings("unused")
585
  public static int getMaxMatrix()
586
    {
587
    return EffectQueue.getMax(EffectTypes.MATRIX.ordinal());
588
    }
589

    
590
///////////////////////////////////////////////////////////////////////////////////////////////////
591
/**
592
 * Returns the maximum number of Vertex effects.
593
 *
594
 * @return The maximum number of Vertex effects
595
 */
596
  @SuppressWarnings("unused")
597
  public static int getMaxVertex()
598
    {
599
    return EffectQueue.getMax(EffectTypes.VERTEX.ordinal());
600
    }
601

    
602
///////////////////////////////////////////////////////////////////////////////////////////////////
603
/**
604
 * Returns the maximum number of Fragment effects.
605
 *
606
 * @return The maximum number of Fragment effects
607
 */
608
  @SuppressWarnings("unused")
609
  public static int getMaxFragment()
610
    {
611
    return EffectQueue.getMax(EffectTypes.FRAGMENT.ordinal());
612
    }
613

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

    
636
///////////////////////////////////////////////////////////////////////////////////////////////////
637
/**
638
 * Sets the maximum number of Vertex effects that can be stored in a single EffectQueue at one time.
639
 * This can fail if:
640
 * <ul>
641
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
642
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
643
 *     before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
644
 *     time only decreasing the value of 'max' is permitted.
645
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
646
 * </ul>
647
 *
648
 * @param max new maximum number of simultaneous Vertex Effects. Has to be a non-negative number not greater
649
 *            than Byte.MAX_VALUE
650
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
651
 */
652
  @SuppressWarnings("unused")
653
  public static boolean setMaxVertex(int max)
654
    {
655
    return EffectQueue.setMax(EffectTypes.VERTEX.ordinal(),max);
656
    }
657

    
658
///////////////////////////////////////////////////////////////////////////////////////////////////
659
/**
660
 * Sets the maximum number of Fragment effects that can be stored in a single EffectQueue at one time.
661
 * This can fail if:
662
 * <ul>
663
 * <li>the value of 'max' is outside permitted range (0 &le; max &le; Byte.MAX_VALUE)
664
 * <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
665
 *     before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
666
 *     time only decreasing the value of 'max' is permitted.
667
 * <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
668
 * </ul>
669
 *
670
 * @param max new maximum number of simultaneous Fragment Effects. Has to be a non-negative number not greater
671
 *            than Byte.MAX_VALUE
672
 * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
673
 */
674
  @SuppressWarnings("unused")
675
  public static boolean setMaxFragment(int max)
676
    {
677
    return EffectQueue.setMax(EffectTypes.FRAGMENT.ordinal(),max);
678
    }
679

    
680
///////////////////////////////////////////////////////////////////////////////////////////////////   
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682
// Individual effect functions.
683
///////////////////////////////////////////////////////////////////////////////////////////////////
684
// Matrix-based effects
685
///////////////////////////////////////////////////////////////////////////////////////////////////
686
/**
687
 * Moves the Object by a (possibly changing in time) vector.
688
 * 
689
 * @param vector 3-dimensional Data which at any given time will return a Static3D
690
 *               representing the current coordinates of the vector we want to move the Object with.
691
 * @return       ID of the effect added, or -1 if we failed to add one.
692
 */
693
  public long move(Data3D vector)
694
    {   
695
    return mM.add(EffectNames.MOVE,vector);
696
    }
697

    
698
///////////////////////////////////////////////////////////////////////////////////////////////////
699
/**
700
 * Scales the Object by (possibly changing in time) 3D scale factors.
701
 * 
702
 * @param scale 3-dimensional Data which at any given time returns a Static3D
703
 *              representing the current x- , y- and z- scale factors.
704
 * @return      ID of the effect added, or -1 if we failed to add one.
705
 */
706
  public long scale(Data3D scale)
707
    {   
708
    return mM.add(EffectNames.SCALE,scale);
709
    }
710

    
711
///////////////////////////////////////////////////////////////////////////////////////////////////
712
/**
713
 * Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
714
 *
715
 * @param scale The factor to scale all 3 dimensions with.
716
 * @return      ID of the effect added, or -1 if we failed to add one.
717
 */
718
  public long scale(float scale)
719
    {
720
    return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
721
    }
722

    
723
///////////////////////////////////////////////////////////////////////////////////////////////////
724
/**
725
 * Rotates the Object by 'angle' degrees around the center.
726
 * Static axis of rotation is given by the last parameter.
727
 *
728
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
729
 * @param axis   Axis of rotation
730
 * @param center Coordinates of the Point we are rotating around.
731
 * @return       ID of the effect added, or -1 if we failed to add one.
732
 */
733
  public long rotate(Data1D angle, Static3D axis, Data3D center )
734
    {   
735
    return mM.add(EffectNames.ROTATE, angle, axis, center);
736
    }
737

    
738
///////////////////////////////////////////////////////////////////////////////////////////////////
739
/**
740
 * Rotates the Object by 'angle' degrees around the center.
741
 * Here both angle and axis can dynamically change.
742
 *
743
 * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
744
 * @param center    Coordinates of the Point we are rotating around.
745
 * @return          ID of the effect added, or -1 if we failed to add one.
746
 */
747
  public long rotate(Data4D angleaxis, Data3D center)
748
    {
749
    return mM.add(EffectNames.ROTATE, angleaxis, center);
750
    }
751

    
752
///////////////////////////////////////////////////////////////////////////////////////////////////
753
/**
754
 * Rotates the Object by quaternion.
755
 *
756
 * @param quaternion The quaternion describing the rotation.
757
 * @param center     Coordinates of the Point we are rotating around.
758
 * @return           ID of the effect added, or -1 if we failed to add one.
759
 */
760
  public long quaternion(Data4D quaternion, Data3D center )
761
    {
762
    return mM.add(EffectNames.QUATERNION,quaternion,center);
763
    }
764

    
765
///////////////////////////////////////////////////////////////////////////////////////////////////
766
/**
767
 * Shears the Object.
768
 *
769
 * @param shear   The 3-tuple of shear factors. The first controls level
770
 *                of shearing in the X-axis, second - Y-axis and the third -
771
 *                Z-axis. Each is the tangens of the shear angle, i.e 0 -
772
 *                no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
773
 * @param center  Center of shearing, i.e. the point which stays unmoved.
774
 * @return        ID of the effect added, or -1 if we failed to add one.
775
 */
776
  public long shear(Data3D shear, Data3D center)
777
    {
778
    return mM.add(EffectNames.SHEAR, shear, center);
779
    }
780

    
781
///////////////////////////////////////////////////////////////////////////////////////////////////
782
// Fragment-based effects  
783
///////////////////////////////////////////////////////////////////////////////////////////////////
784
/**
785
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
786
 *        
787
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
788
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
789
 *               Valid range: <0,1>
790
 * @param color  Color to mix. (1,0,0) is RED.
791
 * @param region Region this Effect is limited to.
792
 * @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
793
 * @return       ID of the effect added, or -1 if we failed to add one.
794
 */
795
  public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
796
    {
797
    return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
798
    }
799

    
800
///////////////////////////////////////////////////////////////////////////////////////////////////
801
/**
802
 * Makes the whole Object smoothly change all three of its RGB components.
803
 *
804
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
805
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
806
 *               Valid range: <0,1>
807
 * @param color  Color to mix. (1,0,0) is RED.
808
 * @return       ID of the effect added, or -1 if we failed to add one.
809
 */
810
  public long chroma(Data1D blend, Data3D color)
811
    {
812
    return mF.add(EffectNames.CHROMA, blend, color);
813
    }
814

    
815
///////////////////////////////////////////////////////////////////////////////////////////////////
816
/**
817
 * Makes a certain sub-region of the Object smoothly change its transparency level.
818
 *        
819
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any given
820
 *               moment: pixel.a *= alpha.
821
 *               Valid range: <0,1>
822
 * @param region Region this Effect is limited to. 
823
 * @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
824
 * @return       ID of the effect added, or -1 if we failed to add one. 
825
 */
826
  public long alpha(Data1D alpha, Data4D region, boolean smooth)
827
    {
828
    return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
829
    }
830

    
831
///////////////////////////////////////////////////////////////////////////////////////////////////
832
/**
833
 * Makes the whole Object smoothly change its transparency level.
834
 *
835
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any
836
 *               given moment: pixel.a *= alpha.
837
 *               Valid range: <0,1>
838
 * @return       ID of the effect added, or -1 if we failed to add one.
839
 */
840
  public long alpha(Data1D alpha)
841
    {
842
    return mF.add(EffectNames.ALPHA, alpha);
843
    }
844

    
845
///////////////////////////////////////////////////////////////////////////////////////////////////
846
/**
847
 * Makes a certain sub-region of the Object smoothly change its brightness level.
848
 *        
849
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
850
 *                   at any given moment. Valid range: <0,infinity)
851
 * @param region     Region this Effect is limited to.
852
 * @param smooth     If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
853
 * @return           ID of the effect added, or -1 if we failed to add one.
854
 */
855
  public long brightness(Data1D brightness, Data4D region, boolean smooth)
856
    {
857
    return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
858
    }
859

    
860
///////////////////////////////////////////////////////////////////////////////////////////////////
861
/**
862
 * Makes the whole Object smoothly change its brightness level.
863
 *
864
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
865
 *                   at any given moment. Valid range: <0,infinity)
866
 * @return           ID of the effect added, or -1 if we failed to add one.
867
 */
868
  public long brightness(Data1D brightness)
869
    {
870
    return mF.add(EffectNames.BRIGHTNESS, brightness);
871
    }
872

    
873
///////////////////////////////////////////////////////////////////////////////////////////////////
874
/**
875
 * Makes a certain sub-region of the Object smoothly change its contrast level.
876
 *        
877
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
878
 *                 at any given moment. Valid range: <0,infinity)
879
 * @param region   Region this Effect is limited to.
880
 * @param smooth   If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
881
 * @return         ID of the effect added, or -1 if we failed to add one.
882
 */
883
  public long contrast(Data1D contrast, Data4D region, boolean smooth)
884
    {
885
    return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
886
    }
887

    
888
///////////////////////////////////////////////////////////////////////////////////////////////////
889
/**
890
 * Makes the whole Object smoothly change its contrast level.
891
 *
892
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
893
 *                 at any given moment. Valid range: <0,infinity)
894
 * @return         ID of the effect added, or -1 if we failed to add one.
895
 */
896
  public long contrast(Data1D contrast)
897
    {
898
    return mF.add(EffectNames.CONTRAST, contrast);
899
    }
900

    
901
///////////////////////////////////////////////////////////////////////////////////////////////////
902
/**
903
 * Makes a certain sub-region of the Object smoothly change its saturation level.
904
 *        
905
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
906
 *                   at any given moment. Valid range: <0,infinity)
907
 * @param region     Region this Effect is limited to.
908
 * @param smooth     If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
909
 * @return           ID of the effect added, or -1 if we failed to add one.
910
 */
911
  public long saturation(Data1D saturation, Data4D region, boolean smooth)
912
    {
913
    return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
914
    }
915

    
916
///////////////////////////////////////////////////////////////////////////////////////////////////
917
/**
918
 * Makes the whole Object smoothly change its saturation level.
919
 *
920
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
921
 *                   at any given moment. Valid range: <0,infinity)
922
 * @return           ID of the effect added, or -1 if we failed to add one.
923
 */
924
  public long saturation(Data1D saturation)
925
    {
926
    return mF.add(EffectNames.SATURATION, saturation);
927
    }
928

    
929
///////////////////////////////////////////////////////////////////////////////////////////////////
930
// Vertex-based effects  
931
///////////////////////////////////////////////////////////////////////////////////////////////////
932
/**
933
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
934
 *
935
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
936
 *               currently being dragged with.
937
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
938
 * @param region Region that masks the Effect.
939
 * @return       ID of the effect added, or -1 if we failed to add one.
940
 */
941
  public long distort(Data3D vector, Data3D center, Data4D region)
942
    {  
943
    return mV.add(EffectNames.DISTORT, vector, center, region);
944
    }
945

    
946
///////////////////////////////////////////////////////////////////////////////////////////////////
947
/**
948
 * Distort the whole Object by a (possibly changing in time) vector of force.
949
 *
950
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
951
 *               currently being dragged with.
952
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
953
 * @return       ID of the effect added, or -1 if we failed to add one.
954
 */
955
  public long distort(Data3D vector, Data3D center)
956
    {
957
    return mV.add(EffectNames.DISTORT, vector, center, null);
958
    }
959

    
960
///////////////////////////////////////////////////////////////////////////////////////////////////
961
/**
962
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
963
 * a (possibly changing in time) point on the Object.
964
 *
965
 * @param vector Vector of force that deforms the shape of the whole Object.
966
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
967
 * @param region Region that masks the Effect.
968
 * @return       ID of the effect added, or -1 if we failed to add one.
969
 */
970
  public long deform(Data3D vector, Data3D center, Data4D region)
971
    {
972
    return mV.add(EffectNames.DEFORM, vector, center, region);
973
    }
974

    
975
///////////////////////////////////////////////////////////////////////////////////////////////////
976
/**
977
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
978
 * a (possibly changing in time) point on the Object.
979
 *     
980
 * @param vector Vector of force that deforms the shape of the whole Object.
981
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
982
 * @return       ID of the effect added, or -1 if we failed to add one.
983
 */
984
  public long deform(Data3D vector, Data3D center)
985
    {  
986
    return mV.add(EffectNames.DEFORM, vector, center, null);
987
    }
988

    
989
///////////////////////////////////////////////////////////////////////////////////////////////////  
990
/**
991
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
992
 * away from the center (degree<=1)
993
 *
994
 * @param sink   The current degree of the Effect.
995
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
996
 * @param region Region that masks the Effect.
997
 * @return       ID of the effect added, or -1 if we failed to add one.
998
 */
999
  public long sink(Data1D sink, Data3D center, Data4D region)
1000
    {
1001
    return mV.add(EffectNames.SINK, sink, center, region);
1002
    }
1003

    
1004
///////////////////////////////////////////////////////////////////////////////////////////////////
1005
/**
1006
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
1007
 * away from the center (degree<=1)
1008
 *
1009
 * @param sink   The current degree of the Effect.
1010
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1011
 * @return       ID of the effect added, or -1 if we failed to add one.
1012
 */
1013
  public long sink(Data1D sink, Data3D center)
1014
    {
1015
    return mV.add(EffectNames.SINK, sink, center);
1016
    }
1017

    
1018
///////////////////////////////////////////////////////////////////////////////////////////////////
1019
/**
1020
 * Pull all points around the center of the Effect towards a line passing through the center
1021
 * (that's if degree>=1) or push them away from the line (degree<=1)
1022
 *
1023
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
1024
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1025
 * @param region Region that masks the Effect.
1026
 * @return       ID of the effect added, or -1 if we failed to add one.
1027
 */
1028
  public long pinch(Data2D pinch, Data3D center, Data4D region)
1029
    {
1030
    return mV.add(EffectNames.PINCH, pinch, center, region);
1031
    }
1032

    
1033
///////////////////////////////////////////////////////////////////////////////////////////////////
1034
/**
1035
 * Pull all points around the center of the Effect towards a line passing through the center
1036
 * (that's if degree>=1) or push them away from the line (degree<=1)
1037
 *
1038
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
1039
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1040
 * @return       ID of the effect added, or -1 if we failed to add one.
1041
 */
1042
  public long pinch(Data2D pinch, Data3D center)
1043
    {
1044
    return mV.add(EffectNames.PINCH, pinch, center);
1045
    }
1046

    
1047
///////////////////////////////////////////////////////////////////////////////////////////////////  
1048
/**
1049
 * Rotate part of the Object around the Center of the Effect by a certain angle.
1050
 *
1051
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
1052
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1053
 * @param region Region that masks the Effect.
1054
 * @return       ID of the effect added, or -1 if we failed to add one.
1055
 */
1056
  public long swirl(Data1D swirl, Data3D center, Data4D region)
1057
    {    
1058
    return mV.add(EffectNames.SWIRL, swirl, center, region);
1059
    }
1060

    
1061
///////////////////////////////////////////////////////////////////////////////////////////////////
1062
/**
1063
 * Rotate the whole Object around the Center of the Effect by a certain angle.
1064
 *
1065
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
1066
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1067
 * @return       ID of the effect added, or -1 if we failed to add one.
1068
 */
1069
  public long swirl(Data1D swirl, Data3D center)
1070
    {
1071
    return mV.add(EffectNames.SWIRL, swirl, center);
1072
    }
1073

    
1074
///////////////////////////////////////////////////////////////////////////////////////////////////
1075
/**
1076
 * Directional, sinusoidal wave effect.
1077
 *
1078
 * @param wave   A 5-dimensional data structure describing the wave: first member is the amplitude,
1079
 *               second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
1080
 *               wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
1081
 *               describe the 'direction' of the wave.
1082
 *               <p>
1083
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
1084
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
1085
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
1086
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
1087
 *               <p>
1088
 *               <p>
1089
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
1090
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
1091
 *               will be sine shapes.
1092
 *               <p>
1093
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
1094
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
1095
 *               YZ-plane with be sine shapes.
1096
 *               <p>
1097
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
1098
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
1099
 *               value if sin at this point.
1100
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1101
 * @return       ID of the effect added, or -1 if we failed to add one.
1102
 */
1103
  public long wave(Data5D wave, Data3D center)
1104
    {
1105
    return mV.add(EffectNames.WAVE, wave, center, null);
1106
    }
1107

    
1108
///////////////////////////////////////////////////////////////////////////////////////////////////
1109
/**
1110
 * Directional, sinusoidal wave effect.
1111
 *
1112
 * @param wave   see {@link DistortedEffects#wave(Data5D,Data3D)}
1113
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1114
 * @param region Region that masks the Effect.
1115
 * @return       ID of the effect added, or -1 if we failed to add one.
1116
 */
1117
  public long wave(Data5D wave, Data3D center, Data4D region)
1118
    {
1119
    return mV.add(EffectNames.WAVE, wave, center, region);
1120
    }
1121
  }
(2-2/26)