Project

General

Profile

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

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

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
///////////////////////////////////////////////////////////////////////////////////////////////////
90

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

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

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

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

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

    
113
    mProgram = new DistortedProgram(mainVertexStream,mainFragmentStream, mainVertexHeader, mainFragmentHeader);
114

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

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

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

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

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

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

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

    
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183
// DEBUG ONLY
184

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

    
194
    float x,y,z, X,Y,W, ndcX,ndcY;
195

    
196
    for(int i=0; i<len; i++)
197
      {
198
      x = 2*halfX*vertices[3*i  ];
199
      y = 2*halfY*vertices[3*i+1];
200
      z = 2*halfZ*vertices[3*i+2];
201

    
202
      X = mvp[ 0]*x + mvp[ 4]*y + mvp[ 8]*z + mvp[12];
203
      Y = mvp[ 1]*x + mvp[ 5]*y + mvp[ 9]*z + mvp[13];
204
      W = mvp[ 3]*x + mvp[ 7]*y + mvp[11]*z + mvp[15];
205

    
206
      ndcX = X/W;
207
      ndcY = Y/W;
208

    
209
      wx = (int)(df.mWidth *(ndcX+1)/2);
210
      wy = (int)(df.mHeight*(ndcY+1)/2);
211

    
212
      if( wx<minx ) minx = wx;
213
      if( wx>maxx ) maxx = wx;
214
      if( wy<miny ) miny = wy;
215
      if( wy>maxy ) maxy = wy;
216
      }
217

    
218
    mDebugProgram.useProgram();
219
    df.setAsOutput();
220

    
221
    Matrix.setIdentityM(mTmpMatrix, 0);
222
    Matrix.translateM(mTmpMatrix, 0, -df.mWidth/2, df.mHeight/2, -df.mDistance);
223

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

    
227
    Matrix.translateM(mTmpMatrix, 0, halfX,-halfY, 0);
228
    Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
229

    
230
    GLES20.glUniform2f( mObjDH , 2*halfX, 2*halfY);
231
    GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
232

    
233
    GLES20.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES20.GL_FLOAT, false, 0, mQuadPositions);
234
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
235
    }
236

    
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

    
239
  void drawPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df, long currTime)
240
    {
241
    mM.compute(currTime);
242
    mV.compute(currTime);
243
    mF.compute(currTime);
244
    mP.compute(currTime);
245

    
246
    float halfZ = halfInputW*mesh.zFactor;
247
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
248

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

    
283
        Matrix.setIdentityM(mTmpMatrix, 0);
284
        Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
285
        Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
286

    
287
        mBufferFBO.setAsInput();
288
        mP.render(df.mWidth, df.mHeight, mMVPMatrix, df);
289
        }
290
      }
291

    
292
    /// DEBUG ONLY //////
293
    displayBoundingRect(halfInputH, halfInputW, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
294
    /// END DEBUG ///////
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
   
299
  static void drawNoEffectsPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df)
300
    {
301
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
302

    
303
    Matrix.setIdentityM(mTmpMatrix, 0);
304
    Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
305
    Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
306

    
307
    EffectQueueMatrix.sendZero(df,halfInputW,halfInputH,halfInputW*mesh.zFactor);
308
    EffectQueueVertex.sendZero();
309
    EffectQueueFragment.sendZero();
310
    EffectQueuePostprocess.sendZero(df.mWidth, df.mHeight, mMVPMatrix);
311

    
312
    GLES20.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mesh.mMeshPositions);
313
    GLES20.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mesh.mMeshNormals);
314
    GLES20.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mesh.mMeshTexture);
315
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
316
    }
317
    
318
///////////////////////////////////////////////////////////////////////////////////////////////////
319
   
320
  private void releasePriv()
