Project

General

Profile

« Previous | Next » 

Revision 8d5a8e06

Added by Leszek Koltunski about 5 years ago

Simplify the way applications can get notifications when an effect finishes.

Now, instead of the 'DistortedEffects.(de)registerForNotifications()' 2 APIs, we call a single 'Effect.notifyWhenFinished()'.

View differences:

src/main/java/org/distorted/examples/deform/DeformRenderer.java
35 35
import org.distorted.library.mesh.MeshFlat;
36 36

  
37 37
import org.distorted.library.message.EffectListener;
38
import org.distorted.library.message.EffectMessage;
39 38
import org.distorted.library.type.Dynamic3D;
40 39
import org.distorted.library.type.Static3D;
41 40
import org.distorted.library.type.Static4D;
......
87 86
      mMove       = new Static3D(0,0,0);
88 87
      mTouchPoint = new Static3D(0,0,0);
89 88

  
90
      mEffects.registerForMessages(this);
91

  
92 89
      // DISTORT
93 90
      Dynamic3D releasedDistortDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
94 91
      releasedDistortDynamic.setMode(Dynamic3D.MODE_PATH);
......
169 166
// keep aborting the 'released' effects, otherwise we are quickly going to run out of room in
170 167
// effect queues.
171 168

  
172
   public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
169
   public void effectFinished(final long effectID)
173 170
     {
174
     switch(em)
175
        {
176
        case EFFECT_FINISHED: mEffects.abortById(effectID); break;
177
        }
171
     mEffects.abortById(effectID);
178 172
     }
179 173

  
180 174
///////////////////////////////////////////////////////////////////////////////////////////////////
......
305 299
                       }
306 300
                     vDistort[NUM_VECTORS-1].set(0,0,0);
307 301
                     mEffects.apply(mReleasedDistort);
302
                     mReleasedDistort.notifyWhenFinished(this);
308 303
                     break;
309 304
       case DEFORM : for(int i=1; i<NUM_VECTORS-1; i++)
310 305
                       {
......
312 307
                       }
313 308
                     vDeform[NUM_VECTORS-1].set(0,0,0);
314 309
                     mEffects.apply(mReleasedDeform);
310
                     mReleasedDeform.notifyWhenFinished(this);
315 311
                     break;
316 312
       case SHEAR  : for(int i=1; i<NUM_VECTORS-1; i++)
317 313
                       {
......
319 315
                       }
320 316
                     vShear[NUM_VECTORS-1].set(0,0,0);
321 317
                     mEffects.apply(mReleasedShear);
318
                     mReleasedShear.notifyWhenFinished(this);
322 319
                     break;
323 320
       }
324 321
     }
src/main/java/org/distorted/examples/effectqueue/EffectQueueActivity.java
50 50
  private int mPosID, mPosName, mPosType;
51 51
  private TableLayout mLayoutList;
52 52

  
53
  private HashMap<Long,TableRow> mMap = new HashMap<>();
53
  private class EffectRow
54
    {
55
    Effect effect;
56
    TableRow row;
57

  
58
    EffectRow(Effect e, TableRow tr)
59
      {
60
      effect = e;
61
      row    = tr;
62
      }
63
    }
64

  
65
  private ArrayList<EffectRow> mList = new ArrayList<>();
54 66

  
55 67
///////////////////////////////////////////////////////////////////////////////////////////////////
56 68

  
......
173 185
      Long currEffect = (Long)mID.getItemAtPosition(mPosID);
174 186
      EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
175 187
      v.getRenderer().getEffects().abortById(currEffect);
188

  
189
      int numRows = mList.size();
190

  
191
      for(int i=0; i<numRows; i++)
192
        {
193
        Effect effect = mList.get(i).effect;
194

  
195
        if( effect.getID() == currEffect )
196
          {
197
          effectRemoved(i);
198
          break;
199
          }
200
        }
176 201
      }
177 202
    catch(IndexOutOfBoundsException ex)
178 203
      {
......
196 221
      default: name = EffectName.CONTRAST     ;
197 222
      }
198 223

  
224
      int numRows = mList.size();
225

  
226
      for(int i=0; i<numRows; i++)
227
        {
228
        Effect effect = mList.get(i).effect;
229

  
230
        if( effect.getName() == name )
231
          {
232
          effectRemoved(i);
233
          i--;
234
          numRows--;
235
          }
236
        }
