Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedObject.java @ 16d8b8f3

1 d333eb6b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 6a06a912 Leszek Koltunski
package org.distorted.library;
21
22
import android.graphics.Bitmap;
23 985ea9c5 Leszek Koltunski
import android.graphics.Matrix;
24 6a06a912 Leszek Koltunski
import android.opengl.GLES20;
25
import android.opengl.GLUtils;
26
27 e458a4ba Leszek Koltunski
import org.distorted.library.message.EffectListener;
28 568b29d8 Leszek Koltunski
import org.distorted.library.type.Data1D;
29 f2fe7e28 Leszek Koltunski
import org.distorted.library.type.Data2D;
30 568b29d8 Leszek Koltunski
import org.distorted.library.type.Data3D;
31
import org.distorted.library.type.Data4D;
32 350cc2f5 Leszek Koltunski
import org.distorted.library.type.Data5D;
33 568b29d8 Leszek Koltunski
import org.distorted.library.type.Static3D;
34 a4835695 Leszek Koltunski
35 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
36 b329f352 Leszek Koltunski
/**
37 437bc43e Leszek Koltunski
 * All Objects to which Distorted Graphics effects can be applied need to be extended from here.
38 b329f352 Leszek Koltunski
 */
39 6a06a912 Leszek Koltunski
public abstract class DistortedObject 
40 d425545a Leszek Koltunski
  {
41 3d590d8d Leszek Koltunski
  private EffectQueueMatrix    mM;
42
  private EffectQueueFragment  mF;
43
  private EffectQueueVertex    mV;
44
45
  private boolean matrixCloned, vertexCloned, fragmentCloned;
46
  private long mID;
47
  private int mSizeX, mSizeY, mSizeZ; // in screen space
48 6a06a912 Leszek Koltunski
49 d425545a Leszek Koltunski
  protected DistortedObjectGrid mGrid = null;
50 6a06a912 Leszek Koltunski
51 3d590d8d Leszek Koltunski
  private Bitmap[] mBmp= null; //
52
  int[] mTextureDataH;         // have to be shared among all the cloned Objects
53
  boolean[] mBitmapSet;        //
54 9361b337 Leszek Koltunski
55 985ea9c5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
56
// We have to flip vertically every single Bitmap that we get fed with.
57
//
58
// Reason: textures read from files are the only objects in OpenGL which have their origins at the
59
// upper-left corner. Everywhere else the origin is in the lower-left corner. Thus we have to flip.
60
// The alternative solution, namely inverting the y-coordinate of the TexCoord does not really work-
61
// i.e. it works only in case of rendering directly to the screen, but if we render to an FBO and
62
// then take the FBO and render to screen, (DistortedNode does so!) things get inverted as textures
63
// created from FBO have their origins in the lower-left... Mindfuck!
64
65
  private static Bitmap flipBitmap(Bitmap src)
66
    {
67
    Matrix matrix = new Matrix();
68
    matrix.preScale(1.0f,-1.0f);
69
70
    return Bitmap.createBitmap(src,0,0,src.getWidth(),src.getHeight(), matrix,true);
71
    }
72
73 9361b337 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
74
75 d425545a Leszek Koltunski
  protected abstract DistortedObject deepCopy(int flags);
76 9361b337 Leszek Koltunski
77 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
78
79 3d590d8d Leszek Koltunski
  protected void initializeData(int x, int y, int z)
80 d425545a Leszek Koltunski
    {
81 3d590d8d Leszek Koltunski
    mSizeX= x;
82
    mSizeY= y;
83
    mSizeZ= z;
84
85 d425545a Leszek Koltunski
    mID             = DistortedObjectList.add(this);
86
    mTextureDataH   = new int[1];
87
    mTextureDataH[0]= 0;
88
    mBmp            = new Bitmap[1];
89
    mBmp[0]         = null;
90
    mBitmapSet      = new boolean[1];
91
    mBitmapSet[0]   = false;
92 6a06a912 Leszek Koltunski
      
93 d425545a Leszek Koltunski
    initializeEffectLists(this,0);
94 6a06a912 Leszek Koltunski
      
95 d425545a Leszek Koltunski
    if( Distorted.isInitialized() ) resetTexture();
96
    }
97 6a06a912 Leszek Koltunski
    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99
    
100 3d590d8d Leszek Koltunski
  private void initializeEffectLists(DistortedObject d, int flags)
101 d425545a Leszek Koltunski
    {
102 015642fb Leszek Koltunski
    if( (flags & Distorted.CLONE_MATRIX) != 0 )
103 6a06a912 Leszek Koltunski
      {
104 d425545a Leszek Koltunski
      mM = d.mM;
105
      matrixCloned = true;
106
      }
107
    else
108
      {
109
      mM = new EffectQueueMatrix(d);
110
      matrixCloned = false;
111
      }
112 6a06a912 Leszek Koltunski
    
113 d425545a Leszek Koltunski
    if( (flags & Distorted.CLONE_VERTEX) != 0 )
114
      {
115
      mV = d.mV;
116
      vertexCloned = true;
117
      }
118
    else
119
      {
120
      mV = new EffectQueueVertex(d);
121
      vertexCloned = false;
122
      }
123 6a06a912 Leszek Koltunski
    
124 d425545a Leszek Koltunski
    if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
125
      {
126
      mF = d.mF;
127
      fragmentCloned = true;
128 6a06a912 Leszek Koltunski
      }
129 d425545a Leszek Koltunski
    else
130
      {
131
      mF = new EffectQueueFragment(d);
132
      fragmentCloned = false;
133
      }
134
    }
135 6a06a912 Leszek Koltunski
    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137
// this will be called on startup and every time OpenGL context has been lost
138
// also call this from the constructor if the OpenGL context has been created already.
139
    
140 d425545a Leszek Koltunski
  void resetTexture()
141
    {
142
    if( mTextureDataH!=null )
143 6a06a912 Leszek Koltunski
      {
144 d425545a Leszek Koltunski
      if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
145 6a06a912 Leszek Koltunski
146 d425545a Leszek Koltunski
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
147
      GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
148
      GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
149
      GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
150
      GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
151 6a06a912 Leszek Koltunski
       
152 d425545a Leszek Koltunski
      if( mBmp!=null && mBmp[0]!=null)
153
        {
154 985ea9c5 Leszek Koltunski
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, flipBitmap(mBmp[0]), 0);
155 d425545a Leszek Koltunski
        mBmp[0] = null;
156 6a06a912 Leszek Koltunski
        }
157
      }
158 d425545a Leszek Koltunski
    }
