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

Also available in: Unified diff