321
    {
322
    if( !matrixCloned     ) mM.abortAll(false);
323
    if( !vertexCloned     ) mV.abortAll(false);
324
    if( !fragmentCloned   ) mF.abortAll(false);
325
    if( !postprocessCloned) mP.abortAll(false);
326

    
327
    mM = null;
328
    mV = null;
329
    mF = null;
330
    mP = null;
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
  static void onDestroy()
336
    {
337
    mNextID = 0;
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341
// PUBLIC API
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343
/**
344
 * Create empty effect queue.
345
 */
346
  public DistortedEffects()
347
    {
348
    mID = mNextID++;
349
    initializeEffectLists(this,0);
350
    }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353
/**
354
 * Copy constructor.
355
 * <p>
356
 * Whatever we do not clone gets created just like in the default constructor.
357
 *
358
 * @param dc    Source object to create our object from
359
 * @param flags A bitmask of values specifying what to copy.
360
 *              For example, CLONE_VERTEX | CLONE_MATRIX.
361
 */
362
  public DistortedEffects(DistortedEffects dc, int flags)
363
    {
364
    mID = mNextID++;
365
    initializeEffectLists(dc,flags);
366
    }
367

    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
/**
370
 * Releases all resources. After this call, the queue should not be used anymore.
371
 */
372
  public synchronized void delete()
373
    {
374
    releasePriv();
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378
/**
379
 * Returns unique ID of this instance.
380
 *
381
 * @return ID of the object.
382
 */
383
  public long getID()
384
      {
385
      return mID;
386
      }
387

    
388
///////////////////////////////////////////////////////////////////////////////////////////////////
389
/**
390
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
391
 * to one of the Effects in those queues. Nothing will happen if 'el' is already in the list.
392
 * 
393
 * @param el A class implementing the EffectListener interface that wants to get notifications.
394
 */
395
  public void registerForMessages(EffectListener el)
396
    {
397
    mV.registerForMessages(el);
398
    mF.registerForMessages(el);
399
    mM.registerForMessages(el);
400
    mP.registerForMessages(el);
401
    }
402

    
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404
/**
405
 * Removes the calling class from the list of Listeners.
406
 * 
407
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
408
 */
409
  public void deregisterForMessages(EffectListener el)
410
    {
411
    mV.deregisterForMessages(el);
412
    mF.deregisterForMessages(el);
413
    mM.deregisterForMessages(el);
414
    mP.deregisterForMessages(el);
415
    }
416

    
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418
/**
419
 * Aborts all Effects.
420
 * @return Number of effects aborted.
421
 */
422
  public int abortAllEffects()
423
      {
424
      return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true) + mP.abortAll(true);
425
      }
426

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

    
457
    if( type==EffectTypes.MATRIX.type      ) return mM.removeByID(id>>EffectTypes.LENGTH);
458
    if( type==EffectTypes.VERTEX.type      ) return mV.removeByID(id>>EffectTypes.LENGTH);
459
    if( type==EffectTypes.FRAGMENT.type    ) return mF.removeByID(id>>EffectTypes.LENGTH);
460
    if( type==EffectTypes.POSTPROCESS.type ) return mP.removeByID(id>>EffectTypes.LENGTH);
461

    
462
    return 0;
463
    }
464

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

    
496
    if( type==EffectTypes.MATRIX.type      )  return mM.printByID(id>>EffectTypes.LENGTH);
497
    if( type==EffectTypes.VERTEX.type      )  return mV.printByID(id>>EffectTypes.LENGTH);
498
    if( type==EffectTypes.FRAGMENT.type    )  return mF.printByID(id>>EffectTypes.LENGTH);
499
    if( type==EffectTypes.POSTPROCESS.type )  return mP.printByID(id>>EffectTypes.LENGTH);
500

    
501
    return false;
502
    }
503

    
504
///////////////////////////////////////////////////////////////////////////////////////////////////
505
/**
506
 * Returns the maximum number of Matrix effects.
507
 *
508
 * @return The maximum number of Matrix effects
509
 */
510
  public static int getMaxMatrix()
511
    {
512
    return EffectQueue.getMax(EffectTypes.MATRIX.ordinal());
513
    }
514

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

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

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

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

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

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

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

    
632
///////////////////////////////////////////////////////////////////////////////////////////////////   
633
///////////////////////////////////////////////////////////////////////////////////////////////////
634
// Individual effect functions.
635
///////////////////////////////////////////////////////////////////////////////////////////////////
636
// Matrix-based effects
637
///////////////////////////////////////////////////////////////////////////////////////////////////
638
/**
639
 * Moves the Object by a (possibly changing in time) vector.
640
 * 
641
 * @param vector 3-dimensional Data which at any given time will return a Static3D
642
 *               representing the current coordinates of the vector we want to move the Object with.
643
 * @return       ID of the effect added, or -1 if we failed to add one.
644
 */
645
  public long move(Data3D vector)
646
    {   
647
    return mM.add(EffectNames.MOVE,vector);
648
    }
649

    
650
///////////////////////////////////////////////////////////////////////////////////////////////////
651
/**
652
 * Scales the Object by (possibly changing in time) 3D scale factors.
653
 * 
654
 * @param scale 3-dimensional Data which at any given time returns a Static3D
655
 *              representing the current x- , y- and z- scale factors.
656
 * @return      ID of the effect added, or -1 if we failed to add one.
657
 */