159 6a06a912 Leszek Koltunski
  
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161
   
162 ed13a5de Leszek Koltunski
  void drawPriv(long currTime, DistortedFramebuffer df)
163 d425545a Leszek Koltunski
    {
164 16d8b8f3 Leszek Koltunski
    DistortedFramebufferList.deleteAllMarked();
165
166 ed13a5de Leszek Koltunski
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
167 6a06a912 Leszek Koltunski
      
168 d425545a Leszek Koltunski
    mM.compute(currTime);
169 ed13a5de Leszek Koltunski
    mM.send(df);
170 6a06a912 Leszek Koltunski
      
171 d425545a Leszek Koltunski
    mV.compute(currTime);
172
    mV.send();
173 6a06a912 Leszek Koltunski
        
174 d425545a Leszek Koltunski
    mF.compute(currTime);
175
    mF.send();
176 6a06a912 Leszek Koltunski
       
177 d425545a Leszek Koltunski
    mGrid.draw();
178
    }
179 6a06a912 Leszek Koltunski
180
///////////////////////////////////////////////////////////////////////////////////////////////////
181
   
182 ed13a5de Leszek Koltunski
  void drawNoEffectsPriv(DistortedFramebuffer df)
183 d425545a Leszek Koltunski
    {
184 ed13a5de Leszek Koltunski
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
185
    mM.sendZero(df);
186 d425545a Leszek Koltunski
    mV.sendZero();
187
    mF.sendZero();
188
    mGrid.draw();
189
    }
190 6a06a912 Leszek Koltunski
    
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192
   
193 d425545a Leszek Koltunski
  void releasePriv()
194
    {
195 0df17fad Leszek Koltunski
    if( matrixCloned  ==false) mM.abortAll(false);
196
    if( vertexCloned  ==false) mV.abortAll(false);
197
    if( fragmentCloned==false) mF.abortAll(false);
198 d425545a Leszek Koltunski
199
    mBmp          = null;
200
    mGrid         = null;
201
    mM            = null;
202
    mV            = null;
203
    mF            = null;
204
    mTextureDataH = null;
205
    }
206 6a06a912 Leszek Koltunski
 
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208
209 d425545a Leszek Koltunski
  long getBitmapID()
210 6a06a912 Leszek Koltunski
      {
211
      return mBmp==null ? 0 : mBmp.hashCode();
212
      }
213
214 ada90d33 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
215 d425545a Leszek Koltunski
/**
216
 * Default empty constructor so that derived classes can call it
217
 */
218
  public DistortedObject()
219
    {
220 ada90d33 Leszek Koltunski
221 d425545a Leszek Koltunski
    }
222 ada90d33 Leszek Koltunski
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224 d425545a Leszek Koltunski
/**
225
 * Copy constructor used to create a DistortedObject based on various parts of another object.
226
 * <p>
227
 * Whatever we do not clone gets created just like in the default constructor.
228
 * We only call this from the descendant's classes' constructors where we have to pay attention
229
 * to give it the appropriate type of a DistortedObject!
230
 *
231
 * @param dc    Source object to create our object from
232
 * @param flags A bitmask of values specifying what to copy.
233
 *              For example, CLONE_BITMAP | CLONE_MATRIX.
234
 */
235
  public DistortedObject(DistortedObject dc, int flags)