237

  
199 238
    EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
200 239
    v.getRenderer().getEffects().abortByName(name);
201 240
    }
......
213 252
      default: type = EffectType.MATRIX;
214 253
      }
215 254

  
255
    int numRows = mList.size();
256

  
257
    for(int i=0; i<numRows; i++)
258
      {
259
      Effect effect = mList.get(i).effect;
260

  
261
      if( effect.getType() == type )
262
        {
263
        effectRemoved(i);
264
        i--;
265
        numRows--;
266
        }
267
      }
268

  
216 269
    EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
217 270
    v.getRenderer().getEffects().abortByType(type);
218 271
    }
......
223 276
    {
224 277
    if( success )  // we really added a new effect
225 278
      {
279
      EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
280
      effect.notifyWhenFinished(v.getRenderer());
281

  
226 282
      mAdapterID.add(effect.getID());
227 283
      mAdapterID.notifyDataSetChanged();
228 284

  
......
249 305
      b4.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
250 306
      tr.addView(b4);
251 307

  
252
      mMap.put(effect.getID(),tr);
308
      mList.add(new EffectRow(effect,tr));
253 309

  
254 310
      mLayoutList.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
255 311
      }
......
261 317

  
262 318
///////////////////////////////////////////////////////////////////////////////////////////////////
263 319

  
264
  public void effectRemoved(final long id)
320
  private void effectRemoved(int index)
265 321
    {
266
    runOnUiThread(new Runnable()
267
      {
268
      public void run()
269
        {
270
        mAdapterID.remove(id);
271
        mAdapterID.notifyDataSetChanged();
322
    EffectRow er = mList.remove(index);
272 323

  
273
        TableRow row = mMap.remove(id);
324
    mAdapterID.remove(er.effect.getID());
325
    mAdapterID.notifyDataSetChanged();
274 326

  
275
        if( row!=null )
276
          {
277
          mLayoutList.removeView(row);
278
          }
279
        else
280
          {
281
          android.util.Log.e("EFFECTS2D", "Impossible: id="+id+" not in the map!");
282
          }
283
        }
284
      });
327
    if( er.row!=null )
328
      {
329
      mLayoutList.removeView(er.row);
330
      }
331
    else
332
      {
333
      android.util.Log.e("EFFECTQUEUE", "Impossible: id="+er.effect.getID()+" not in the map!");
334
      }
285 335
    }
286 336

  
287 337
///////////////////////////////////////////////////////////////////////////////////////////////////
......
292 342
      {
293 343
      public void run()
294 344
        {
295
        TableRow row = mMap.get(id);
345
        TableRow row = null;
346

  
347
        int numRows = mList.size();
348

  
349
        for(int i=0; i<numRows; i++)
350
          {
351
          EffectRow er = mList.get(i);
352

  
353
          if( er.effect.getID() == id )
354
            {
355
            row = er.row;
356
            break;
357
            }
358
          }
296 359

  
297 360
        if( row!=null )
298 361
          {
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java
40 40
import org.distorted.library.mesh.MeshFlat;
41 41
import org.distorted.library.main.DistortedTexture;
42 42
import org.distorted.library.message.EffectListener;
43
import org.distorted.library.message.EffectMessage;
44 43
import org.distorted.library.type.Static3D;
45 44

  
46 45
///////////////////////////////////////////////////////////////////////////////////////////////////
......
82 81
    mTexture = new DistortedTexture(texWidth,texHeight);
83 82
    mEffects = new DistortedEffects();
84 83
    mEffects.apply(scaleEffect);
85
    mEffects.registerForMessages(this);
86 84

  
87 85
    mScreen = new DistortedScreen();
88 86
    }
......
148 146
    }
149 147

  
150 148
///////////////////////////////////////////////////////////////////////////////////////////////////
151
// the library sending messages to us. This is running on a library 'MessageSender' thread.
152 149

  
153
  public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
150
  public void effectFinished(final long effectID)
154 151
    {
155 152
    EffectQueueActivity act = (EffectQueueActivity)mView.getContext();
156

  
157
    switch(em)
158
      {
159
      case EFFECT_REMOVED : act.effectRemoved(effectID) ; break;
160
      case EFFECT_FINISHED: act.effectFinished(effectID); break;
161
      default             : break;
162
      }
153
    act.effectFinished(effectID);
163 154
    }
164 155
  }
src/main/java/org/distorted/examples/listener/ListenerRenderer.java
41 41
import org.distorted.library.type.Static3D;
42 42
import org.distorted.library.type.Static4D;
43 43
import org.distorted.library.message.EffectListener;
44
import org.distorted.library.message.EffectMessage;
45 44

  
46 45
import android.graphics.Bitmap;
47 46
import android.graphics.BitmapFactory;
......
68 67
      {
69 68
      mView = v;
70 69
      mEffects = new DistortedEffects();
71
      mEffects.registerForMessages(this);
72 70
      mScreen = new DistortedScreen();
73 71
      mRnd = new Random(0);
74 72

  
......
92 90
      dDistort.add(new Static3D(0,0,     0));
93 91
      dDistort.add(new Static3D(0,0,height));
94 92

  
95
      return mEffects.apply( new VertexEffectDistort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,0,radius)) );