658
  public long scale(Data3D scale)
659
    {   
660
    return mM.add(EffectNames.SCALE,scale);
661
    }
662

    
663
///////////////////////////////////////////////////////////////////////////////////////////////////
664
/**
665
 * Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
666
 *
667
 * @param scale The factor to scale all 3 dimensions with.
668
 * @return      ID of the effect added, or -1 if we failed to add one.
669
 */
670
  public long scale(float scale)
671
    {
672
    return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
673
    }
674

    
675
///////////////////////////////////////////////////////////////////////////////////////////////////
676
/**
677
 * Rotates the Object by 'angle' degrees around the center.
678
 * Static axis of rotation is given by the last parameter.
679
 *
680
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
681
 * @param axis   Axis of rotation
682
 * @param center Coordinates of the Point we are rotating around.
683
 * @return       ID of the effect added, or -1 if we failed to add one.
684
 */
685
  public long rotate(Data1D angle, Static3D axis, Data3D center )
686
    {   
687
    return mM.add(EffectNames.ROTATE, angle, axis, center);
688
    }
689

    
690
///////////////////////////////////////////////////////////////////////////////////////////////////
691
/**
692
 * Rotates the Object by 'angle' degrees around the center.
693
 * Here both angle and axis can dynamically change.
694
 *
695
 * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
696
 * @param center    Coordinates of the Point we are rotating around.
697
 * @return          ID of the effect added, or -1 if we failed to add one.
698
 */
699
  public long rotate(Data4D angleaxis, Data3D center)
700
    {
701
    return mM.add(EffectNames.ROTATE, angleaxis, center);
702
    }
703

    
704
///////////////////////////////////////////////////////////////////////////////////////////////////
705
/**
706
 * Rotates the Object by quaternion.
707
 *
708
 * @param quaternion The quaternion describing the rotation.
709
 * @param center     Coordinates of the Point we are rotating around.
710
 * @return           ID of the effect added, or -1 if we failed to add one.
711
 */
712
  public long quaternion(Data4D quaternion, Data3D center )
713
    {
714
    return mM.add(EffectNames.QUATERNION,quaternion,center);
715
    }
716

    
717
///////////////////////////////////////////////////////////////////////////////////////////////////
718
/**
719
 * Shears the Object.
720
 *
721
 * @param shear   The 3-tuple of shear factors. The first controls level
722
 *                of shearing in the X-axis, second - Y-axis and the third -
723
 *                Z-axis. Each is the tangens of the shear angle, i.e 0 -
724
 *                no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
725
 * @param center  Center of shearing, i.e. the point which stays unmoved.
726
 * @return        ID of the effect added, or -1 if we failed to add one.
727
 */
728
  public long shear(Data3D shear, Data3D center)
729
    {
730
    return mM.add(EffectNames.SHEAR, shear, center);
731
    }
732

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

    
752
///////////////////////////////////////////////////////////////////////////////////////////////////
753
/**
754
 * Makes the whole Object smoothly change all three of its RGB components.
755
 *
756
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
757
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
758
 *               Valid range: <0,1>
759
 * @param color  Color to mix. (1,0,0) is RED.
760
 * @return       ID of the effect added, or -1 if we failed to add one.
761
 */
762
  public long chroma(Data1D blend, Data3D color)
763
    {
764
    return mF.add(EffectNames.CHROMA, blend, color);
765
    }
766

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

    
783
///////////////////////////////////////////////////////////////////////////////////////////////////
784
/**
785
 * Makes the whole Object smoothly change its transparency level.
786
 *
787
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any
788
 *               given moment: pixel.a *= alpha.
789
 *               Valid range: <0,1>
790
 * @return       ID of the effect added, or -1 if we failed to add one.
791
 */
792
  public long alpha(Data1D alpha)
793
    {
794
    return mF.add(EffectNames.ALPHA, alpha);
795
    }
796

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

    
812
///////////////////////////////////////////////////////////////////////////////////////////////////
813
/**
814
 * Makes the whole Object smoothly change its brightness level.
815
 *
816
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
817
 *                   at any given moment. Valid range: <0,infinity)
818
 * @return           ID of the effect added, or -1 if we failed to add one.
819
 */
820
  public long brightness(Data1D brightness)
821
    {
822
    return mF.add(EffectNames.BRIGHTNESS, brightness);
823
    }
824

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

    
840
///////////////////////////////////////////////////////////////////////////////////////////////////
841
/**
842
 * Makes the whole Object smoothly change its contrast level.
843
 *
844
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
845
 *                 at any given moment. Valid range: <0,infinity)
846
 * @return         ID of the effect added, or -1 if we failed to add one.
847
 */
