Project

General

Profile

« Previous | Next » 

Revision 16b22aab

Added by Leszek Koltunski about 5 years ago

Fix several more apps for the 'center-of-matrix-effects-in-screen-center' change.

View differences:

src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java
200 200
    
201 201
///////////////////////////////////////////////////////////////////////////////////////////////////
202 202

  
203
  private void setupScreen(int w, int h)
203
  private void setupScreen(int scrW, int scrH)
204 204
    {
205
    double angleA = (90.0f - FOV_ANGLE/2)*Math.PI/180;
206
    double angleB = (90.0f - FOV_ANGLE/2 +CRAWL_ANGLE)*Math.PI/180;
205
    double angleA = (90.0f - FOV_ANGLE/2              ) * Math.PI/180;
206
    double angleB = (90.0f - FOV_ANGLE/2 + CRAWL_ANGLE) * Math.PI/180;
207 207

  
208 208
    if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion();
209
    mCrawlBackgroundTexture = new DistortedTexture(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)));
210
       
209
    mCrawlBackgroundTexture = new DistortedTexture(scrW,(int)(scrH*Math.sin(angleA)/Math.sin(angleB)));
210

  
211 211
    int randomA, randomX, randomY, randomTime;
212 212
    float randomS, randomAlpha1, randomAlpha2;
213 213
       
......
217 217

  
218 218
    for(int i=0; i<NUM_STARS; i++)
219 219
      {
220
      randomX = mRnd.nextInt(w);
221
      randomY = mRnd.nextInt(h);
220
      randomX = mRnd.nextInt(scrW) - scrW/2;
221
      randomY = mRnd.nextInt(scrH) - scrH/2;
222 222
      randomS = 0.2f+ 0.8f*mRnd.nextFloat();
223 223
      randomA = (int)(180*mRnd.nextFloat());
224 224
      randomAlpha1 = 0.2f + 0.8f*mRnd.nextFloat();
......
239 239
      mScreen.attach(mStarTexture, mStarEffects[i], mQuad);
240 240
      }
241 241
      
242
    float scale = (0.5f*w/mGFFATexture.getWidth());
242
    float scale = (0.5f*scrW/mGFFATexture.getWidth());
243 243
    
244 244
    Dynamic1D di = new Dynamic1D(6000,0.5f);
245 245
    di.add(new Static1D(1.0f));
246 246
    di.add(new Static1D(1.0f));
247 247
    di.add(new Static1D(0.0f));
248 248
    
249
    mGFFAEffects.apply( new MatrixEffectMove(new Static3D(w/5,2*h/3,0)) );
249
    mGFFAEffects.apply( new MatrixEffectMove(new Static3D(-scrW/3 + mGFFATexture.getWidth()/2 ,scrH/6,0)) );
250 250
    mGFFAEffects.apply( new MatrixEffectScale(scale) );
251 251
    mGFFAEffects.apply( new FragmentEffectAlpha(di) );
252 252
      
......
382 382
        mGFFATexture.markForDeletion();
383 383

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

  
397
        mLogoEffects.apply( new MatrixEffectMove(new Static3D(screenW/2,screenH/2,0)) );
398 393
        mLogoEffects.apply( new MatrixEffectScale(di) );
399
        mLogoEffects.apply( new MatrixEffectMove(new Static3D(-logoW/2,-logoH/2,0)) );
400
      
394

  
401 395
        mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
402 396
        mLogoEffects.registerForMessages(this);
403 397
        }
......
409 403
        int crawlW = mCrawlTexture.getWidth();
410 404
        int crawlH = mCrawlTexture.getHeight();
411 405
        int screenW= mScreen.getWidth();
406
        int screenH= mScreen.getHeight();
407
        int backW  = mCrawlBackgroundTexture.getWidth();
412 408
        int backH  = mCrawlBackgroundTexture.getHeight();
413
        float scale= (float)screenW/crawlW;
409
        float scale= (float)backW/crawlW;
414 410

  
415
        mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,0,0)) );
411
        mCrawlBackgroundEffects.apply( new MatrixEffectMove(new Static3D( 0, (backH-screenH)/2, 0)) );
412
        mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(0,-backH/2,0)) );
416 413

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

  
422 419
        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));
420
        di.add(new Static3D(0, -(scale*crawlH+backH)/2, 0));
421
        di.add(new Static3D(0, +(scale*crawlH+backH)/2, 0));
425 422

  
426 423
        mCrawlEffects.apply( new MatrixEffectMove(di) );
427 424
        mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale,scale,scale)) );
428
        mCrawlEffects.apply( new MatrixEffectMove(new Static3D(-crawlW/2,-crawlH/2,0)) );
429
        
425

  
430 426
        mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
431 427
        mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad);
432 428
        mBackground.glDisable(GLES31.GL_DEPTH_TEST);

Also available in: Unified diff