93
      VertexEffectDistort distort = new VertexEffectDistort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,0,radius));
94
      distort.notifyWhenFinished(this);
95

  
96
      return mEffects.apply(distort);
96 97
      }
97 98
   
98 99
///////////////////////////////////////////////////////////////////////////////////////////////////
99
// the library sending messages to us. This is running on a library 'MessageSender' thread.
100 100

  
101
   public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
101
   public void effectFinished(final long effectID)
102 102
     {
103
     switch(em)
104
        {
105
        case EFFECT_FINISHED: mEffects.abortById(effectID);
106

  
107
                              if( !addNewBubble() )
108
                                {
109
                                android.util.Log.e("Listener", "failed to add new bubble - this should never happen!");
110
                                }
111
                              break;
112
        }
103
     mEffects.abortById(effectID);
104

  
105
     if( !addNewBubble() )
106
       {
107
       android.util.Log.e("Listener", "failed to add new bubble - this should never happen!");
108
       }
113 109
     }
114 110
   
115 111
///////////////////////////////////////////////////////////////////////////////////////////////////
......
128 124
       int w = (height*bmpWidth)/bmpHeight;
129 125
       float factor = (float)height/bmpHeight;
130 126

  
131
       mMove.set((width-w)/2,0,0);
127
       mMove.set((width-w)*0.5f,0,0);
132 128
       mScale.set(factor,factor,factor);
133 129
       }
134 130
     else
......
136 132
       int h = (width*bmpHeight)/bmpWidth;
137 133
       float factor = (float)width/bmpWidth;
138 134

  
139
       mMove.set(0,(height-h)/2,0);
135
       mMove.set(0,(height-h)*0.5f,0);
140 136
       mScale.set(factor,factor,factor);
141 137
       }
142 138
      
src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java
37 37
import org.distorted.library.mesh.MeshBase;
38 38
import org.distorted.library.mesh.MeshFlat;
39 39
import org.distorted.library.message.EffectListener;
40
import org.distorted.library.message.EffectMessage;
41 40
import org.distorted.library.type.Dynamic1D;
42 41
import org.distorted.library.type.Dynamic4D;
43 42
import org.distorted.library.type.Static1D;
......
93 92
      for(int j=0; j<NUM_LEAVES; j++)