236
    {
237
    initializeEffectLists(dc,flags);
238 ada90d33 Leszek Koltunski
239 d425545a Leszek Koltunski
    mID = DistortedObjectList.add(this);
240 ada90d33 Leszek Koltunski
241 d425545a Leszek Koltunski
    mSizeX = dc.mSizeX;
242
    mSizeY = dc.mSizeY;
243
    mSizeZ = dc.mSizeZ;
244
    mGrid  = dc.mGrid;
245 ada90d33 Leszek Koltunski
246 d425545a Leszek Koltunski
    if( (flags & Distorted.CLONE_BITMAP) != 0 )
247
      {
248
      mTextureDataH = dc.mTextureDataH;
249
      mBmp          = dc.mBmp;
250
      mBitmapSet    = dc.mBitmapSet;
251 ada90d33 Leszek Koltunski
      }
252 d425545a Leszek Koltunski
    else
253
      {
254
      mTextureDataH   = new int[1];
255
      mTextureDataH[0]= 0;
256
      mBitmapSet      = new boolean[1];
257
      mBitmapSet[0]   = false;
258
      mBmp            = new Bitmap[1];
259
      mBmp[0]         = null;
260
261
      if( Distorted.isInitialized() ) resetTexture();
262
      }
263
    }
264 ada90d33 Leszek Koltunski
265 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
266
/**
267
 * Draw the DistortedObject to the location specified by current Matrix effects.    
268
 *     
269
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
270 5d923c17 Leszek Koltunski
 *        This gets passed on to Dynamics inside the Effects that are currently applied to the
271 6a06a912 Leszek Koltunski
 *        Object.
272
 */
273 d425545a Leszek Koltunski
  public void draw(long currTime)
274
    {
275
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
276
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
277
    GLES20.glUniform1i(Distorted.mTextureUniformH, 0);
278
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
279 ed13a5de Leszek Koltunski
280
    drawPriv(currTime, Distorted.mFramebuffer);
281 d425545a Leszek Koltunski
    }
282 6a06a912 Leszek Koltunski
 
283
///////////////////////////////////////////////////////////////////////////////////////////////////
284
/**
285
 * Releases all resources.
286
 */
287 d425545a Leszek Koltunski
  public synchronized void release()
288
    {
289
    releasePriv();
290
    DistortedObjectList.remove(this);
291
    }
292 6a06a912 Leszek Koltunski
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294
/**
295
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
296
 * <p>
297
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
298
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
299
 * 
300
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
301
 */
302
   
303 d425545a Leszek Koltunski
  public void setBitmap(Bitmap bmp)
304
    {
305
    mBitmapSet[0] = true;
306 6a06a912 Leszek Koltunski
      
307 d425545a Leszek Koltunski
    if( Distorted.isInitialized() )
308
      {
309
      GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
310
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
311 985ea9c5 Leszek Koltunski
      GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, flipBitmap(bmp), 0);
312 d425545a Leszek Koltunski
      }
313
    else
314
      {
315
      mBmp[0] = bmp;
316
      }
317
    }
318 6a06a912 Leszek Koltunski
    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320
/**
321
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
322 9351ad55 Leszek Koltunski
 * to one of the Effects that are currently applied to the DistortedObject.
323 6a06a912 Leszek Koltunski
 * 
324
 * @param el A class implementing the EffectListener interface that wants to get notifications.
325
 */
326 d425545a Leszek Koltunski
  public void addEventListener(EffectListener el)
327
    {
328
    mV.addListener(el);
329
    mF.addListener(el);
330
    mM.addListener(el);
331
    }
332 6a06a912 Leszek Koltunski
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334
/**
335
 * Removes the calling class from the list of Listeners.
336
 * 
337
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
338
 */
339 d425545a Leszek Koltunski
  public void removeEventListener(EffectListener el)
340
    {
341
    mV.removeListener(el);
342
    mF.removeListener(el);
343
    mM.removeListener(el);
344
    }
345 6a06a912 Leszek Koltunski
   
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347
/**
348
 * Returns the height of the DistortedObject.
349
 *    
350
 * @return height of the object, in pixels.
351
 */
352 d425545a Leszek Koltunski
  public int getWidth()
353 6a06a912 Leszek Koltunski
     {
354
     return mSizeX;   
355
     }
356
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358
/**
359
 * Returns the width of the DistortedObject.
360
 * 
361
 * @return width of the Object, in pixels.
362
 */
363 d425545a Leszek Koltunski
  public int getHeight()
364 6a06a912 Leszek Koltunski
      {
365
      return mSizeY;  
366
      }
367
    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
/**
370
 * Returns the depth of the DistortedObject.
371
 * 
372
 * @return depth of the Object, in pixels.
373
 */
374 d425545a Leszek Koltunski
  public int getDepth()
375 6a06a912 Leszek Koltunski
      {
376
      return mSizeZ;  
377
      }
378
        
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380
/**
381
 * Returns unique ID of this instance.
382
 * 
383
 * @return ID of the object.
384
 */
385 d425545a Leszek Koltunski
  public long getID()
386 6a06a912 Leszek Koltunski
      {
387
      return mID;  
388
      }
389
    
390
///////////////////////////////////////////////////////////////////////////////////////////////////
391
/**
392 d07f2950 Leszek Koltunski
 * Aborts all Effects.
393
 * @return Number of effects aborted.
394 6a06a912 Leszek Koltunski
 */
395 d425545a Leszek Koltunski
  public int abortAllEffects()
396 6a06a912 Leszek Koltunski
      {
397 0df17fad Leszek Koltunski
      return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true);
398 6a06a912 Leszek Koltunski
      }
