Project

General

Profile

« Previous | Next » 

Revision d79a56d3

Added by Leszek Koltunski about 7 years ago

Major refactoring: convert the Matrix Effects to be independent of the resolution of the surface we render to.

Re-write the first 15 apps to work with this.

View differences:

src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java
207 207
    if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion();
208 208
    mCrawlBackgroundTexture = new DistortedTexture(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)));
209 209
       
210
    int randomA, randomX, randomY, randomTime;
211
    float randomS, randomAlpha1, randomAlpha2;
212
       
213
    Static3D center = new Static3D(0,0,0);
214
    Static3D axis   = new Static3D(0,0,1);
210
    int randomTime;
211
    float randomX, randomY, randomS, randomAlpha1, randomAlpha2;
212

  
213
    float starScaleX = (float)mStarTexture.getWidth()/w;
214
    float starScaleY = (float)mStarTexture.getHeight()/h;
215

  
215 216
    Static1D alphaNoise = new Static1D(0.4f);
216 217

  
217 218
    for(int i=0; i<NUM_STARS; i++)
218 219
      {
219
      randomX = mRnd.nextInt(w);
220
      randomY = mRnd.nextInt(h);
220
      randomX = mRnd.nextFloat() -0.5f;
221
      randomY = mRnd.nextFloat() -0.5f;
221 222
      randomS = 0.2f+ 0.8f*mRnd.nextFloat();
222
      randomA = (int)(180*mRnd.nextFloat());
223 223
      randomAlpha1 = 0.2f + 0.8f*mRnd.nextFloat();
224 224
      randomAlpha2 = 0.8f + 0.2f*mRnd.nextFloat();
225 225
      randomTime = 500+mRnd.nextInt(2000);
226 226
      
227 227
      mStarEffects[i].move( new Static3D(randomX,randomY,0) );
228
      mStarEffects[i].scale(randomS);
229
      mStarEffects[i].rotate( new Static1D(randomA), axis, center );
230
      
228
      mStarEffects[i].scale( new Static3D(randomS*starScaleX, randomS*starScaleY, 1) );
229

  
231 230
      Dynamic1D di = new Dynamic1D(randomTime,0.0f);
232 231
      di.setNoise(alphaNoise);
233 232
      di.add(new Static1D(randomAlpha1));
......
237 236
      
238 237
      mScreen.attach(mStarTexture, mStarEffects[i], mQuad);
239 238
      }
240
      
241
    float scale = (0.5f*w/mGFFATexture.getWidth());
242
    
239

  
240
    float qx = (float)mGFFATexture.getWidth()/w;
241
    float qy = (float)mGFFATexture.getHeight()/h;
242

  
243 243
    Dynamic1D di = new Dynamic1D(6000,0.5f);
244 244
    di.add(new Static1D(1.0f));
245 245
    di.add(new Static1D(1.0f));
246 246
    di.add(new Static1D(0.0f));
247 247
    
248
    mGFFAEffects.move( new Static3D(w/5,h/3,0) );
249
    mGFFAEffects.scale( new Static3D(scale,scale,scale) );
248
    mGFFAEffects.move( new Static3D(qx/2-0.3f,qy/2-0.16f,0) );
249
    mGFFAEffects.scale( new Static3D(qx,qy,1) );
250 250
    mGFFAEffects.alpha(di);
251 251
      
252 252
    mScreen.attach(mGFFATexture, mGFFAEffects, mQuad);
......
380 380
        mScreen.detach(mGFFAEffects);
381 381
        mGFFATexture.markForDeletion();
382 382

  
383
        int screenW=mScreen.getWidth();
384
        int screenH=mScreen.getHeight();
385
        
386
        int logoW = mLogoTexture.getWidth();
387
        int logoH = mLogoTexture.getHeight();
388
      
389
        int initSize= (int)(3.0f*screenW/logoW);
390
        int finaSize= (int)(0.1f*screenW/logoW);
383
        float qx= (float)mScreen.getWidth() /mLogoTexture.getWidth() ;
384
        float qy= (float)mScreen.getHeight()/mLogoTexture.getHeight();
385

  
386
        float initSize= 3.0f;
387
        float finaSize= 0.1f;
391 388
      
392 389
        Dynamic3D di = new Dynamic3D(10000,0.5f);
393
        di.add(new Static3D(initSize,initSize,1));
394
        di.add(new Static3D(finaSize,finaSize,1));
390
        di.add(qx<qy ? (new Static3D(initSize,initSize*qx/qy,1)) : (new Static3D(initSize*qy/qx,initSize,1)));
391
        di.add(qx<qy ? (new Static3D(finaSize,finaSize*qx/qy,1)) : (new Static3D(finaSize*qy/qx,finaSize,1)));
395 392

  
396
        mLogoEffects.move( new Static3D(screenW/2,screenH/2,0) );
397 393
        mLogoEffects.scale(di);
398
        mLogoEffects.move( new Static3D(-logoW/2,-logoH/2,0) );
399
      
394

  
400 395
        mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
401 396
        mLogoEffects.registerForMessages(this);
402 397
        }
......
412 407
        int backH  = mCrawlBackgroundTexture.getHeight();
413 408
        float scale= (float)screenW/crawlW;
414 409

  
415
        mCrawlBackgroundEffects.move( new Static3D(0,screenH-backH,0) );
416
        mCrawlBackgroundEffects.rotate( new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,backH,0) );
410
        //mCrawlBackgroundEffects.move( new Static3D(0,screenH-backH,0) );
411
        mCrawlBackgroundEffects.rotate( new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(0.5f,1.0f,0.0f) );
412
        mCrawlBackgroundEffects.scale( new Static3D(1.0f, (float)backH/screenH,1.0f) );
417 413

  
418 414
        final int transpDist = 5;
419 415
        Static4D region = new Static4D(screenW/2,(1-transpDist)*backH,transpDist*backH,transpDist*backH);
420
        mCrawlBackgroundEffects.alpha(new Static1D(1-transpDist*0.6f), region, true);
416
        //mCrawlBackgroundEffects.alpha(new Static1D(1-transpDist*0.6f), region, true);
421 417

  
422 418
        Dynamic3D di = new Dynamic3D(70000,0.5f);
423 419
        di.add(new Static3D(screenW/2,+backH       , 0));
424 420
        di.add(new Static3D(screenW/2,-scale*crawlH, 0));
425 421

  
426
        mCrawlEffects.move(di);
427
        mCrawlEffects.scale( new Static3D(scale,scale,scale) );
428
        mCrawlEffects.move( new Static3D(-crawlW/2,0,0) );
422
        //mCrawlEffects.move(di);
423
        //mCrawlEffects.scale( new Static3D(scale,scale,scale) );
424
        //mCrawlEffects.move( new Static3D(-crawlW/2,0,0) );
429 425
        
430 426
        mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
431 427
        mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad);

Also available in: Unified diff