Project

General

Profile

Download (16 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / starwars / StarWarsRenderer.java @ d2aee6cc

1 bc0a685b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19 427ab7bf Leszek Koltunski
20 5068fa06 Leszek Koltunski
package org.distorted.examples.starwars;
21 427ab7bf Leszek Koltunski
22
import java.io.IOException;
23
import java.io.InputStream;
24
import java.util.Random;
25
26
import javax.microedition.khronos.egl.EGLConfig;
27
import javax.microedition.khronos.opengles.GL10;
28
29 5068fa06 Leszek Koltunski
import org.distorted.examples.R;
30
31 8744aa41 Leszek Koltunski
import org.distorted.library.DistortedNode;
32 d218d64e leszek
import org.distorted.library.DistortedScreen;
33 b01acdaf Leszek Koltunski
import org.distorted.library.MeshFlat;
34 c5a28eb8 Leszek Koltunski
import org.distorted.library.EffectNames;
35 7589635e Leszek Koltunski
import org.distorted.library.type.Dynamic1D;
36
import org.distorted.library.type.Dynamic3D;
37
import org.distorted.library.type.Static1D;
38
import org.distorted.library.type.Static3D;
39
import org.distorted.library.type.Static4D;
40 13efa930 Leszek Koltunski
import org.distorted.library.message.EffectListener;
41
import org.distorted.library.message.EffectMessage;
42 5068fa06 Leszek Koltunski
import org.distorted.library.Distorted;
43 f6d884d5 Leszek Koltunski
import org.distorted.library.DistortedTexture;
44 d04a4886 Leszek Koltunski
import org.distorted.library.DistortedEffects;
45 427ab7bf Leszek Koltunski
46
import android.graphics.Bitmap;
47
import android.graphics.BitmapFactory;
48
import android.graphics.Canvas;
49
import android.graphics.Paint;
50
import android.graphics.Typeface;
51 41a81a14 Leszek Koltunski
import android.opengl.GLES30;
52 427ab7bf Leszek Koltunski
import android.opengl.GLSurfaceView;
53
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56
class StarWarsRenderer implements GLSurfaceView.Renderer, EffectListener
57 bc0a685b Leszek Koltunski
  {
58
  private final String[] mGFFAString = 
59 427ab7bf Leszek Koltunski
         
60
            { "A long time ago, in a galaxy far,",
61
              "far away...." };                    // yes, there really was a four-dot ellipsis
62
63 bc0a685b Leszek Koltunski
  private final String[] mCRAWLString = 
64 427ab7bf Leszek Koltunski
      
65
            { "It is a period of civil war.",      // in the original 1977 version, there was no 
66
              "Rebel spaceships, striking",        // 'Episode IV New Hope' subtitle line before
67
              "from a hidden base, have",          // the crawl. Lets keep to the classic.
68
              "won their first victory",
69
              "against the evil Galactic",
70
              "Empire.",
71
              "",
72
              "During the battle, rebel",
73
              "spies managed to steal",
74
              "secret plans to the Empire's",
75
              "ultimate weapon, the",
76
              "DEATH STAR, an armored",
77
              "space station with enough",
78
              "power to destroy an entire",
79
              "planet.",
80
              "",
81
              "Pursued by the Empire's",
82
              "sinister agents, Princess",
83
              "Leia races home aboard her",
84
              "starship, custodian of the",
85
              "stolen plans that can save",
86
              "her people and restore",
87
              "freedom to the galaxy...." };      // four-dot.
88
   
89 76f2d645 leszek
  private final int NUM_STARS = 40;
90 427ab7bf Leszek Koltunski
   
91 bc0a685b Leszek Koltunski
  private final int CRAWL_COLOR = 0xffffe81f;
92
  private final int GFFA_COLOR  = 0xff0000ff;
93
  private final int FONT_HEIGHT      = 40;
94
  private final int VERTICAL_SPACING = 10;
95
  private final String CRAWL_TYPEFACE = "News Gothic";
96 427ab7bf Leszek Koltunski
   
97 bc0a685b Leszek Koltunski
  private final int CRAWL_WIDTH = 500;
98
  private final int CRAWL_HEIGHT= (FONT_HEIGHT+VERTICAL_SPACING)*(mCRAWLString.length+1);
99 427ab7bf Leszek Koltunski
   
100 bc0a685b Leszek Koltunski
  private final int GFFA_WIDTH = 600;
101
  private final int GFFA_HEIGHT= (FONT_HEIGHT+VERTICAL_SPACING)*(mGFFAString.length+1);
102 427ab7bf Leszek Koltunski
   
103 bc0a685b Leszek Koltunski
  private final float CRAWL_ANGLE = -30.0f;
104 427ab7bf Leszek Koltunski
   
105 bc0a685b Leszek Koltunski
  private GLSurfaceView mView;
106 d2aee6cc leszek
  private DistortedTexture mGFFATexture, mLogoTexture, mCrawlTexture, mCrawlBackgroundTexture, mStarTexture;
107
  private DistortedEffects mGFFAEffects, mLogoEffects, mCrawlEffects, mCrawlBackgroundEffects;
108 d04a4886 Leszek Koltunski
  private DistortedEffects[] mStarEffects;
109 d2aee6cc leszek
  private DistortedNode mBackground;
110 d218d64e leszek
  private DistortedScreen mScreen;
111 b01acdaf Leszek Koltunski
  private MeshFlat mQuad;
112 392e16fd Leszek Koltunski
113
  private long gffaID, logoID, crawlID;
114
  private Random mRnd = new Random(0);
115 c4f5a8db Leszek Koltunski
  private int mWidth, mHeight;
116 e8b6aa95 Leszek Koltunski
117 427ab7bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
118
119 e7a4ef16 Leszek Koltunski
  StarWarsRenderer(GLSurfaceView v)
120 bc0a685b Leszek Koltunski
    {
121 76f2d645 leszek
    android.util.Log.d("STAR WARS", "constructor");
122
123 bc0a685b Leszek Koltunski
    mView = v;
124 e8b6aa95 Leszek Koltunski
125 b01acdaf Leszek Koltunski
    mQuad = new MeshFlat(1,1);
126 f6d884d5 Leszek Koltunski
127 d04a4886 Leszek Koltunski
    mGFFAEffects            = new DistortedEffects();
128
    mLogoEffects            = new DistortedEffects();
129
    mCrawlEffects           = new DistortedEffects();
130
    mCrawlBackgroundEffects = new DistortedEffects();
131 f6d884d5 Leszek Koltunski
132 3f5b2cb3 leszek
    if( NUM_STARS>0 )
133
      {
134
      mStarEffects = new DistortedEffects[NUM_STARS];
135
      mStarEffects[0] = new DistortedEffects();
136 f6d884d5 Leszek Koltunski
137 3f5b2cb3 leszek
      for (int i = 1; i < NUM_STARS; i++)
138
        mStarEffects[i] = new DistortedEffects(mStarEffects[0], Distorted.CLONE_VERTEX);
139
      }
140 f6d884d5 Leszek Koltunski
141 d218d64e leszek
    mScreen = new DistortedScreen();
142 392e16fd Leszek Koltunski
    mScreen.setProjection(60.0f, 0.0f, 0.0f);
143 d2aee6cc leszek
    mScreen.enableDepth(false);
144 bc0a685b Leszek Koltunski
    }
145 427ab7bf Leszek Koltunski
146 c4f5a8db Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
147
148
  public void onPause()
149
    {
150 76f2d645 leszek
    android.util.Log.d("STAR WARS", "onPause");
151
152 c4f5a8db Leszek Koltunski
    mWidth = 0;
153
    mHeight= 0;
154
    }
155
156 427ab7bf Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
157
   
158 bc0a685b Leszek Koltunski
  public void onDrawFrame(GL10 glUnused) 
159
    {
160 41a81a14 Leszek Koltunski
    GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
161 fe59d375 Leszek Koltunski
    mScreen.render(System.currentTimeMillis());
162 bc0a685b Leszek Koltunski
    }
163 427ab7bf Leszek Koltunski
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165
    
166 bc0a685b Leszek Koltunski
  public void onSurfaceChanged(GL10 glUnused, int width, int height) 
167 b4cc083b Leszek Koltunski
    {
168 76f2d645 leszek
    android.util.Log.d("STAR WARS", "surfaceChanged");
169
170
171 c4f5a8db Leszek Koltunski
    if( mWidth!=width || mHeight!=height )  // after onPause() we get 2 calls here
172
      {
173
      mWidth = width;
174
      mHeight= height;
175 b4cc083b Leszek Koltunski
176 392e16fd Leszek Koltunski
      mGFFAEffects.abortAllEffects();
177
      mLogoEffects.abortAllEffects();
178
      mCrawlEffects.abortAllEffects();
179
      mCrawlBackgroundEffects.abortAllEffects();
180 b4cc083b Leszek Koltunski
181 d04a4886 Leszek Koltunski
      for(int i=0; i<NUM_STARS; i++) mStarEffects[i].abortAllEffects();
182 b4cc083b Leszek Koltunski
183 fe59d375 Leszek Koltunski
      mScreen.detachAll();
184 d2aee6cc leszek
      setupScreen(width,height);
185 392e16fd Leszek Koltunski
      mScreen.resize(width, height);
186 c4f5a8db Leszek Koltunski
      }
187 bc0a685b Leszek Koltunski
    }
188 427ab7bf Leszek Koltunski
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190
    
191 bc0a685b Leszek Koltunski
  public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
192
    {
193 76f2d645 leszek
    android.util.Log.d("STAR WARS", "surfaceCreated");
194
195 41a81a14 Leszek Koltunski
    GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
196 e7a4ef16 Leszek Koltunski
197 bc0a685b Leszek Koltunski
    setupBitmaps();
198 b4cc083b Leszek Koltunski
199 bc0a685b Leszek Koltunski
    try
200
      {
201 76f9798b Leszek Koltunski
      Distorted.onCreate(mView.getContext());
202 bc0a685b Leszek Koltunski
      }
203
    catch(Exception ex)
204
      {
205
      android.util.Log.e("Star Wars", ex.getMessage() );
206 427ab7bf Leszek Koltunski
      }
207 bc0a685b Leszek Koltunski
    }
208 427ab7bf Leszek Koltunski
    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210
211 bc0a685b Leszek Koltunski
  private void setupScreen(int w, int h)
212
    {
213 7451c98a Leszek Koltunski
    mCrawlBackgroundTexture = new DistortedTexture(w,(int)(Math.sqrt(3.0)*h));
214 427ab7bf Leszek Koltunski
       
215 bc0a685b Leszek Koltunski
    int randomA, randomX, randomY, randomTime;
216
    float randomS, randomAlpha1, randomAlpha2;
217 427ab7bf Leszek Koltunski
       
218 7589635e Leszek Koltunski
    Static3D center = new Static3D(0,0,0);
219
    Static3D axis   = new Static3D(0,0,1);
220 9ff0c8c3 Leszek Koltunski
    Static1D alphaNoise = new Static1D(0.4f);
221
222 bc0a685b Leszek Koltunski
    for(int i=0; i<NUM_STARS; i++)
223
      {
224
      randomX = mRnd.nextInt(w);
225
      randomY = mRnd.nextInt(h);
226 f6d884d5 Leszek Koltunski
      randomS = 0.2f+ 0.8f*mRnd.nextFloat();
227 bc0a685b Leszek Koltunski
      randomA = (int)(180*mRnd.nextFloat());
228
      randomAlpha1 = 0.2f + 0.8f*mRnd.nextFloat();
229
      randomAlpha2 = 0.8f + 0.2f*mRnd.nextFloat();
230
      randomTime = 500+mRnd.nextInt(2000);
231 427ab7bf Leszek Koltunski
      
232 d04a4886 Leszek Koltunski
      mStarEffects[i].move( new Static3D(randomX,randomY,0) );
233
      mStarEffects[i].scale(randomS);
234
      mStarEffects[i].rotate( new Static1D(randomA), axis, center );
235 427ab7bf Leszek Koltunski
      
236 f988589e Leszek Koltunski
      Dynamic1D di = new Dynamic1D(randomTime,0.0f);
237 9ff0c8c3 Leszek Koltunski
      di.setNoise(alphaNoise);
238 7589635e Leszek Koltunski
      di.add(new Static1D(randomAlpha1));
239
      di.add(new Static1D(randomAlpha2));
240 427ab7bf Leszek Koltunski
      
241 d04a4886 Leszek Koltunski
      mStarEffects[i].alpha(di);
242 427ab7bf Leszek Koltunski
      
243 d2aee6cc leszek
      mScreen.attach(mStarTexture, mStarEffects[i], mQuad);
244 427ab7bf Leszek Koltunski
      }
245 bc0a685b Leszek Koltunski
      
246 f6d884d5 Leszek Koltunski
    float scale = (0.5f*w/mGFFATexture.getWidth());
247 bc0a685b Leszek Koltunski
    
248 f988589e Leszek Koltunski
    Dynamic1D di = new Dynamic1D(6000,0.5f);
249 7589635e Leszek Koltunski
    di.add(new Static1D(1.0f));
250
    di.add(new Static1D(1.0f));
251
    di.add(new Static1D(0.0f));
252 bc0a685b Leszek Koltunski
    
253 392e16fd Leszek Koltunski
    mGFFAEffects.move( new Static3D(w/5,h/3,0) );
254
    mGFFAEffects.scale( new Static3D(scale,scale,scale) );
255
    mGFFAEffects.alpha(di);
256 bc0a685b Leszek Koltunski
      
257 d2aee6cc leszek
    mScreen.attach(mGFFATexture, mGFFAEffects, mQuad);
258 392e16fd Leszek Koltunski
    mGFFAEffects.registerForMessages(this);
259 bc0a685b Leszek Koltunski
    }
260 427ab7bf Leszek Koltunski
    
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262
263 bc0a685b Leszek Koltunski
  private void setupBitmaps()
264
    {
265
    InputStream is1 = mView.getContext().getResources().openRawResource(R.raw.starwars);
266
    InputStream is2 = mView.getContext().getResources().openRawResource(R.raw.star);
267 427ab7bf Leszek Koltunski
    
268 bc0a685b Leszek Koltunski
    Bitmap bitmapStar, bitmapGFFA, bitmapLogo, bitmapText;
269
      
270
    try 
271
      {
272
      bitmapLogo = BitmapFactory.decodeStream(is1);
273
      bitmapStar = BitmapFactory.decodeStream(is2);
274
      } 
275
    finally 
276
      {
277 427ab7bf Leszek Koltunski
      try 
278
        {
279 bc0a685b Leszek Koltunski
        is1.close();
280
        is2.close();
281 427ab7bf Leszek Koltunski
        } 
282 bc0a685b Leszek Koltunski
      catch(IOException e) { }
283
      } 
284 427ab7bf Leszek Koltunski
      
285 bc0a685b Leszek Koltunski
    Paint paint = new Paint();
286
    paint.setAntiAlias(true);
287
    paint.setTextAlign(Paint.Align.LEFT);
288
    paint.setTextSize(FONT_HEIGHT);
289
    paint.setColor(GFFA_COLOR);
290 427ab7bf Leszek Koltunski
      
291 bc0a685b Leszek Koltunski
    Typeface tf = Typeface.create(CRAWL_TYPEFACE, Typeface.BOLD);
292
    paint.setTypeface(tf);     
293 427ab7bf Leszek Koltunski
 
294 bc0a685b Leszek Koltunski
    ///// create GFFA ///////////////////
295 7451c98a Leszek Koltunski
    mGFFATexture  = new DistortedTexture(GFFA_WIDTH,GFFA_HEIGHT);
296 bc0a685b Leszek Koltunski
    bitmapGFFA = Bitmap.createBitmap(GFFA_WIDTH,GFFA_HEIGHT,Bitmap.Config.ARGB_8888);
297
    bitmapGFFA.eraseColor(0x00000000);
298
    Canvas gffaCanvas = new Canvas(bitmapGFFA);
299 427ab7bf Leszek Koltunski
      
300 bc0a685b Leszek Koltunski
    for(int i=0; i<mGFFAString.length; i++)
301
      {
302
      gffaCanvas.drawText(mGFFAString[i], 0, (i+1)*(FONT_HEIGHT+VERTICAL_SPACING), paint);  
303
      }
304 427ab7bf Leszek Koltunski
  
305 f6d884d5 Leszek Koltunski
    mGFFATexture.setTexture(bitmapGFFA);
306 427ab7bf Leszek Koltunski
      
307 bc0a685b Leszek Koltunski
    ///// create Logo ///////////////////
308 7451c98a Leszek Koltunski
    mLogoTexture  = new DistortedTexture(bitmapLogo.getWidth(),bitmapLogo.getHeight());
309 f6d884d5 Leszek Koltunski
    mLogoTexture.setTexture(bitmapLogo);
310 e8b6aa95 Leszek Koltunski
311 bc0a685b Leszek Koltunski
    ///// create CRAWL //////////////////
312 7451c98a Leszek Koltunski
    mCrawlTexture = new DistortedTexture(CRAWL_WIDTH,CRAWL_HEIGHT);
313 bc0a685b Leszek Koltunski
    bitmapText = Bitmap.createBitmap(CRAWL_WIDTH,CRAWL_HEIGHT,Bitmap.Config.ARGB_8888);
314
    bitmapText.eraseColor(0x00000000);
315
    Canvas textCanvas = new Canvas(bitmapText);
316
    paint.setColor(CRAWL_COLOR);
317 427ab7bf Leszek Koltunski
  
318 bc0a685b Leszek Koltunski
    for(int i=0; i<mCRAWLString.length; i++)
319
      {
320
      displayJustified(mCRAWLString[i], 0, (i+1)*(FONT_HEIGHT+VERTICAL_SPACING), CRAWL_WIDTH, textCanvas, paint);  
321
      }
322 427ab7bf Leszek Koltunski
      
323 f6d884d5 Leszek Koltunski
    mCrawlTexture.setTexture(bitmapText);
324 427ab7bf Leszek Koltunski
      
325 bc0a685b Leszek Koltunski
    ///// create Stars ///////////////////
326 7451c98a Leszek Koltunski
    mStarTexture = new DistortedTexture(bitmapStar.getWidth(),bitmapStar.getHeight());
327 f6d884d5 Leszek Koltunski
    mStarTexture.setTexture(bitmapStar);
328 e8b6aa95 Leszek Koltunski
329 392e16fd Leszek Koltunski
    gffaID = mGFFAEffects.getID();
330
    logoID = mLogoEffects.getID();
331
    crawlID= mCrawlEffects.getID();
332 bc0a685b Leszek Koltunski
    }
333 427ab7bf Leszek Koltunski
 
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335
336 bc0a685b Leszek Koltunski
  private void displayJustified(String str, int x, int y, int length, Canvas c, Paint paint)
337
    { 
338
    int len       = str.length();
339
    int numspaces = retNumSpaces(str);
340 427ab7bf Leszek Koltunski
    
341 bc0a685b Leszek Koltunski
    if( len>0 && str.charAt(len-1) == ' ' ) numspaces--;
342 427ab7bf Leszek Koltunski
343 bc0a685b Leszek Koltunski
    float left=x,w = (numspaces>0 ? (length-paint.measureText(str))/numspaces : 0);
344
    String tmp;
345
    int begin,end=0;
346 427ab7bf Leszek Koltunski
347 bc0a685b Leszek Koltunski
    while( end<len )
348
      {
349
      begin=end;
350
      end = str.indexOf(' ', begin)+1;
351
      if( end<=0 ) end = len;
352 427ab7bf Leszek Koltunski
353 bc0a685b Leszek Koltunski
      tmp = str.substring(begin,end);
354
      c.drawText( tmp, left, y, paint);
355
      left+= (paint.measureText(tmp)+w);
356
      }  
357
    }
358 427ab7bf Leszek Koltunski
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360
   
361 bc0a685b Leszek Koltunski
  private int retNumSpaces(String str)
362
    {
363
    int begin=0, ret=0;
364 427ab7bf Leszek Koltunski
365 bc0a685b Leszek Koltunski
    while( true )
366
      {
367
      begin = str.indexOf(' ', begin) +1;
368 427ab7bf Leszek Koltunski
369 bc0a685b Leszek Koltunski
      if( begin>0 ) ret++;
370
      else break;
371 427ab7bf Leszek Koltunski
      }
372 bc0a685b Leszek Koltunski
373
    return ret;
374
    }
375 427ab7bf Leszek Koltunski
    
376
///////////////////////////////////////////////////////////////////////////////////////////////////
377 c5a28eb8 Leszek Koltunski
// the library sending messages to us. This is running on a library 'MessageSender' thread.
378 427ab7bf Leszek Koltunski
379 9d12dd4a Leszek Koltunski
  public void effectMessage(final EffectMessage em, final long effectID, final EffectNames effectName, final long objectID)
380 bc0a685b Leszek Koltunski
    {
381
    if( em==EffectMessage.EFFECT_FINISHED )
382 427ab7bf Leszek Koltunski
      {
383 c5a28eb8 Leszek Koltunski
      if( objectID == gffaID )
384 427ab7bf Leszek Koltunski
        {
385 d2aee6cc leszek
        mScreen.detach(mGFFAEffects);
386 392e16fd Leszek Koltunski
        mGFFAEffects.abortAllEffects();
387 3c8b1903 Leszek Koltunski
        mGFFATexture.markForDeletion();
388 611ea379 Leszek Koltunski
389 d2aee6cc leszek
        int screenW=mScreen.getWidth();
390
        int screenH=mScreen.getHeight();
391 427ab7bf Leszek Koltunski
        
392 f6d884d5 Leszek Koltunski
        int logoW = mLogoTexture.getWidth();
393
        int logoH = mLogoTexture.getHeight();
394 427ab7bf Leszek Koltunski
      
395 bc0a685b Leszek Koltunski
        int initSize= (int)(3.0f*screenW/logoW);
396
        int finaSize= (int)(0.1f*screenW/logoW);
397 427ab7bf Leszek Koltunski
      
398 f988589e Leszek Koltunski
        Dynamic3D di = new Dynamic3D(10000,0.5f);
399 7589635e Leszek Koltunski
        di.add(new Static3D(initSize,initSize,1));
400
        di.add(new Static3D(finaSize,finaSize,1));
401 f988589e Leszek Koltunski
402 392e16fd Leszek Koltunski
        mLogoEffects.move( new Static3D(screenW/2,screenH/2,0) );
403
        mLogoEffects.scale(di);
404
        mLogoEffects.move( new Static3D(-logoW/2,-logoH/2,0) );
405 427ab7bf Leszek Koltunski
      
406 d2aee6cc leszek
        mScreen.attach(mLogoTexture, mLogoEffects,mQuad);
407 392e16fd Leszek Koltunski
        mLogoEffects.registerForMessages(this);
408 bc0a685b Leszek Koltunski
        }
409 c5a28eb8 Leszek Koltunski
      else if( objectID==logoID )
410 bc0a685b Leszek Koltunski
        {
411 d2aee6cc leszek
        mScreen.detach(mLogoEffects);
412 392e16fd Leszek Koltunski
        mLogoEffects.abortAllEffects();
413 3c8b1903 Leszek Koltunski
        mLogoTexture.markForDeletion();
414 427ab7bf Leszek Koltunski
        
415 f6d884d5 Leszek Koltunski
        int crawlW = mCrawlTexture.getWidth();
416
        int crawlH = mCrawlTexture.getHeight();
417 d2aee6cc leszek
        int screenW= mScreen.getWidth();
418
        int screenH= mScreen.getHeight();
419 f6d884d5 Leszek Koltunski
        int backH  = mCrawlBackgroundTexture.getHeight();
420 bc0a685b Leszek Koltunski
        float scale= (float)screenW/crawlW;
421
      
422 f988589e Leszek Koltunski
        Dynamic3D di = new Dynamic3D(60000,0.5f);
423 7589635e Leszek Koltunski
        di.add(new Static3D(screenW/2,+backH       , 0));
424
        di.add(new Static3D(screenW/2,-scale*crawlH, 0));
425 427ab7bf Leszek Koltunski
        
426 392e16fd Leszek Koltunski
        mCrawlBackgroundEffects.move( new Static3D(0,screenH-backH,0) );
427
        mCrawlBackgroundEffects.rotate( new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,backH,0) );
428 427ab7bf Leszek Koltunski
        
429 59759251 Leszek Koltunski
        final int transpDist = 5;
430
        Static4D region = new Static4D(screenW/2,(1-transpDist)*backH,transpDist*backH,transpDist*backH);
431 392e16fd Leszek Koltunski
        mCrawlBackgroundEffects.alpha(new Static1D(1-transpDist/2), region, true);
432 427ab7bf Leszek Koltunski
        
433 392e16fd Leszek Koltunski
        mCrawlEffects.move(di);
434
        mCrawlEffects.scale( new Static3D(scale,scale,scale) );
435
        mCrawlEffects.move( new Static3D(-crawlW/2,0,0) );
436 427ab7bf Leszek Koltunski
        
437 d2aee6cc leszek
        mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad);
438 392e16fd Leszek Koltunski
        mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad);
439
        mCrawlEffects.registerForMessages(this);
440 bc0a685b Leszek Koltunski
        }
441 c5a28eb8 Leszek Koltunski
      else if( objectID==crawlID )
442 bc0a685b Leszek Koltunski
        {
443 d2aee6cc leszek
        mScreen.detach(mBackground);
444 392e16fd Leszek Koltunski
        mBackground.detach(mCrawlEffects);
445
        mCrawlEffects.abortAllEffects();
446 3c8b1903 Leszek Koltunski
        mCrawlTexture.markForDeletion();
447 392e16fd Leszek Koltunski
        mCrawlBackgroundEffects.abortAllEffects();
448 3c8b1903 Leszek Koltunski
        mCrawlBackgroundTexture.markForDeletion();
449 427ab7bf Leszek Koltunski
        }
450
      }
451 bc0a685b Leszek Koltunski
    }
452
  }