399
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401
/**
402 d07f2950 Leszek Koltunski
 * Aborts all Effects of a given type, for example all MATRIX Effects.
403 6a06a912 Leszek Koltunski
 * 
404 d07f2950 Leszek Koltunski
 * @param type one of the constants defined in {@link EffectTypes}
405
 * @return Number of effects aborted.
406 6a06a912 Leszek Koltunski
 */
407 d425545a Leszek Koltunski
  public int abortEffects(EffectTypes type)
408
    {
409
    switch(type)
410 6a06a912 Leszek Koltunski
      {
411 0df17fad Leszek Koltunski
      case MATRIX  : return mM.abortAll(true);
412
      case VERTEX  : return mV.abortAll(true);
413
      case FRAGMENT: return mF.abortAll(true);
414 d425545a Leszek Koltunski
      default      : return 0;
415 6a06a912 Leszek Koltunski
      }
416 d425545a Leszek Koltunski
    }
417 6a06a912 Leszek Koltunski
    
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419
/**
420
 * Aborts a single Effect.
421
 * 
422
 * @param id ID of the Effect we want to abort.
423 476bbc81 Leszek Koltunski
 * @return number of Effects aborted. Always either 0 or 1.
424 6a06a912 Leszek Koltunski
 */
425 d425545a Leszek Koltunski
  public int abortEffect(long id)
426
    {
427
    int type = (int)(id&EffectTypes.MASK);
428 1e438fc7 Leszek Koltunski
429 d425545a Leszek Koltunski
    if( type==EffectTypes.MATRIX.type   ) return mM.removeByID(id>>EffectTypes.LENGTH);
430
    if( type==EffectTypes.VERTEX.type   ) return mV.removeByID(id>>EffectTypes.LENGTH);
431
    if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
432 1e438fc7 Leszek Koltunski
433 d425545a Leszek Koltunski
    return 0;
434
    }
435 6a06a912 Leszek Koltunski
436
///////////////////////////////////////////////////////////////////////////////////////////////////
437
/**
438 e8c81a8e Leszek Koltunski
 * Abort all Effects of a given name, for example all rotations.
439 6a06a912 Leszek Koltunski
 * 
440 d07f2950 Leszek Koltunski
 * @param name one of the constants defined in {@link EffectNames}
441 476bbc81 Leszek Koltunski
 * @return number of Effects aborted.
442 6a06a912 Leszek Koltunski
 */
443 d425545a Leszek Koltunski
  public int abortEffects(EffectNames name)
444
    {
445
    switch(name.getType())
446 6a06a912 Leszek Koltunski
      {
447 d425545a Leszek Koltunski
      case MATRIX  : return mM.removeByType(name);
448
      case VERTEX  : return mV.removeByType(name);
449
      case FRAGMENT: return mF.removeByType(name);
450
      default      : return 0;
451 6a06a912 Leszek Koltunski
      }
452 d425545a Leszek Koltunski
    }
453 6a06a912 Leszek Koltunski
    
454
///////////////////////////////////////////////////////////////////////////////////////////////////
455
/**
456
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
457
 * 
458
 * @param id Effect ID we want to print info about
459
 * @return <code>true</code> if a single Effect of type effectType has been found.
460
 */
461
    
462 d425545a Leszek Koltunski
  public boolean printEffect(long id)
463
    {
464
    int type = (int)(id&EffectTypes.MASK);
465 1e438fc7 Leszek Koltunski
466 d425545a Leszek Koltunski
    if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
467
    if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
468
    if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
469 1e438fc7 Leszek Koltunski
470 d425545a Leszek Koltunski
    return false;
471
    }
472 6a06a912 Leszek Koltunski
   
473
///////////////////////////////////////////////////////////////////////////////////////////////////   
474
///////////////////////////////////////////////////////////////////////////////////////////////////
475
// Individual effect functions.
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477
// Matrix-based effects
478
///////////////////////////////////////////////////////////////////////////////////////////////////
479
/**
480 e8c81a8e Leszek Koltunski
 * Moves the Object by a (possibly changing in time) vector.
481 6a06a912 Leszek Koltunski
 * 
482 568b29d8 Leszek Koltunski
 * @param vector 3-dimensional Data which at any given time will return a Static3D
483 e0a16874 Leszek Koltunski
 *               representing the current coordinates of the vector we want to move the Object with.
484
 * @return       ID of the effect added, or -1 if we failed to add one.
485 6a06a912 Leszek Koltunski
 */
486 568b29d8 Leszek Koltunski
  public long move(Data3D vector)
487 6a06a912 Leszek Koltunski
    {   
488 e0a16874 Leszek Koltunski
    return mM.add(EffectNames.MOVE,vector);
489 6a06a912 Leszek Koltunski
    }
490
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492
/**
493 e8c81a8e Leszek Koltunski
 * Scales the Object by (possibly changing in time) 3D scale factors.
494 6a06a912 Leszek Koltunski
 * 
495 568b29d8 Leszek Koltunski
 * @param scale 3-dimensional Dynamic which at any given time returns a Static3D
496 e0a16874 Leszek Koltunski
 *              representing the current x- , y- and z- scale factors.
497
 * @return      ID of the effect added, or -1 if we failed to add one.
498 6a06a912 Leszek Koltunski
 */
499 568b29d8 Leszek Koltunski
  public long scale(Data3D scale)
