Revision 687263cc
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
124 | 124 |
|
125 | 125 |
mQuad = new MeshRectangles(1,1); |
126 | 126 |
|
127 |
mGFFAEffects = new DistortedEffects(); |
|
128 |
mLogoEffects = new DistortedEffects(); |
|
129 |
mCrawlEffects = new DistortedEffects(); |
|
130 |
mCrawlBackgroundEffects = new DistortedEffects(); |
|
127 |
mGFFAEffects = new DistortedEffects(1);
|
|
128 |
mLogoEffects = new DistortedEffects(1);
|
|
129 |
mCrawlEffects = new DistortedEffects(1);
|
|
130 |
mCrawlBackgroundEffects = new DistortedEffects(1);
|
|
131 | 131 |
|
132 | 132 |
if( NUM_STARS>0 ) |
133 | 133 |
{ |
134 | 134 |
mStarEffects = new DistortedEffects[NUM_STARS]; |
135 |
mStarEffects[0] = new DistortedEffects(); |
|
135 |
mStarEffects[0] = new DistortedEffects(1);
|
|
136 | 136 |
|
137 | 137 |
for (int i = 1; i < NUM_STARS; i++) |
138 | 138 |
mStarEffects[i] = new DistortedEffects(mStarEffects[0], DistortedLibrary.CLONE_VERTEX); |
... | ... | |
205 | 205 |
double angleB = (90.0f - FOV_ANGLE/2 +CRAWL_ANGLE)*Math.PI/180; |
206 | 206 |
|
207 | 207 |
if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion(); |
208 |
mCrawlBackgroundTexture = new DistortedTexture(w,(int)(h*Math.sin(angleA)/Math.sin(angleB))); |
|
209 |
|
|
208 |
mCrawlBackgroundTexture = new DistortedTexture(); |
|
209 |
|
|
210 |
mCrawlBackgroundEffects.setStretch(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)),0); |
|
211 |
|
|
210 | 212 |
int randomA, randomX, randomY, randomTime; |
211 | 213 |
float randomS, randomAlpha1, randomAlpha2; |
212 | 214 |
|
... | ... | |
238 | 240 |
mScreen.attach(mStarTexture, mStarEffects[i], mQuad); |
239 | 241 |
} |
240 | 242 |
|
241 |
float scale = (0.5f*w/mGFFATexture.getWidth());
|
|
243 |
float scale = (0.5f*w/mGFFAEffects.getStartchX());
|
|
242 | 244 |
|
243 | 245 |
Dynamic1D di = new Dynamic1D(6000,0.5f); |
244 | 246 |
di.add(new Static1D(1.0f)); |
... | ... | |
290 | 292 |
paint.setTypeface(tf); |
291 | 293 |
|
292 | 294 |
///// create GFFA /////////////////// |
293 |
if( mGFFATexture==null ) mGFFATexture = new DistortedTexture(GFFA_WIDTH,GFFA_HEIGHT); |
|
295 |
mGFFAEffects.setStretch(GFFA_WIDTH,GFFA_HEIGHT,0); |
|
296 |
if( mGFFATexture==null ) mGFFATexture = new DistortedTexture(); |
|
294 | 297 |
bitmapGFFA = Bitmap.createBitmap(GFFA_WIDTH,GFFA_HEIGHT,Bitmap.Config.ARGB_8888); |
295 | 298 |
bitmapGFFA.eraseColor(0x00000000); |
296 | 299 |
Canvas gffaCanvas = new Canvas(bitmapGFFA); |
... | ... | |
303 | 306 |
mGFFATexture.setTexture(bitmapGFFA); |
304 | 307 |
|
305 | 308 |
///// create Logo /////////////////// |
306 |
if( mLogoTexture==null ) mLogoTexture = new DistortedTexture(bitmapLogo.getWidth(),bitmapLogo.getHeight()); |
|
309 |
mLogoEffects.setStretch(bitmapLogo.getWidth(),bitmapLogo.getHeight(),0); |
|
310 |
if( mLogoTexture==null ) mLogoTexture = new DistortedTexture(); |
|
307 | 311 |
mLogoTexture.setTexture(bitmapLogo); |
308 | 312 |
|
309 | 313 |
///// create CRAWL ////////////////// |
310 |
if( mCrawlTexture==null ) mCrawlTexture = new DistortedTexture(CRAWL_WIDTH,CRAWL_HEIGHT); |
|
314 |
mCrawlEffects.setStretch(CRAWL_WIDTH,CRAWL_HEIGHT,0); |
|
315 |
if( mCrawlTexture==null ) mCrawlTexture = new DistortedTexture(); |
|
311 | 316 |
bitmapText = Bitmap.createBitmap(CRAWL_WIDTH,CRAWL_HEIGHT,Bitmap.Config.ARGB_8888); |
312 | 317 |
bitmapText.eraseColor(0x00000000); |
313 | 318 |
Canvas textCanvas = new Canvas(bitmapText); |
... | ... | |
321 | 326 |
mCrawlTexture.setTexture(bitmapText); |
322 | 327 |
|
323 | 328 |
///// create Stars /////////////////// |
324 |
if( mStarTexture==null ) mStarTexture = new DistortedTexture(bitmapStar.getWidth(),bitmapStar.getHeight()); |
|
329 |
mStarEffects[0].setStretch(bitmapStar.getWidth(),bitmapStar.getHeight(),0); |
|
330 |
if( mStarTexture==null ) mStarTexture = new DistortedTexture(); |
|
325 | 331 |
mStarTexture.setTexture(bitmapStar); |
326 | 332 |
} |
327 | 333 |
|
... | ... | |
379 | 385 |
int screenW=mScreen.getWidth(); |
380 | 386 |
int screenH=mScreen.getHeight(); |
381 | 387 |
|
382 |
int logoW = mLogoTexture.getWidth();
|
|
383 |
int logoH = mLogoTexture.getHeight();
|
|
388 |
int logoW = mLogoEffects.getStartchX();
|
|
389 |
int logoH = mLogoEffects.getStartchY();
|
|
384 | 390 |
|
385 | 391 |
int initSize= (int)(3.0f*screenW/logoW); |
386 | 392 |
int finaSize= (int)(0.1f*screenW/logoW); |
... | ... | |
403 | 409 |
mScreen.detach(mLogoEffects); |
404 | 410 |
mLogoTexture.markForDeletion(); |
405 | 411 |
|
406 |
int crawlW = mCrawlTexture.getWidth();
|
|
407 |
int crawlH = mCrawlTexture.getHeight();
|
|
412 |
int crawlW = mCrawlEffects.getStartchX();
|
|
413 |
int crawlH = mCrawlEffects.getStartchY();
|
|
408 | 414 |
int screenW= mScreen.getWidth(); |
409 |
int backH = mCrawlBackgroundTexture.getHeight();
|
|
415 |
int backH = mCrawlBackgroundEffects.getStartchY();
|
|
410 | 416 |
float scale= (float)screenW/crawlW; |
411 | 417 |
|
412 | 418 |
mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,0,0)) ); |
Also available in: Unified diff
Move the 'pre-multiply mesh before applying any effects' thing from [(Xsize of texture, Ysize of texture) x Mesh's zFactor] to Effects.setStretch(sx,sy,sz)