Project

General

Profile

« Previous | Next » 

Revision 6ddda212

Added by Leszek Koltunski about 8 years ago

Adjustments for EffectQueueVertex.postprocess()

View differences:

src/main/java/org/distorted/library/DistortedObject.java
164 164
    mM.send(mViewMatrix, dp);
165 165
      
166 166
    mV.compute(currTime);
167
    mV.postprocess();
168 167
    mV.send();
169 168
        
170 169
    mF.compute(currTime);
src/main/java/org/distorted/library/EffectQueueVertex.java
71 71
   
72 72
    for(int i=0; i<mNumEffects; i++)
73 73
      {
74
      if( mInter[0][i]!=null && mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i, mCurrentDuration[i], step) )
74
      if( mInter[0][i]!=null )
75 75
        {
76
        for(int j=0; j<mNumListeners; j++)
77
          EffectMessageSender.newMessage( mListeners.elementAt(j),
78
                                          EffectMessage.EFFECT_FINISHED,
79
                                         (mID[i]<<EffectTypes.LENGTH)+EffectTypes.VERTEX.type,
80
                                          mName[i],
81
                                          mBitmapID,
82
                                          null);
83

  
84
        if( EffectNames.isUnity(mName[i], mUniforms, NUM_UNIFORMS*i) )
76
        if( mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i, mCurrentDuration[i], step) )
85 77
          {
86
          remove(i);
87
          i--;
88
          continue;
78
          for(int j=0; j<mNumListeners; j++)
79
            EffectMessageSender.newMessage( mListeners.elementAt(j),
80
                                            EffectMessage.EFFECT_FINISHED,
81
                                           (mID[i]<<EffectTypes.LENGTH)+EffectTypes.VERTEX.type,
82
                                            mName[i],
83
                                            mBitmapID,
84
                                            null);
85

  
86
          if( EffectNames.isUnity(mName[i], mUniforms, NUM_UNIFORMS*i) )
87
            {
88
            remove(i);
89
            i--;
90
            continue;
91
            }
92
          else mInter[0][i] = null;
93
          }
94
        else
95
          {
96
          postprocess(i);
89 97
          }
90
        else mInter[0][i] = null;
91 98
        }
92 99

  
93 100
      if( mInter[1][i]!=null )  // region
......
153 160
// 2) in case of swirl, pre-compute the sine and cosine of its rotation angle
154 161
// 3) likewise in case of wave
155 162
  
156
  void postprocess()
163
  void postprocess(int effect)
157 164
    {
158 165
    double d;  
159
     
160
    for(int i=0; i<mNumEffects; i++)
161
      {      
162
      if( mName[i]==EffectNames.SWIRL.ordinal() )
163
        {
164
        d = Math.PI*mUniforms[NUM_UNIFORMS*i]/180;  
165
        mUniforms[NUM_UNIFORMS*i+4] = (float)Math.sin(d);
166
        mUniforms[NUM_UNIFORMS*i+5] = (float)Math.cos(d);
167
        }
168
      if( mName[i]==EffectNames.WAVE.ordinal() )
169
        {
170
        d = Math.PI*mUniforms[NUM_UNIFORMS*i+1]/180;
171
        mUniforms[NUM_UNIFORMS*i+4] = (float)Math.sin(d);
172
        mUniforms[NUM_UNIFORMS*i+5] = (float)Math.cos(d);
173
        }
166

  
167
    if( mName[effect]==EffectNames.SWIRL.ordinal() )
168
      {
169
      d = Math.PI*mUniforms[NUM_UNIFORMS*effect]/180;
170
      mUniforms[NUM_UNIFORMS*effect+4] = (float)Math.sin(d);
171
      mUniforms[NUM_UNIFORMS*effect+5] = (float)Math.cos(d);
172
      }
173
    if( mName[effect]==EffectNames.WAVE.ordinal() )
174
      {
175
      d = Math.PI*mUniforms[NUM_UNIFORMS*effect+1]/180;
176
      mUniforms[NUM_UNIFORMS*effect+4] = (float)Math.sin(d);
177
      mUniforms[NUM_UNIFORMS*effect+5] = (float)Math.cos(d);
174 178
      }
175 179
    }
176 180
  
......
312 316
      mUniforms[NUM_UNIFORMS*mNumEffects+7] =-((Static2D)center).getY()+mObjHalfY;
313 317
      }
314 318

  
315
    return addBase(eln);
319
    long ret= addBase(eln);
320

  
321
    postprocess(mNumEffects-1); //addBase just incremented mNumEffects
322

  
323
    return ret;
316 324
    }
317 325

  
318 326
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/res/raw/main_vertex_shader.glsl
360 360
  float d = dot( vec2(-ps.y,-ps.x),sincos );
361 361
  float num = length==0.0 ? 0.0 : d / length;
362 362

  
363
  v.xy += (sin(1.57*num)*amplitude*deg*sincos);
363
  v.xy += (sin(1.578*num)*amplitude*deg*sincos);
364 364
  }
365 365

  
366 366
#endif

Also available in: Unified diff