500 6a06a912 Leszek Koltunski
    {   
501 e0a16874 Leszek Koltunski
    return mM.add(EffectNames.SCALE,scale);
502 6a06a912 Leszek Koltunski
    }
503
504 2fce34f4 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
505
/**
506 e8c81a8e Leszek Koltunski
 * Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
507 2fce34f4 Leszek Koltunski
 *
508
 * @param scale The factor to scale all 3 dimensions with.
509
 * @return      ID of the effect added, or -1 if we failed to add one.
510
 */
511 d425545a Leszek Koltunski
  public long scale(float scale)
512
    {
513
    return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
514
    }
515 2fce34f4 Leszek Koltunski
516 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
517
/**
518 568b29d8 Leszek Koltunski
 * Rotates the Object by 'angle' degrees around the center.
519
 * Static axis of rotation is given by the last parameter.
520
 *
521 9351ad55 Leszek Koltunski
 * @param angle  Angle that we want to rotate the Object to. Unit: degrees
522 568b29d8 Leszek Koltunski
 * @param axis   Axis of rotation
523 0df17fad Leszek Koltunski
 * @param center Coordinates of the Point we are rotating around.
524 e0a16874 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
525
 */
526 0df17fad Leszek Koltunski
  public long rotate(Data1D angle, Static3D axis, Data3D center )
527 6a06a912 Leszek Koltunski
    {   
528 0df17fad Leszek Koltunski
    return mM.add(EffectNames.ROTATE, angle, axis, center);
529 6a06a912 Leszek Koltunski
    }
530
531
///////////////////////////////////////////////////////////////////////////////////////////////////
532
/**
533 568b29d8 Leszek Koltunski
 * Rotates the Object by 'angle' degrees around the center.
534 2fce34f4 Leszek Koltunski
 * Here both angle and axis can dynamically change.
535 568b29d8 Leszek Koltunski
 *
536
 * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
537 0df17fad Leszek Koltunski
 * @param center    Coordinates of the Point we are rotating around.
538 568b29d8 Leszek Koltunski
 * @return          ID of the effect added, or -1 if we failed to add one.
539 e0a16874 Leszek Koltunski
 */
540 0df17fad Leszek Koltunski
  public long rotate(Data4D angleaxis, Data3D center)
541 568b29d8 Leszek Koltunski
    {
542 0df17fad Leszek Koltunski
    return mM.add(EffectNames.ROTATE, angleaxis, center);
543 6a06a912 Leszek Koltunski
    }
544
545
///////////////////////////////////////////////////////////////////////////////////////////////////
546
/**
547 568b29d8 Leszek Koltunski
 * Rotates the Object by quaternion.
548 0df17fad Leszek Koltunski
 *
549 568b29d8 Leszek Koltunski
 * @param quaternion The quaternion describing the rotation.
550 0df17fad Leszek Koltunski
 * @param center     Coordinates of the Point we are rotating around.
551 568b29d8 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
552 6a06a912 Leszek Koltunski
 */
553 0df17fad Leszek Koltunski
  public long quaternion(Data4D quaternion, Data3D center )
554 568b29d8 Leszek Koltunski
    {
555 0df17fad Leszek Koltunski
    return mM.add(EffectNames.QUATERNION,quaternion,center);
556 6a06a912 Leszek Koltunski
    }
557
558
///////////////////////////////////////////////////////////////////////////////////////////////////
559
/**
560 568b29d8 Leszek Koltunski
 * Shears the Object.
561 6a06a912 Leszek Koltunski
 *
562 8c3cdec5 Leszek Koltunski
 * @param shear   The 3-tuple of shear factors. The first controls level
563
 *                of shearing in the X-axis, second - Y-axis and the third -
564
 *                Z-axis. Each is the tangens of the shear angle, i.e 0 -
565
 *                no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
566 0df17fad Leszek Koltunski
 * @param center  Center of shearing, i.e. the point which stays unmoved.
567 e0a16874 Leszek Koltunski
 * @return        ID of the effect added, or -1 if we failed to add one.
568 6a06a912 Leszek Koltunski
 */
569 0df17fad Leszek Koltunski
  public long shear(Data3D shear, Data3D center)
570 6a06a912 Leszek Koltunski
    {
571 0df17fad Leszek Koltunski
    return mM.add(EffectNames.SHEAR, shear, center);
572 6a06a912 Leszek Koltunski
    }
573
574
///////////////////////////////////////////////////////////////////////////////////////////////////
575
// Fragment-based effects  
576
///////////////////////////////////////////////////////////////////////////////////////////////////
577
/**
578 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
579 6a06a912 Leszek Koltunski
 *        
580 2fce34f4 Leszek Koltunski
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
581 e4878781 Leszek Koltunski
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
582
 *               Valid range: <0,1>
583 b1e91f2c Leszek Koltunski
 * @param color  Color to mix. (1,0,0) is RED.
584 2fce34f4 Leszek Koltunski
 * @param region Region this Effect is limited to.
585
 * @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
586
 * @return       ID of the effect added, or -1 if we failed to add one.
587 6a06a912 Leszek Koltunski
 */
588 8c893ffc Leszek Koltunski
  public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
589 6a06a912 Leszek Koltunski
    {
590 2fce34f4 Leszek Koltunski
    return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
591 6a06a912 Leszek Koltunski
    }
