Revision 7589635e
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import org.distorted.examples.R; |
30 | 30 |
|
31 |
import org.distorted.library.type.Interpolator1D;
|
|
32 |
import org.distorted.library.type.Interpolator3D;
|
|
31 |
import org.distorted.library.type.Dynamic1D;
|
|
32 |
import org.distorted.library.type.Dynamic3D;
|
|
33 | 33 |
import org.distorted.library.DistortedNode; |
34 |
import org.distorted.library.type.Float1D;
|
|
35 |
import org.distorted.library.type.Float2D;
|
|
36 |
import org.distorted.library.type.Float3D;
|
|
37 |
import org.distorted.library.type.Float4D;
|
|
34 |
import org.distorted.library.type.Static1D;
|
|
35 |
import org.distorted.library.type.Static2D;
|
|
36 |
import org.distorted.library.type.Static3D;
|
|
37 |
import org.distorted.library.type.Static4D;
|
|
38 | 38 |
import org.distorted.library.message.EffectListener; |
39 | 39 |
import org.distorted.library.message.EffectMessage; |
40 | 40 |
import org.distorted.library.Distorted; |
... | ... | |
162 | 162 |
int randomA, randomX, randomY, randomTime; |
163 | 163 |
float randomS, randomAlpha1, randomAlpha2; |
164 | 164 |
|
165 |
Float3D rot = new Float3D(0,0,0); |
|
166 |
|
|
165 |
Static3D center = new Static3D(0,0,0); |
|
166 |
Static3D axis = new Static3D(0,0,1); |
|
167 |
|
|
167 | 168 |
for(int i=0; i<NUM_STARS; i++) |
168 | 169 |
{ |
169 | 170 |
randomX = mRnd.nextInt(w); |
... | ... | |
174 | 175 |
randomAlpha2 = 0.8f + 0.2f*mRnd.nextFloat(); |
175 | 176 |
randomTime = 500+mRnd.nextInt(2000); |
176 | 177 |
|
177 |
mStars[i].move( randomX,randomY,0);
|
|
178 |
mStars[i].scale(randomS);
|
|
179 |
mStars[i].rotate( rot, randomA);
|
|
178 |
mStars[i].move( new Static3D(randomX,randomY,0) );
|
|
179 |
mStars[i].scale( new Static3D(randomS,randomS,randomS) );
|
|
180 |
mStars[i].rotate( center, new Static1D(randomA), axis);
|
|
180 | 181 |
|
181 |
Interpolator1D di = new Interpolator1D();
|
|
182 |
Dynamic1D di = new Dynamic1D();
|
|
182 | 183 |
di.setDuration(randomTime); |
183 | 184 |
di.setCount(0.0f); |
184 | 185 |
di.setNoise(0.3f); |
185 |
di.add(new Float1D(randomAlpha1));
|
|
186 |
di.add(new Float1D(randomAlpha2));
|
|
186 |
di.add(new Static1D(randomAlpha1));
|
|
187 |
di.add(new Static1D(randomAlpha2));
|
|
187 | 188 |
|
188 |
mStars[i].alpha(di, null, new Float2D(0,0));
|
|
189 |
mStars[i].alpha(di, null, new Static2D(0,0));
|
|
189 | 190 |
|
190 | 191 |
mRoot.attach(mStars[i]); |
191 | 192 |
} |
192 | 193 |
|
193 | 194 |
float scale = (0.5f*w/mGFFA.getWidth()); |
194 | 195 |
|
195 |
Interpolator1D di = new Interpolator1D();
|
|
196 |
Dynamic1D di = new Dynamic1D();
|
|
196 | 197 |
di.setDuration(6000); |
197 | 198 |
di.setCount(0.5f); |
198 |
di.add(new Float1D(1.0f));
|
|
199 |
di.add(new Float1D(1.0f));
|
|
200 |
di.add(new Float1D(0.0f));
|
|
199 |
di.add(new Static1D(1.0f));
|
|
200 |
di.add(new Static1D(1.0f));
|
|
201 |
di.add(new Static1D(0.0f));
|
|
201 | 202 |
|
202 |
mGFFA.move( w/5, h/3, 0);
|
|
203 |
mGFFA.scale(scale);
|
|
204 |
mGFFA.alpha(di, null, new Float2D(0,0));
|
|
203 |
mGFFA.move( new Static3D(w/5,h/3,0) );
|
|
204 |
mGFFA.scale( new Static3D(scale,scale,scale) );
|
|
205 |
mGFFA.alpha(di, null, new Static2D(0,0));
|
|
205 | 206 |
|
206 | 207 |
mRoot.attach(mGFFA); |
207 | 208 |
mGFFA.addEventListener(this); |
... | ... | |
348 | 349 |
int initSize= (int)(3.0f*screenW/logoW); |
349 | 350 |
int finaSize= (int)(0.1f*screenW/logoW); |
350 | 351 |
|
351 |
Interpolator3D di = new Interpolator3D();
|
|
352 |
Dynamic3D di = new Dynamic3D();
|
|
352 | 353 |
|
353 |
di.add(new Float3D(initSize,initSize,1));
|
|
354 |
di.add(new Float3D(finaSize,finaSize,1));
|
|
354 |
di.add(new Static3D(initSize,initSize,1));
|
|
355 |
di.add(new Static3D(finaSize,finaSize,1));
|
|
355 | 356 |
di.setCount(0.5f); |
356 | 357 |
di.setDuration(10000); |
357 | 358 |
|
358 |
mLogo.move( screenW/2, screenH/2, 0);
|
|
359 |
mLogo.move( new Static3D(screenW/2,screenH/2,0) );
|
|
359 | 360 |
mLogo.scale(di); |
360 |
mLogo.move( -logoW/2, -logoH/2, 0);
|
|
361 |
mLogo.move( new Static3D(-logoW/2,-logoH/2,0) );
|
|
361 | 362 |
|
362 | 363 |
mRoot.attach(mLogo); |
363 | 364 |
mLogo.addEventListener(this); |
... | ... | |
374 | 375 |
int backH = mCrawlBackground.getHeight(); |
375 | 376 |
float scale= (float)screenW/crawlW; |
376 | 377 |
|
377 |
Interpolator3D di = new Interpolator3D();
|
|
378 |
Dynamic3D di = new Dynamic3D();
|
|
378 | 379 |
di.setCount(0.5f); |
379 | 380 |
di.setDuration(60000); |
380 |
di.add(new Float3D(screenW/2,+backH , 0));
|
|
381 |
di.add(new Float3D(screenW/2,-scale*crawlH, 0));
|
|
381 |
di.add(new Static3D(screenW/2,+backH , 0));
|
|
382 |
di.add(new Static3D(screenW/2,-scale*crawlH, 0));
|
|
382 | 383 |
|
383 |
mCrawlBackground.move(0,screenH-backH,0);
|
|
384 |
mCrawlBackground.rotate(new Float3D(screenW/2,backH,0), CRAWL_ANGLE, 1.0f, 0.0f, 0.0f);
|
|
384 |
mCrawlBackground.move( new Static3D(0,screenH-backH,0) );
|
|
385 |
mCrawlBackground.rotate(new Static3D(screenW/2,backH,0), new Static1D(CRAWL_ANGLE), new Static3D(1,0,0) );
|
|
385 | 386 |
|
386 | 387 |
final int transpDistance = 5; |
387 |
mCrawlBackground.smooth_alpha((1-transpDistance/2)*1.0f, new Float4D(0,0,transpDistance*backH,transpDistance*backH), new Float2D(screenW/2,(1-transpDistance)*backH));
|
|
388 |
mCrawlBackground.smooth_alpha((1-transpDistance/2)*1.0f, new Static4D(0,0,transpDistance*backH,transpDistance*backH), new Static2D(screenW/2,(1-transpDistance)*backH));
|
|
388 | 389 |
|
389 | 390 |
mCrawl.move(di); |
390 |
mCrawl.scale(scale);
|
|
391 |
mCrawl.move(-crawlW/2,0,0);
|
|
391 |
mCrawl.scale( new Static3D(scale,scale,scale) );
|
|
392 |
mCrawl.move( new Static3D(-crawlW/2,0,0) );
|
|
392 | 393 |
|
393 | 394 |
mBackground = mRoot.attach(mCrawlBackground); |
394 | 395 |
mBackground.attach(mCrawl); |
Also available in: Unified diff
Major push towards simplifying DistortedObject's public API.
All MATRIX effects are using the new API - the 'DataND' marker interfaces.