Project

General

Profile

« Previous | Next » 

Revision 735a8757

Added by Leszek Koltunski over 7 years ago

Simplification in EffectQueueMatrix.

View differences:

src/main/java/org/distorted/library/main/EffectQueueMatrix.java
146 146
    Matrix.scaleM(mViewMatrix, 0, scale, scale, scale);
147 147
    }
148 148

  
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150
// here construct the ModelView and the ModelViewProjection Matrices
151

  
152
  private void constructMatrices(DistortedOutputSurface projection, float halfX, float halfY, float halfZ, float marginInPixels)
153
    {
154
    Matrix.setIdentityM(mViewMatrix, 0);
155
    Matrix.translateM(mViewMatrix, 0, -projection.mWidth/2, projection.mHeight/2, -projection.mDistance);
156
    float mipmap = projection.mMipmap;
157
    if( mipmap!=1 ) Matrix.scaleM(mViewMatrix, 0, mipmap, mipmap, mipmap);
158

  
159
    for(int i=0; i<mNumEffects; i++) ((MatrixEffect)mEffects[i]).apply(mViewMatrix,mUniforms,i);
160

  
161
    Matrix.translateM(mViewMatrix, 0, halfX,-halfY,-halfZ);
162
    if( marginInPixels!=0 ) magnify(projection,halfX,halfY,halfZ, marginInPixels);
163
    Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mViewMatrix, 0);
164
    }
165

  
166 149
///////////////////////////////////////////////////////////////////////////////////////////////////
167 150

  
168 151
  static void getUniforms(int mProgramH)
......
174 157

  
175 158
///////////////////////////////////////////////////////////////////////////////////////////////////
176 159

  
177
  synchronized void compute(long currTime) 
160
  void compute(long currTime)
178 161
    {
179 162
    if( currTime==mTime ) return;
180 163
    if( mTime==0 ) mTime = currTime;
......
209 192

  
210 193
///////////////////////////////////////////////////////////////////////////////////////////////////
211 194

  
212
  synchronized void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ, float marginInPixels)
195
  void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ, float marginInPixels)
213 196
    {
214
    constructMatrices(projection,halfX,halfY,halfZ, marginInPixels);
197
    Matrix.setIdentityM(mViewMatrix, 0);
198
    Matrix.translateM(mViewMatrix, 0, -projection.mWidth/2, projection.mHeight/2, -projection.mDistance);
199
    float mipmap = projection.mMipmap;
200
    if( mipmap!=1 ) Matrix.scaleM(mViewMatrix, 0, mipmap, mipmap, mipmap);
201

  
202
    for(int i=0; i<mNumEffects; i++) ((MatrixEffect)mEffects[i]).apply(mViewMatrix,mUniforms,i);
203

  
204
    Matrix.translateM(mViewMatrix, 0, halfX,-halfY,-halfZ);
205
    if( marginInPixels!=0 ) magnify(projection,halfX,halfY,halfZ, marginInPixels);
206
    Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mViewMatrix, 0);
215 207

  
216 208
    GLES30.glUniform3f( mObjDH , halfX, halfY, halfZ);
217 209
    GLES30.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0);

Also available in: Unified diff