592
593
///////////////////////////////////////////////////////////////////////////////////////////////////
594
/**
595 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change all three of its RGB components.
596
 *
597
 * @param blend  1-dimensional Data that returns the level of blend a given pixel will be
598 e4878781 Leszek Koltunski
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
599
 *               Valid range: <0,1>
600 b1e91f2c Leszek Koltunski
 * @param color  Color to mix. (1,0,0) is RED.
601 2fce34f4 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
602 6a06a912 Leszek Koltunski
 */
603 8c893ffc Leszek Koltunski
  public long chroma(Data1D blend, Data3D color)
604 6a06a912 Leszek Koltunski
    {
605 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.CHROMA, blend, color);
606 6a06a912 Leszek Koltunski
    }
607
608
///////////////////////////////////////////////////////////////////////////////////////////////////
609
/**
610 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its transparency level.
611 6a06a912 Leszek Koltunski
 *        
612 2fce34f4 Leszek Koltunski
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any given
613 e4878781 Leszek Koltunski
 *               moment: pixel.a *= alpha.
614
 *               Valid range: <0,1>
615 d7bbef2f Leszek Koltunski
 * @param region Region this Effect is limited to. 
616 2fce34f4 Leszek Koltunski
 * @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
617 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
618 6a06a912 Leszek Koltunski
 */
619 2fce34f4 Leszek Koltunski
  public long alpha(Data1D alpha, Data4D region, boolean smooth)
620 6a06a912 Leszek Koltunski
    {
621 2fce34f4 Leszek Koltunski
    return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
622 6a06a912 Leszek Koltunski
    }
623
624
///////////////////////////////////////////////////////////////////////////////////////////////////
625
/**
626 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its transparency level.
627
 *
628
 * @param alpha  1-dimensional Data that returns the level of transparency we want to have at any
629 e4878781 Leszek Koltunski
 *               given moment: pixel.a *= alpha.
630
 *               Valid range: <0,1>
631 2fce34f4 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
632 6a06a912 Leszek Koltunski
 */
633 2fce34f4 Leszek Koltunski
  public long alpha(Data1D alpha)
634 6a06a912 Leszek Koltunski
    {
635 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.ALPHA, alpha);
636 6a06a912 Leszek Koltunski
    }
637
638
///////////////////////////////////////////////////////////////////////////////////////////////////
639
/**
640 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its brightness level.
641 6a06a912 Leszek Koltunski
 *        
642 2fce34f4 Leszek Koltunski
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
643 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
644 e0a16874 Leszek Koltunski
 * @param region     Region this Effect is limited to.
645 2fce34f4 Leszek Koltunski
 * @param smooth     If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
646 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
647 6a06a912 Leszek Koltunski
 */
648 2fce34f4 Leszek Koltunski
  public long brightness(Data1D brightness, Data4D region, boolean smooth)
649 6a06a912 Leszek Koltunski
    {
650 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
651 6a06a912 Leszek Koltunski
    }
652
653
///////////////////////////////////////////////////////////////////////////////////////////////////
654
/**
655 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its brightness level.
656
 *
657
 * @param brightness 1-dimensional Data that returns the level of brightness we want to have
658 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
659 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
660 6a06a912 Leszek Koltunski
 */
661 2fce34f4 Leszek Koltunski
  public long brightness(Data1D brightness)
662 6a06a912 Leszek Koltunski
    {
663 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.BRIGHTNESS, brightness);
664 6a06a912 Leszek Koltunski
    }
665
666
///////////////////////////////////////////////////////////////////////////////////////////////////
667
/**
668 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its contrast level.
669 6a06a912 Leszek Koltunski
 *        
670 2fce34f4 Leszek Koltunski
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
671 e4878781 Leszek Koltunski
 *                 at any given moment. Valid range: <0,infinity)
672 e0a16874 Leszek Koltunski
 * @param region   Region this Effect is limited to.
673 2fce34f4 Leszek Koltunski
 * @param smooth   If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
674 e0a16874 Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one.
675 6a06a912 Leszek Koltunski
 */
676 2fce34f4 Leszek Koltunski
  public long contrast(Data1D contrast, Data4D region, boolean smooth)
677 6a06a912 Leszek Koltunski
    {
678 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
679 6a06a912 Leszek Koltunski
    }
680
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682
/**
683 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its contrast level.
684
 *
685
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
686 e4878781 Leszek Koltunski
 *                 at any given moment. Valid range: <0,infinity)
687 e0a16874 Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one.
688 6a06a912 Leszek Koltunski
 */
689 2fce34f4 Leszek Koltunski
  public long contrast(Data1D contrast)
690 6a06a912 Leszek Koltunski
    {
691 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.CONTRAST, contrast);
692 6a06a912 Leszek Koltunski
    }
693
694
///////////////////////////////////////////////////////////////////////////////////////////////////
695
/**
696 e0a16874 Leszek Koltunski
 * Makes a certain sub-region of the Object smoothly change its saturation level.
697 6a06a912 Leszek Koltunski
 *        
698 2fce34f4 Leszek Koltunski
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
699 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
700 e0a16874 Leszek Koltunski
 * @param region     Region this Effect is limited to.
701 2fce34f4 Leszek Koltunski
 * @param smooth     If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
702 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
703 6a06a912 Leszek Koltunski
 */