94 93
        {
95 94
        mLeafEffects[j] = new DistortedEffects();
96
        mLeafEffects[j].registerForMessages(this);
97 95
        mLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
98 96
        mLeafEffects[j].apply(leafMove);
99 97
        mLeafEffects[j].apply( new FragmentEffectChroma(chromaLevel, new Static3D(colors[3*j],colors[3*j+1], colors[3*j+2])) );
......
141 139
     {
142 140
     mGlowing = leaf;
143 141
     mLeafEffects[leaf].apply(mGlow[leaf]);
142
     mGlow[leaf].notifyWhenFinished(this);
144 143
     }
145 144

  
146 145
///////////////////////////////////////////////////////////////////////////////////////////////////
147 146
// Glow finished. Make the next Leaf glow.
148 147

  
149
   public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
148
   public void effectFinished(final long effectID)
150 149
     {
151
     switch(em)
152
       {
153
       case EFFECT_FINISHED: mLeafEffects[mGlowing].abortById(effectID);
150
     mLeafEffects[mGlowing].abortById(effectID);
154 151

  
155
                             int glowing = mGlowing+1;
156
                             if( glowing>=NUM_LEAVES ) glowing = 0;
157
                             makeGlow(glowing);
158
                             break;
159
       }
152
     int glowing = mGlowing+1;
153
     if( glowing>=NUM_LEAVES ) glowing = 0;
154
     makeGlow(glowing);
160 155
     }
161 156

  
162 157
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/rubik/RubikCube.java
63 63
    private DistortedEffects[][][] mEffects;
64 64
    private Static3D[][][] mRotationAxis;
65 65
    private Dynamic1D[][][] mRotationAngle;
66
    private MatrixEffectRotate[][][] mRotate;
66 67
    private DistortedTexture mTexture;
67 68
    private int mSize;
68 69

  
......
79 80
      mEffects        = new DistortedEffects[mSize][mSize][mSize];
80 81
      mRotationAxis   = new Static3D[mSize][mSize][mSize];
81 82
      mRotationAngle  = new Dynamic1D[mSize][mSize][mSize];
83
      mRotate         = new MatrixEffectRotate[mSize][mSize][mSize];
82 84

  
83 85
      Static3D[][][] cubeVectors = new Static3D[mSize][mSize][mSize];
84 86

  
......
134 136

  
135 137
              mRotationAngle[x][y][z].add(new Static1D(0.0f));
136 138
              mRotationAngle[x][y][z].add(new Static1D(0.0f));
139
              mRotate[x][y][z] = new MatrixEffectRotate( mRotationAngle[x][y][z], mRotationAxis[x][y][z], center);
137 140

  
138 141
              mEffects[x][y][z] = new DistortedEffects();
139 142
              mEffects[x][y][z].apply(sinkEffect);
140 143
              mEffects[x][y][z].apply(moveEffect);
141 144
              mEffects[x][y][z].apply(scaleEffect);
142 145
              mEffects[x][y][z].apply(quatEffect);
143
              mEffects[x][y][z].apply( new MatrixEffectRotate( mRotationAngle[x][y][z], mRotationAxis[x][y][z], center));
146
              mEffects[x][y][z].apply( mRotate[x][y][z] );
144 147
              mEffects[x][y][z].apply( new MatrixEffectMove(cubeVectors[x][y][z]) );
145 148
              }
146 149
            }
......
224 227
               if( first )
225 228
                 {
226 229
                 first = false;
227
                 mEffects[x][y][z].registerForMessages(listener);
230
                 mRotate[x][y][z].notifyWhenFinished(listener);
228 231
                 }
229 232
               }
230 233
             }
src/main/java/org/distorted/examples/rubik/RubikRenderer.java
25 25
import org.distorted.library.main.DistortedLibrary;
26 26
import org.distorted.library.main.DistortedScreen;
27 27
import org.distorted.library.message.EffectListener;
28
import org.distorted.library.message.EffectMessage;
29 28
import org.distorted.library.type.Static3D;
30 29

  
31 30
import javax.microedition.khronos.egl.EGLConfig;
......
84 83
      }
85 84

  
86 85
///////////////////////////////////////////////////////////////////////////////////////////////////
87
// EffectListener. The library sends a message to us when it's time to create a new cube.
88 86

  
89
   public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
87
   public void effectFinished(final long effectID)
90 88
     {
91
     switch(em)
92
        {
93
        case EFFECT_FINISHED: mNextCubeSize++;
94
                              if( mNextCubeSize> MAX_CUBE_SIZE ) mNextCubeSize = MIN_CUBE_SIZE;
95
                              mChangeCubeSizeNow = true;
96
                              break;
97
        }
89
     mNextCubeSize++;
90
     if( mNextCubeSize> MAX_CUBE_SIZE ) mNextCubeSize = MIN_CUBE_SIZE;
91
     mChangeCubeSizeNow = true;
98 92
     }
99 93

  
100 94
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java
40 40
import org.distorted.library.type.Static1D;
41 41
import org.distorted.library.type.Static3D;
42 42
import org.distorted.library.message.EffectListener;
43
import org.distorted.library.message.EffectMessage;
44 43
import org.distorted.library.main.DistortedLibrary;
45 44
import org.distorted.library.main.DistortedTexture;
46 45
import org.distorted.library.main.DistortedEffects;
......
113 112
  private DistortedScreen mScreen;
