Revision d2aee6cc
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
103 | 103 |
private final float CRAWL_ANGLE = -30.0f; |
104 | 104 |
|
105 | 105 |
private GLSurfaceView mView; |
106 |
private DistortedTexture mScreenTexture, mGFFATexture, mLogoTexture, mCrawlTexture, mCrawlBackgroundTexture, mStarTexture;
|
|
107 |
private DistortedEffects mScreenEffects, mGFFAEffects, mLogoEffects, mCrawlEffects, mCrawlBackgroundEffects;
|
|
106 |
private DistortedTexture mGFFATexture, mLogoTexture, mCrawlTexture, mCrawlBackgroundTexture, mStarTexture; |
|
107 |
private DistortedEffects mGFFAEffects, mLogoEffects, mCrawlEffects, mCrawlBackgroundEffects; |
|
108 | 108 |
private DistortedEffects[] mStarEffects; |
109 |
private DistortedNode mRoot, mBackground;
|
|
109 |
private DistortedNode mBackground; |
|
110 | 110 |
private DistortedScreen mScreen; |
111 | 111 |
private MeshFlat mQuad; |
112 | 112 |
|
... | ... | |
124 | 124 |
|
125 | 125 |
mQuad = new MeshFlat(1,1); |
126 | 126 |
|
127 |
mScreenEffects = new DistortedEffects(); |
|
128 | 127 |
mGFFAEffects = new DistortedEffects(); |
129 | 128 |
mLogoEffects = new DistortedEffects(); |
130 | 129 |
mCrawlEffects = new DistortedEffects(); |
... | ... | |
141 | 140 |
|
142 | 141 |
mScreen = new DistortedScreen(); |
143 | 142 |
mScreen.setProjection(60.0f, 0.0f, 0.0f); |
143 |
mScreen.enableDepth(false); |
|
144 | 144 |
} |
145 | 145 |
|
146 | 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
173 | 173 |
mWidth = width; |
174 | 174 |
mHeight= height; |
175 | 175 |
|
176 |
mScreenEffects.abortAllEffects(); |
|
177 | 176 |
mGFFAEffects.abortAllEffects(); |
178 | 177 |
mLogoEffects.abortAllEffects(); |
179 | 178 |
mCrawlEffects.abortAllEffects(); |
... | ... | |
181 | 180 |
|
182 | 181 |
for(int i=0; i<NUM_STARS; i++) mStarEffects[i].abortAllEffects(); |
183 | 182 |
|
184 |
setupScreen(width,height); |
|
185 |
|
|
186 | 183 |
mScreen.detachAll(); |
187 |
mScreen.attach(mRoot);
|
|
184 |
setupScreen(width,height);
|
|
188 | 185 |
mScreen.resize(width, height); |
189 | 186 |
} |
190 | 187 |
} |
... | ... | |
213 | 210 |
|
214 | 211 |
private void setupScreen(int w, int h) |
215 | 212 |
{ |
216 |
mScreenTexture = new DistortedTexture(w,h); |
|
217 |
mRoot = new DistortedNode(mScreenTexture, mScreenEffects,mQuad); |
|
218 |
|
|
219 | 213 |
mCrawlBackgroundTexture = new DistortedTexture(w,(int)(Math.sqrt(3.0)*h)); |
220 | 214 |
|
221 | 215 |
int randomA, randomX, randomY, randomTime; |
... | ... | |
246 | 240 |
|
247 | 241 |
mStarEffects[i].alpha(di); |
248 | 242 |
|
249 |
mRoot.attach(mStarTexture, mStarEffects[i], mQuad);
|
|
243 |
mScreen.attach(mStarTexture, mStarEffects[i], mQuad);
|
|
250 | 244 |
} |
251 | 245 |
|
252 | 246 |
float scale = (0.5f*w/mGFFATexture.getWidth()); |
... | ... | |
260 | 254 |
mGFFAEffects.scale( new Static3D(scale,scale,scale) ); |
261 | 255 |
mGFFAEffects.alpha(di); |
262 | 256 |
|
263 |
mRoot.attach(mGFFATexture, mGFFAEffects, mQuad);
|
|
257 |
mScreen.attach(mGFFATexture, mGFFAEffects, mQuad);
|
|
264 | 258 |
mGFFAEffects.registerForMessages(this); |
265 | 259 |
} |
266 | 260 |
|
... | ... | |
388 | 382 |
{ |
389 | 383 |
if( objectID == gffaID ) |
390 | 384 |
{ |
391 |
mRoot.detach(mGFFAEffects);
|
|
385 |
mScreen.detach(mGFFAEffects);
|
|
392 | 386 |
mGFFAEffects.abortAllEffects(); |
393 | 387 |
mGFFATexture.markForDeletion(); |
394 | 388 |
|
395 |
int screenW=mScreenTexture.getWidth();
|
|
396 |
int screenH=mScreenTexture.getHeight();
|
|
389 |
int screenW=mScreen.getWidth(); |
|
390 |
int screenH=mScreen.getHeight(); |
|
397 | 391 |
|
398 | 392 |
int logoW = mLogoTexture.getWidth(); |
399 | 393 |
int logoH = mLogoTexture.getHeight(); |
... | ... | |
409 | 403 |
mLogoEffects.scale(di); |
410 | 404 |
mLogoEffects.move( new Static3D(-logoW/2,-logoH/2,0) ); |
411 | 405 |
|
412 |
mRoot.attach(mLogoTexture, mLogoEffects,mQuad);
|
|
406 |
mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
|
|
413 | 407 |
mLogoEffects.registerForMessages(this); |
414 | 408 |
} |
415 | 409 |
else if( objectID==logoID ) |
416 | 410 |
{ |
417 |
mRoot.detach(mLogoEffects);
|
|
411 |
mScreen.detach(mLogoEffects);
|
|
418 | 412 |
mLogoEffects.abortAllEffects(); |
419 | 413 |
mLogoTexture.markForDeletion(); |
420 | 414 |
|
421 | 415 |
int crawlW = mCrawlTexture.getWidth(); |
422 | 416 |
int crawlH = mCrawlTexture.getHeight(); |
423 |
int screenW= mScreenTexture.getWidth();
|
|
424 |
int screenH= mScreenTexture.getHeight();
|
|
417 |
int screenW= mScreen.getWidth(); |
|
418 |
int screenH= mScreen.getHeight(); |
|
425 | 419 |
int backH = mCrawlBackgroundTexture.getHeight(); |
426 | 420 |
float scale= (float)screenW/crawlW; |
427 | 421 |
|
... | ... | |
440 | 434 |
mCrawlEffects.scale( new Static3D(scale,scale,scale) ); |
441 | 435 |
mCrawlEffects.move( new Static3D(-crawlW/2,0,0) ); |
442 | 436 |
|
443 |
mBackground = mRoot.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
|
|
437 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
|
|
444 | 438 |
mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad); |
445 | 439 |
mCrawlEffects.registerForMessages(this); |
446 | 440 |
} |
447 | 441 |
else if( objectID==crawlID ) |
448 | 442 |
{ |
449 |
mRoot.detach(mBackground);
|
|
443 |
mScreen.detach(mBackground);
|
|
450 | 444 |
mBackground.detach(mCrawlEffects); |
451 | 445 |
mCrawlEffects.abortAllEffects(); |
452 | 446 |
mCrawlTexture.markForDeletion(); |
Also available in: Unified diff
1. Make it possible to enable/disable DEPTH test when rendering to a Screen
2. Using this, remove the 'Root' Node from StarWars.