704 2fce34f4 Leszek Koltunski
  public long saturation(Data1D saturation, Data4D region, boolean smooth)
705 6a06a912 Leszek Koltunski
    {
706 2fce34f4 Leszek Koltunski
    return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
707 6a06a912 Leszek Koltunski
    }
708
709
///////////////////////////////////////////////////////////////////////////////////////////////////
710
/**
711 2fce34f4 Leszek Koltunski
 * Makes the whole Object smoothly change its saturation level.
712
 *
713
 * @param saturation 1-dimensional Data that returns the level of saturation we want to have
714 e4878781 Leszek Koltunski
 *                   at any given moment. Valid range: <0,infinity)
715 e0a16874 Leszek Koltunski
 * @return           ID of the effect added, or -1 if we failed to add one.
716 6a06a912 Leszek Koltunski
 */
717 2fce34f4 Leszek Koltunski
  public long saturation(Data1D saturation)
718 6a06a912 Leszek Koltunski
    {
719 2fce34f4 Leszek Koltunski
    return mF.add(EffectNames.SATURATION, saturation);
720 6a06a912 Leszek Koltunski
    }
721
722
///////////////////////////////////////////////////////////////////////////////////////////////////
723
// Vertex-based effects  
724
///////////////////////////////////////////////////////////////////////////////////////////////////
725
/**
726 e0a16874 Leszek Koltunski
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
727 f2fe7e28 Leszek Koltunski
 *
728
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
729
 *               currently being dragged with.
730 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
731 f2fe7e28 Leszek Koltunski
 * @param region Region that masks the Effect.
732
 * @return       ID of the effect added, or -1 if we failed to add one.
733 6a06a912 Leszek Koltunski
 */
734 fa6c352d Leszek Koltunski
  public long distort(Data3D vector, Data3D center, Data4D region)
735 6a06a912 Leszek Koltunski
    {  
736 f2fe7e28 Leszek Koltunski
    return mV.add(EffectNames.DISTORT, vector, center, region);
737 6a06a912 Leszek Koltunski
    }
738
739
///////////////////////////////////////////////////////////////////////////////////////////////////
740
/**
741 e0a16874 Leszek Koltunski
 * Distort the whole Object by a (possibly changing in time) vector of force.
742 f2fe7e28 Leszek Koltunski
 *
743
 * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
744
 *               currently being dragged with.
745 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
746 e0a16874 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
747 6a06a912 Leszek Koltunski
 */
748 fa6c352d Leszek Koltunski
  public long distort(Data3D vector, Data3D center)
749 d425545a Leszek Koltunski
    {
750 02ef26bc Leszek Koltunski
    return mV.add(EffectNames.DISTORT, vector, center, null);
751 d425545a Leszek Koltunski
    }
752 6a06a912 Leszek Koltunski
753 6ebdbbf1 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
754
/**
755
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
756
 * a (possibly changing in time) point on the Object.
757
 *
758
 * @param vector Vector of force that deforms the shape of the whole Object.
759
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
760
 * @param region Region that masks the Effect.
761
 * @return       ID of the effect added, or -1 if we failed to add one.
762
 */
763
  public long deform(Data3D vector, Data3D center, Data4D region)
764
    {
765
    return mV.add(EffectNames.DEFORM, vector, center, region);
766
    }
767
768 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
769
/**
770 e0a16874 Leszek Koltunski
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
771 9351ad55 Leszek Koltunski
 * a (possibly changing in time) point on the Object.
772 6a06a912 Leszek Koltunski
 *     
773 f2fe7e28 Leszek Koltunski
 * @param vector Vector of force that deforms the shape of the whole Object.
774 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
775 e0a16874 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
776 6a06a912 Leszek Koltunski
 */
777 fa6c352d Leszek Koltunski
  public long deform(Data3D vector, Data3D center)
778 6a06a912 Leszek Koltunski
    {  
779 02ef26bc Leszek Koltunski
    return mV.add(EffectNames.DEFORM, vector, center, null);
780 6a06a912 Leszek Koltunski
    }
781
782
///////////////////////////////////////////////////////////////////////////////////////////////////  
783
/**
784 f2fe7e28 Leszek Koltunski
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
785 6a06a912 Leszek Koltunski
 * away from the center (degree<=1)
786 f2fe7e28 Leszek Koltunski
 *
787
 * @param sink   The current degree of the Effect.
788 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
789 f2fe7e28 Leszek Koltunski
 * @param region Region that masks the Effect.
790
 * @return       ID of the effect added, or -1 if we failed to add one.
791 6a06a912 Leszek Koltunski
 */
792 fa6c352d Leszek Koltunski
  public long sink(Data1D sink, Data3D center, Data4D region)
793 6a06a912 Leszek Koltunski
    {
794 f2fe7e28 Leszek Koltunski
    return mV.add(EffectNames.SINK, sink, center, region);
795 6a06a912 Leszek Koltunski
    }
796
797
///////////////////////////////////////////////////////////////////////////////////////////////////
798
/**
799 f2fe7e28 Leszek Koltunski
 * Pull all points around the center of the Effect towards the center (if degree>=1) or push them
800
 * away from the center (degree<=1)
801
 *
802
 * @param sink   The current degree of the Effect.
803 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
804 f2fe7e28 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
805 6a06a912 Leszek Koltunski
 */