114 113
  private MeshFlat mQuad;
115 114

  
116
  private long gffaID, logoID, crawlID;
115
  private long alphaEffectID, scaleEffectID, moveEffectID;
117 116
  private Random mRnd = new Random(0);
118 117
  private int mWidth, mHeight;
119 118

  
......
245 244
    di.add(new Static1D(1.0f));
246 245
    di.add(new Static1D(1.0f));
247 246
    di.add(new Static1D(0.0f));
248
    
247

  
248
    FragmentEffectAlpha alpha = new FragmentEffectAlpha(di);
249
    alpha.notifyWhenFinished(this);
250
    alphaEffectID = alpha.getID();
251

  
249 252
    mGFFAEffects.apply( new MatrixEffectMove(new Static3D(w/5,2*h/3,0)) );
250 253
    mGFFAEffects.apply( new MatrixEffectScale(scale) );
251
    mGFFAEffects.apply( new FragmentEffectAlpha(di) );
254
    mGFFAEffects.apply( alpha );
252 255
      
253 256
    mScreen.attach(mGFFATexture, mGFFAEffects, mQuad);
254
    mGFFAEffects.registerForMessages(this);
255 257
    }
256 258
    
257 259
///////////////////////////////////////////////////////////////////////////////////////////////////
......
321 323
    ///// create Stars ///////////////////
322 324
    if( mStarTexture==null ) mStarTexture = new DistortedTexture(bitmapStar.getWidth(),bitmapStar.getHeight());
323 325
    mStarTexture.setTexture(bitmapStar);
324

  
325
    gffaID = mGFFAEffects.getID();
326
    logoID = mLogoEffects.getID();
327
    crawlID= mCrawlEffects.getID();
328 326
    }
329 327
 
330 328
///////////////////////////////////////////////////////////////////////////////////////////////////
......
370 368
    }
371 369
    
372 370
///////////////////////////////////////////////////////////////////////////////////////////////////
373
// the library sending messages to us. This is running on a library 'MessageSender' thread.
374 371

  
375
  public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
372
  public void effectFinished(final long effectID)
376 373
    {
377
    if( em==EffectMessage.EFFECT_FINISHED )
374
    if( effectID == alphaEffectID )
378 375
      {
379
      if( objectID == gffaID )
380
        {
381
        mScreen.detach(mGFFAEffects);
382
        mGFFATexture.markForDeletion();
376
      mScreen.detach(mGFFAEffects);
377
      mGFFATexture.markForDeletion();
383 378

  
384
        int screenW=mScreen.getWidth();
385
        int screenH=mScreen.getHeight();
379
      int screenW=mScreen.getWidth();
380
      int screenH=mScreen.getHeight();
386 381
        
387
        int logoW = mLogoTexture.getWidth();
388
        int logoH = mLogoTexture.getHeight();
382
      int logoW = mLogoTexture.getWidth();
383
      int logoH = mLogoTexture.getHeight();
389 384
      
390
        int initSize= (int)(3.0f*screenW/logoW);
391
        int finaSize= (int)(0.1f*screenW/logoW);
385
      int initSize= (int)(3.0f*screenW/logoW);
386
      int finaSize= (int)(0.1f*screenW/logoW);
392 387
      
393
        Dynamic3D di = new Dynamic3D(10000,0.5f);
394
        di.add(new Static3D(initSize,initSize,1));
395
        di.add(new Static3D(finaSize,finaSize,1));
396

  
397
        mLogoEffects.apply( new MatrixEffectMove(new Static3D(screenW/2,screenH/2,0)) );
398
        mLogoEffects.apply( new MatrixEffectScale(di) );
399
        mLogoEffects.apply( new MatrixEffectMove(new Static3D(-logoW/2,-logoH/2,0)) );
388
      Dynamic3D di = new Dynamic3D(10000,0.5f);
389
      di.add(new Static3D(initSize,initSize,1));
390
      di.add(new Static3D(finaSize,finaSize,1));
391
      MatrixEffectScale scale = new MatrixEffectScale(di);
392
      scale.notifyWhenFinished(this);
393
      scaleEffectID = scale.getID();
394

  
395
      mLogoEffects.apply( new MatrixEffectMove(new Static3D(screenW/2,screenH/2,0)) );
396
      mLogoEffects.apply( scale );
397
      mLogoEffects.apply( new MatrixEffectMove(new Static3D(-logoW/2,-logoH/2,0)) );
400 398
      
401
        mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
402
        mLogoEffects.registerForMessages(this);
403
        }
404
      else if( objectID==logoID )
405
        {
406
        mScreen.detach(mLogoEffects);
407
        mLogoTexture.markForDeletion();
399
      mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
400
      }
401
    else if( effectID == scaleEffectID )
402
      {
403
      mScreen.detach(mLogoEffects);
404
      mLogoTexture.markForDeletion();
408 405
        
409
        int crawlW = mCrawlTexture.getWidth();
410
        int crawlH = mCrawlTexture.getHeight();
411
        int screenW= mScreen.getWidth();
412
        int backH  = mCrawlBackgroundTexture.getHeight();
413
        float scale= (float)screenW/crawlW;
414

  
415
        mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,0,0)) );
