Project

General

Profile

« Previous | Next » 

Revision a4d59c0b

Added by Leszek Koltunski over 5 years ago

Massive: make the coordinate system agree with that of OpenGL (i.e. invert the Y axis).

View differences:

src/main/java/org/distorted/examples/listener/ListenerRenderer.java
66 66

  
67 67
   ListenerRenderer(GLSurfaceView v)
68 68
      {
69
      DistortedEffects.setMax(EffectType.VERTEX,NUM_BUBBLES);
69
      // one more than we have bubbles at any given time because it can sometimes happen that
70
      // the old bubble is not yet removed when we add a new one
71
      DistortedEffects.setMax(EffectType.VERTEX,NUM_BUBBLES+1);
72

  
70 73
      mView = v;
71 74
      mEffects = new DistortedEffects();
72 75
      mEffects.registerForMessages(this);
......
81 84

  
82 85
///////////////////////////////////////////////////////////////////////////////////////////////////
83 86

  
84
   private boolean randomizeNewBubble()
87
   private boolean addNewBubble()
85 88
      {
86 89
      int radius   = (int)(( 0.10f + 0.70f*mRnd.nextFloat())*bmpWidth);           // pop up a bubble of size (radius,height)
87 90
      int height   = (int)((-0.10f + 0.20f*mRnd.nextFloat())*bmpWidth);           // 
88 91
      int pointx   = mRnd.nextInt( (int)(0.8f*bmpWidth ))+ (int)(0.1f*bmpWidth ); // at a random place on the bitmap (but not near the edge)
89 92
      int pointy   = mRnd.nextInt( (int)(0.8f*bmpHeight))+ (int)(0.1f*bmpHeight); // 
90
      int duration = 1000 + mRnd.nextInt(3000);                                   // for anytime from 3 to 4 seconds 
93
      int duration = 1000 + mRnd.nextInt(3000);                                   // for anytime from 1 to 4 seconds
91 94

  
92 95
      Dynamic3D dDistort = new Dynamic3D(duration,1.0f);
93 96
      dDistort.add(new Static3D(0,0,     0));
......
103 106
     {
104 107
     switch(em)
105 108
        {
106
        case EFFECT_REMOVED: randomizeNewBubble();
107
        default            : break;
109
        case EFFECT_REMOVED: if( !addNewBubble() )
110
                               {
111
                               android.util.Log.e("Listener", "failed to add new bubble - this should never happen!");
112
                               }
113
                             break;
108 114
        }
109 115
     }
110 116
   
......
170 176
     mScreen.detachAll();
171 177
     mScreen.attach(mTexture,mEffects,mMesh);
172 178

  
173
     for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble();
179
     for(int i=0; i<NUM_BUBBLES; i++) addNewBubble();
174 180

  
175 181
     VertexEffectDistort.enable();
176 182

  

Also available in: Unified diff