806 fa6c352d Leszek Koltunski
  public long sink(Data1D sink, Data3D center)
807 d425545a Leszek Koltunski
    {
808
    return mV.add(EffectNames.SINK, sink, center);
809
    }
810 6a06a912 Leszek Koltunski
811 82ee855a Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
812
/**
813
 * Pull all points around the center of the Effect towards a line passing through the center
814
 * (that's if degree>=1) or push them away from the line (degree<=1)
815
 *
816
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
817
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
818
 * @param region Region that masks the Effect.
819
 * @return       ID of the effect added, or -1 if we failed to add one.
820
 */
821
  public long pinch(Data2D pinch, Data3D center, Data4D region)
822
    {
823
    return mV.add(EffectNames.PINCH, pinch, center, region);
824
    }
825
826
///////////////////////////////////////////////////////////////////////////////////////////////////
827
/**
828
 * Pull all points around the center of the Effect towards a line passing through the center
829
 * (that's if degree>=1) or push them away from the line (degree<=1)
830
 *
831
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
832
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
833
 * @return       ID of the effect added, or -1 if we failed to add one.
834
 */
835
  public long pinch(Data2D pinch, Data3D center)
836
    {
837
    return mV.add(EffectNames.PINCH, pinch, center);
838
    }
839
840 6a06a912 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////  
841
/**
842 f2fe7e28 Leszek Koltunski
 * Rotate part of the Object around the Center of the Effect by a certain angle.
843
 *
844 4fde55a0 Leszek Koltunski
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
845 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
846 f2fe7e28 Leszek Koltunski
 * @param region Region that masks the Effect.
847
 * @return       ID of the effect added, or -1 if we failed to add one.
848 6a06a912 Leszek Koltunski
 */
849 fa6c352d Leszek Koltunski
  public long swirl(Data1D swirl, Data3D center, Data4D region)
850 6a06a912 Leszek Koltunski
    {    
851 f2fe7e28 Leszek Koltunski
    return mV.add(EffectNames.SWIRL, swirl, center, region);
852 6a06a912 Leszek Koltunski
    }
853
854
///////////////////////////////////////////////////////////////////////////////////////////////////
855
/**
856 f2fe7e28 Leszek Koltunski
 * Rotate the whole Object around the Center of the Effect by a certain angle.
857
 *
858 4fde55a0 Leszek Koltunski
 * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
859 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
860 f2fe7e28 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
861 6a06a912 Leszek Koltunski
 */
862 fa6c352d Leszek Koltunski
  public long swirl(Data1D swirl, Data3D center)
863 d425545a Leszek Koltunski
    {
864
    return mV.add(EffectNames.SWIRL, swirl, center);
865
    }
866 4fde55a0 Leszek Koltunski
867
///////////////////////////////////////////////////////////////////////////////////////////////////
868
/**
869
 * Directional, sinusoidal wave effect.
870
 *
871 350cc2f5 Leszek Koltunski
 * @param wave   A 5-dimensional data structure describing the wave: first member is the amplitude,
872 ea16dc89 Leszek Koltunski
 *               second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
873 350cc2f5 Leszek Koltunski
 *               wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
874
 *               describe the 'direction' of the wave.
875 3695d6fa Leszek Koltunski
 *               <p>
876 d0c902b8 Leszek Koltunski
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
877
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
878
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
879
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
880 3695d6fa Leszek Koltunski
 *               <p>
881
 *               <p>
882 d0c902b8 Leszek Koltunski
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
883
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
884
 *               will be sine shapes.
885 3695d6fa Leszek Koltunski
 *               <p>
886 d0c902b8 Leszek Koltunski
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
887
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
888
 *               YZ-plane with be sine shapes.
889 3695d6fa Leszek Koltunski
 *               <p>
890 d0c902b8 Leszek Koltunski
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
891 350cc2f5 Leszek Koltunski
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
892
 *               value if sin at this point.
893 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
894 4fde55a0 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one.
895
 */
896 fa6c352d Leszek Koltunski
  public long wave(Data5D wave, Data3D center)
897 4fde55a0 Leszek Koltunski
    {
898 02ef26bc Leszek Koltunski
    return mV.add(EffectNames.WAVE, wave, center, null);
899 4fde55a0 Leszek Koltunski
    }
900
901
///////////////////////////////////////////////////////////////////////////////////////////////////
902
/**
903
 * Directional, sinusoidal wave effect.
904
 *
905 3d590d8d Leszek Koltunski
 * @param wave   see {@link DistortedObject#wave(Data5D,Data3D)}
906 fa6c352d Leszek Koltunski
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
907 4fde55a0 Leszek Koltunski
 * @param region Region that masks the Effect.
908
 * @return       ID of the effect added, or -1 if we failed to add one.
909
 */
910 fa6c352d Leszek Koltunski
  public long wave(Data5D wave, Data3D center, Data4D region)
911 4fde55a0 Leszek Koltunski
    {
912
    return mV.add(EffectNames.WAVE, wave, center, region);
913
    }
914 f2fe7e28 Leszek Koltunski
  }