416

  
417
        final int transpDist = 5;
418
        Static3D center = new Static3D( screenW/2 , transpDist*backH , 0 );
419
        Static3D region = new Static3D( transpDist*backH , transpDist*backH , transpDist*backH );
420
        mCrawlBackgroundEffects.apply( new FragmentEffectAlpha(new Static1D(1-transpDist*0.6f), center, region, true) );
421

  
422
        Dynamic3D di = new Dynamic3D(70000,0.5f);
423
        di.add(new Static3D(screenW/2,-scale*crawlH/2        , 0));
424
        di.add(new Static3D(screenW/2,+scale*crawlH/2 + backH, 0));
425

  
426
        mCrawlEffects.apply( new MatrixEffectMove(di) );
427
        mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale,scale,scale)) );
428
        mCrawlEffects.apply( new MatrixEffectMove(new Static3D(-crawlW/2,-crawlH/2,0)) );
406
      int crawlW = mCrawlTexture.getWidth();
407
      int crawlH = mCrawlTexture.getHeight();
408
      int screenW= mScreen.getWidth();
409
      int backH  = mCrawlBackgroundTexture.getHeight();
410
      float scale= (float)screenW/crawlW;
411

  
412
      mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,0,0)) );
413

  
414
      final int transpDist = 5;
415
      Static3D center = new Static3D( screenW/2 , transpDist*backH , 0 );
416
      Static3D region = new Static3D( transpDist*backH , transpDist*backH , transpDist*backH );
417
      mCrawlBackgroundEffects.apply( new FragmentEffectAlpha(new Static1D(1-transpDist*0.6f), center, region, true) );
418

  
419
      Dynamic3D di = new Dynamic3D(70000,0.5f);
420
      di.add(new Static3D(screenW/2,-scale*crawlH/2        , 0));
421
      di.add(new Static3D(screenW/2,+scale*crawlH/2 + backH, 0));
422
      MatrixEffectMove move = new MatrixEffectMove(di);
423
      move.notifyWhenFinished(this);
424
      moveEffectID = move.getID();
425

  
426
      mCrawlEffects.apply( move );
427
      mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale,scale,scale)) );
428
      mCrawlEffects.apply( new MatrixEffectMove(new Static3D(-crawlW/2,-crawlH/2,0)) );
429 429
        
430
        mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
431
        mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad);
432
        mBackground.glDisable(GLES31.GL_DEPTH_TEST);
433
        mBackground.glDepthMask(false);
434
        mCrawlEffects.registerForMessages(this);
435
        }
436
      else if( objectID==crawlID )
437
        {
438
        mScreen.detach(mBackground);
439
        mBackground.detach(mCrawlEffects);
440
        mCrawlTexture.markForDeletion();
441
        mCrawlBackgroundEffects.abortAllEffects();
442
        mCrawlBackgroundTexture.markForDeletion();
443
        }
430
      mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
431
      mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad);
432
      mBackground.glDisable(GLES31.GL_DEPTH_TEST);
433
      mBackground.glDepthMask(false);
434
      }
435
    else if( effectID == moveEffectID )
436
      {
437
      mScreen.detach(mBackground);
438
      mBackground.detach(mCrawlEffects);
439
      mCrawlTexture.markForDeletion();
440
      mCrawlBackgroundEffects.abortAllEffects();
441
      mCrawlBackgroundTexture.markForDeletion();
444 442
      }
445 443
    }
446 444
  }

Also available in: Unified diff