Revision 698ad0a8
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
34 | 34 |
import org.distorted.library.effect.MatrixEffectScale; |
35 | 35 |
import org.distorted.library.main.DistortedNode; |
36 | 36 |
import org.distorted.library.main.DistortedScreen; |
37 |
import org.distorted.library.mesh.MeshRectangles;
|
|
37 |
import org.distorted.library.mesh.MeshQuad;
|
|
38 | 38 |
import org.distorted.library.type.Dynamic1D; |
39 | 39 |
import org.distorted.library.type.Dynamic3D; |
40 | 40 |
import org.distorted.library.type.Static1D; |
... | ... | |
110 | 110 |
private DistortedEffects[] mStarEffects; |
111 | 111 |
private DistortedNode mBackground; |
112 | 112 |
private DistortedScreen mScreen; |
113 |
private MeshRectangles mQuad;
|
|
113 |
private MeshQuad mGFFAQuad, mCrawlQuad, mCrawlBackgroundQuad, mLogoQuad, mStarQuad;
|
|
114 | 114 |
|
115 | 115 |
private long alphaEffectID, scaleEffectID, moveEffectID; |
116 | 116 |
private Random mRnd = new Random(0); |
... | ... | |
122 | 122 |
{ |
123 | 123 |
mView = v; |
124 | 124 |
|
125 |
mQuad = new MeshRectangles(1,1); |
|
125 |
mGFFAQuad = new MeshQuad(); |
|
126 |
mStarQuad = new MeshQuad(); |
|
127 |
mCrawlQuad = new MeshQuad(); |
|
128 |
mCrawlBackgroundQuad = new MeshQuad(); |
|
129 |
mLogoQuad = new MeshQuad(); |
|
126 | 130 |
|
127 |
mGFFAEffects = new DistortedEffects(1); |
|
128 |
mLogoEffects = new DistortedEffects(1); |
|
129 |
mCrawlEffects = new DistortedEffects(1); |
|
130 |
mCrawlBackgroundEffects = new DistortedEffects(1); |
|
131 |
mGFFAQuad.setStretch(GFFA_WIDTH,GFFA_HEIGHT,0); |
|
132 |
mCrawlQuad.setStretch(CRAWL_WIDTH,CRAWL_HEIGHT,0); |
|
133 |
|
|
134 |
mGFFAEffects = new DistortedEffects(); |
|
135 |
mLogoEffects = new DistortedEffects(); |
|
136 |
mCrawlEffects = new DistortedEffects(); |
|
137 |
mCrawlBackgroundEffects = new DistortedEffects(); |
|
131 | 138 |
|
132 | 139 |
if( NUM_STARS>0 ) |
133 | 140 |
{ |
134 | 141 |
mStarEffects = new DistortedEffects[NUM_STARS]; |
135 |
mStarEffects[0] = new DistortedEffects(1);
|
|
142 |
mStarEffects[0] = new DistortedEffects(); |
|
136 | 143 |
|
137 | 144 |
for (int i = 1; i < NUM_STARS; i++) |
138 | 145 |
mStarEffects[i] = new DistortedEffects(mStarEffects[0], DistortedLibrary.CLONE_VERTEX); |
... | ... | |
207 | 214 |
if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion(); |
208 | 215 |
mCrawlBackgroundTexture = new DistortedTexture(); |
209 | 216 |
|
210 |
mCrawlBackgroundEffects.setStretch(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)),0);
|
|
217 |
mCrawlBackgroundQuad.setStretch(w,(int)(h*Math.sin(angleA)/Math.sin(angleB)),0);
|
|
211 | 218 |
|
212 | 219 |
int randomA, randomX, randomY, randomTime; |
213 | 220 |
float randomS, randomAlpha1, randomAlpha2; |
... | ... | |
237 | 244 |
|
238 | 245 |
mStarEffects[i].apply( new FragmentEffectAlpha(di) ); |
239 | 246 |
|
240 |
mScreen.attach(mStarTexture, mStarEffects[i], mQuad); |
|
247 |
mScreen.attach(mStarTexture, mStarEffects[i], mStarQuad);
|
|
241 | 248 |
} |
242 | 249 |
|
243 |
float scale = (0.5f*w/mGFFAEffects.getStartchX());
|
|
250 |
float scale = (0.5f*w/mGFFAQuad.getStretchX());
|
|
244 | 251 |
|
245 | 252 |
Dynamic1D di = new Dynamic1D(6000,0.5f); |
246 | 253 |
di.add(new Static1D(1.0f)); |
... | ... | |
255 | 262 |
mGFFAEffects.apply( new MatrixEffectMove(new Static3D(w/5,2*h/3,0)) ); |
256 | 263 |
mGFFAEffects.apply( alpha ); |
257 | 264 |
|
258 |
mScreen.attach(mGFFATexture, mGFFAEffects, mQuad); |
|
265 |
mScreen.attach(mGFFATexture, mGFFAEffects, mGFFAQuad);
|
|
259 | 266 |
} |
260 | 267 |
|
261 | 268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
292 | 299 |
paint.setTypeface(tf); |
293 | 300 |
|
294 | 301 |
///// create GFFA /////////////////// |
295 |
mGFFAEffects.setStretch(GFFA_WIDTH,GFFA_HEIGHT,0); |
|
296 | 302 |
if( mGFFATexture==null ) mGFFATexture = new DistortedTexture(); |
297 | 303 |
bitmapGFFA = Bitmap.createBitmap(GFFA_WIDTH,GFFA_HEIGHT,Bitmap.Config.ARGB_8888); |
298 | 304 |
bitmapGFFA.eraseColor(0x00000000); |
... | ... | |
306 | 312 |
mGFFATexture.setTexture(bitmapGFFA); |
307 | 313 |
|
308 | 314 |
///// create Logo /////////////////// |
309 |
mLogoEffects.setStretch(bitmapLogo.getWidth(),bitmapLogo.getHeight(),0);
|
|
315 |
mLogoQuad.setStretch(bitmapLogo.getWidth(),bitmapLogo.getHeight(),0);
|
|
310 | 316 |
if( mLogoTexture==null ) mLogoTexture = new DistortedTexture(); |
311 | 317 |
mLogoTexture.setTexture(bitmapLogo); |
312 | 318 |
|
313 | 319 |
///// create CRAWL ////////////////// |
314 |
mCrawlEffects.setStretch(CRAWL_WIDTH,CRAWL_HEIGHT,0); |
|
315 | 320 |
if( mCrawlTexture==null ) mCrawlTexture = new DistortedTexture(); |
316 | 321 |
bitmapText = Bitmap.createBitmap(CRAWL_WIDTH,CRAWL_HEIGHT,Bitmap.Config.ARGB_8888); |
317 | 322 |
bitmapText.eraseColor(0x00000000); |
... | ... | |
326 | 331 |
mCrawlTexture.setTexture(bitmapText); |
327 | 332 |
|
328 | 333 |
///// create Stars /////////////////// |
329 |
mStarEffects[0].setStretch(bitmapStar.getWidth(),bitmapStar.getHeight(),0);
|
|
334 |
mStarQuad.setStretch(bitmapStar.getWidth(),bitmapStar.getHeight(),0);
|
|
330 | 335 |
if( mStarTexture==null ) mStarTexture = new DistortedTexture(); |
331 | 336 |
mStarTexture.setTexture(bitmapStar); |
332 | 337 |
} |
... | ... | |
385 | 390 |
int screenW=mScreen.getWidth(); |
386 | 391 |
int screenH=mScreen.getHeight(); |
387 | 392 |
|
388 |
int logoW = mLogoEffects.getStartchX();
|
|
389 |
int logoH = mLogoEffects.getStartchY();
|
|
393 |
float logoW = mLogoQuad.getStretchX();
|
|
394 |
float logoH = mLogoQuad.getStretchY();
|
|
390 | 395 |
|
391 | 396 |
int initSize= (int)(3.0f*screenW/logoW); |
392 | 397 |
int finaSize= (int)(0.1f*screenW/logoW); |
... | ... | |
402 | 407 |
mLogoEffects.apply( scale ); |
403 | 408 |
mLogoEffects.apply( new MatrixEffectMove(new Static3D(screenW/2,screenH/2,0)) ); |
404 | 409 |
|
405 |
mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
|
|
410 |
mScreen.attach(mLogoTexture, mLogoEffects, mLogoQuad);
|
|
406 | 411 |
} |
407 | 412 |
else if( effectID == scaleEffectID ) |
408 | 413 |
{ |
409 | 414 |
mScreen.detach(mLogoEffects); |
410 | 415 |
mLogoTexture.markForDeletion(); |
411 | 416 |
|
412 |
int crawlW = mCrawlEffects.getStartchX();
|
|
413 |
int crawlH = mCrawlEffects.getStartchY();
|
|
414 |
int screenW= mScreen.getWidth();
|
|
415 |
int backH = mCrawlBackgroundEffects.getStartchY();
|
|
416 |
float scale= (float)screenW/crawlW;
|
|
417 |
float crawlW = mCrawlQuad.getStretchX();
|
|
418 |
float crawlH = mCrawlQuad.getStretchY();
|
|
419 |
float screenW= mScreen.getWidth();
|
|
420 |
float backH = mCrawlBackgroundQuad.getStretchY();
|
|
421 |
float scale = screenW/crawlW;
|
|
417 | 422 |
|
418 | 423 |
mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,0,0)) ); |
419 | 424 |
|
... | ... | |
433 | 438 |
mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale,scale,scale)) ); |
434 | 439 |
mCrawlEffects.apply( move ); |
435 | 440 |
|
436 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
|
|
437 |
mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad);
|
|
441 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects, mCrawlBackgroundQuad);
|
|
442 |
mBackground.attach(mCrawlTexture, mCrawlEffects, mCrawlQuad);
|
|
438 | 443 |
mBackground.glDisable(GLES31.GL_DEPTH_TEST); |
439 | 444 |
mBackground.glDepthMask(false); |
440 | 445 |
} |
Also available in: Unified diff
Move the Effects.setStretch to Meshbase.setStretch