Project

General

Profile

« Previous | Next » 

Revision 39a0d81b

Added by Leszek Koltunski about 7 years ago

Convert next 4 APPs to the new Matrix effects.

View differences:

src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java
68 68
        };
69 69

  
70 70
    private static final int NUM_OBJECTS = MOVE_VEC.length/3;
71
    private static final int OBJ_SIZE    = 100;
72 71

  
73 72
    private GLSurfaceView mView;
74 73
    private DistortedTexture mTex1, mTex2;
......
83 82
    private DynamicQuat mQuatInt1, mQuatInt2;
84 83
    private int mDistance;
85 84
    private boolean[] mBlurStatus;
85
    private int mScreenW, mScreenH;
86 86

  
87 87
    Static4D mQuat1, mQuat2;
88 88
    int mScreenMin;
......
114 114
      fpsTexture.setTexture(fpsBitmap);
115 115
      fpsCanvas = new Canvas(fpsBitmap);
116 116
      fpsEffects = new DistortedEffects();
117
      fpsEffects.move( new Static3D(5,5,0) );
118 117
      durations = new long[NUM_FRAMES+1];
119 118
      currDuration = 0;
120 119

  
......
149 148

  
150 149
      MeshCubes mesh = new MeshCubes(1,1,false);
151 150

  
152
      mTex1 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
153
      mTex2 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
151
      mTex1 = new DistortedTexture(1,1);
152
      mTex2 = new DistortedTexture(1,1);
154 153

  
155 154
      mQuat1 = new Static4D(0,0,0,1);  // unity
156 155
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
196 195
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
197 196
      {
198 197
      mScreenMin = width<height ? width:height;
198
      mScreenW = width;
199
      mScreenH = height;
199 200

  
200
    	float factor    = 0.15f*mScreenMin/OBJ_SIZE;
201
      Static3D center = new Static3D( (float)OBJ_SIZE/2, (float)OBJ_SIZE/2, 0.0f );
202
      Static3D moveVec= new Static3D( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0);
201
      fpsEffects.abortAllEffects();
202
      fpsEffects.move(  new Static3D( -0.5f + (fpsW/2 + 5.0f)/width, -0.5f + (fpsH/2 + 5.0f)/height,0.0f) );
203
      fpsEffects.scale( new Static3D( (float)fpsW/width, (float)fpsH/height, 1.0f) );
204

  
205
      float q= (float)width/height;
206
      float scale = 0.15f;
207
      Static3D center = new Static3D(0,0,0);
208
      Static3D factor = (q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)));
203 209

  
204 210
      for(int i=0; i<NUM_OBJECTS; i++)
205 211
        {
206 212
        mEffects[i].abortEffects(EffectTypes.MATRIX);
207 213

  
208
        mEffects[i].move(moveVec);
209
        mEffects[i].scale(factor);
210 214
        mEffects[i].quaternion(mQuatInt1, center);
211 215
        mEffects[i].quaternion(mQuatInt2, center);
212 216
        mEffects[i].move(mMoveDynamic[i]);
217
        mEffects[i].scale(factor);
213 218
        }
214 219

  
215 220
      computeMoveVectors();
......
275 280

  
276 281
    private void computeMoveVectors()
277 282
      {
278
      float size= 0.026f*OBJ_SIZE*mDistance;
283
      float size = 2.6f*mDistance;
284
      float sizeX= size/mScreenW;
285
      float sizeY= size/mScreenH;
279 286

  
280 287
      for(int i=0; i<NUM_OBJECTS; i++)
281 288
        {
282
        mMoveVector[i].set(size*MOVE_VEC[3*i], size*MOVE_VEC[3*i+1], size*MOVE_VEC[3*i+2]);
289
        mMoveVector[i].set(sizeX*MOVE_VEC[3*i], sizeY*MOVE_VEC[3*i+1], sizeX*MOVE_VEC[3*i+2]);
283 290
        }
284 291
      }
285 292

  

Also available in: Unified diff