848
  public long contrast(Data1D contrast)
849
    {
850
    return mF.add(EffectNames.CONTRAST, contrast);
851
    }
852

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

    
868
///////////////////////////////////////////////////////////////////////////////////////////////////
869
/**
870
 * Makes the whole Object smoothly change its saturation level.
871
 *
872
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
873
 *                   at any given moment. Valid range: <0,infinity)
874
 * @return           ID of the effect added, or -1 if we failed to add one.
875
 */
876
  public long saturation(Data1D saturation)
877
    {
878
    return mF.add(EffectNames.SATURATION, saturation);
879
    }
880

    
881
///////////////////////////////////////////////////////////////////////////////////////////////////
882
// Vertex-based effects  
883
///////////////////////////////////////////////////////////////////////////////////////////////////
884
/**
885
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
886
 *
887
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
888
 *               currently being dragged with.
889
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
890
 * @param region Region that masks the Effect.
891
 * @return       ID of the effect added, or -1 if we failed to add one.
892
 */
893
  public long distort(Data3D vector, Data3D center, Data4D region)
894
    {  
895
    return mV.add(EffectNames.DISTORT, vector, center, region);
896
    }
897

    
898
///////////////////////////////////////////////////////////////////////////////////////////////////
899
/**
900
 * Distort the whole Object by a (possibly changing in time) vector of force.
901
 *
902
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
903
 *               currently being dragged with.
904
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
905
 * @return       ID of the effect added, or -1 if we failed to add one.
906
 */
907
  public long distort(Data3D vector, Data3D center)
908
    {
909
    return mV.add(EffectNames.DISTORT, vector, center, null);
910
    }
911

    
912
///////////////////////////////////////////////////////////////////////////////////////////////////
913
/**
914
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
915
 * a (possibly changing in time) point on the Object.
916
 *
917
 * @param vector Vector of force that deforms the shape of the whole Object.
918
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
919
 * @param region Region that masks the Effect.
920
 * @return       ID of the effect added, or -1 if we failed to add one.
921
 */
922
  public long deform(Data3D vector, Data3D center, Data4D region)
923
    {
924
    return mV.add(EffectNames.DEFORM, vector, center, region);
925
    }
926

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

    
941
///////////////////////////////////////////////////////////////////////////////////////////////////  
942
/**
943
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
944
 * away from the center (degree<=1)
945
 *
946
 * @param sink   The current degree of the Effect.
947
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
948
 * @param region Region that masks the Effect.
949
 * @return       ID of the effect added, or -1 if we failed to add one.
950
 */
951
  public long sink(Data1D sink, Data3D center, Data4D region)
952
    {
953
    return mV.add(EffectNames.SINK, sink, center, region);
954
    }
955

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

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

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

    
999
///////////////////////////////////////////////////////////////////////////////////////////////////  
1000
/**
1001
 * Rotate part of the Object around the Center of the Effect by a certain angle.
1002
 *
1003
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
1004
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1005
 * @param region Region that masks the Effect.
1006
 * @return       ID of the effect added, or -1 if we failed to add one.
1007
 */
1008
  public long swirl(Data1D swirl, Data3D center, Data4D region)
1009
    {    
1010
    return mV.add(EffectNames.SWIRL, swirl, center, region);
1011
    }
1012

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

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

    
1060
///////////////////////////////////////////////////////////////////////////////////////////////////
1061
/**
1062
 * Directional, sinusoidal wave effect.
1063
 *
1064
 * @param wave   see {@link DistortedEffects#wave(Data5D,Data3D)}
1065
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
1066
 * @param region Region that masks the Effect.
1067
 * @return       ID of the effect added, or -1 if we failed to add one.
1068
 */
1069
  public long wave(Data5D wave, Data3D center, Data4D region)
1070
    {
1071
    return mV.add(EffectNames.WAVE, wave, center, region);
1072
    }
1073

    
1074
///////////////////////////////////////////////////////////////////////////////////////////////////
1075
// Postprocess-based effects
1076
///////////////////////////////////////////////////////////////////////////////////////////////////
1077
/**
1078
 * Blur the object.
1079
 *
1080
 * @param radius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
1081
 *               take into account 10 pixels in each direction.
1082
 * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
1083
 * @return ID of the effect added, or -1 if we failed to add one.
1084
 */
1085
  public long blur(Data1D radius, Data2D center)
1086
    {
1087
    return mP.add(EffectNames.BLUR, radius, center);
1088
    }
1089
  }
(2-2/16)