Project

General

Profile

« Previous | Next » 

Revision f6d884d5

Added by Leszek Koltunski over 7 years ago

Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)

View differences:

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

  
31 31
import org.distorted.library.Distorted;
32 32
import org.distorted.library.GridFlat;
33
import org.distorted.library.DistortedObject;
33
import org.distorted.library.DistortedTexture;
34
import org.distorted.library.DistortedEffectQueues;
34 35
import org.distorted.library.EffectNames;
35 36
import org.distorted.library.EffectTypes;
36 37
import org.distorted.library.type.Dynamic3D;
......
51 52
   private final int NUM_BUBBLES = 12;
52 53

  
53 54
   private GLSurfaceView mView;
54
   private DistortedObject mWater;
55
   private DistortedTexture mTexture;
56
   private DistortedEffectQueues mQueues;
55 57
   private GridFlat mGrid;
56 58
   private int bmpHeight, bmpWidth;
57 59
   private Random mRnd;
......
62 64
      {
63 65
      Distorted.setMaxVertex(NUM_BUBBLES);   
64 66
      mView = v;
67
      mQueues = new DistortedEffectQueues();
68
      mQueues.addEventListener(this);
69
      mRnd = new Random(0);
65 70
      }
66 71

  
67 72
///////////////////////////////////////////////////////////////////////////////////////////////////
......
78 83
      dDistort.add(new Static3D(0,0,     0));
79 84
      dDistort.add(new Static3D(0,0,height));
80 85

  
81
      return mWater.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
86
      return mQueues.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
82 87
      }
83 88
   
84 89
///////////////////////////////////////////////////////////////////////////////////////////////////
......
98 103
    public void onDrawFrame(GL10 glUnused) 
99 104
      {
100 105
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
101
      mWater.draw(System.currentTimeMillis(), mGrid);
106
      mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
102 107
      }
103 108

  
104 109
///////////////////////////////////////////////////////////////////////////////////////////////////
105 110
    
106 111
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
107 112
      { 
108
      mWater.abortEffects(EffectTypes.MATRIX);
113
      mQueues.abortEffects(EffectTypes.MATRIX);
109 114
         
110 115
      if( (float)bmpHeight/bmpWidth > (float)height/width )
111 116
        {
112 117
        int w = (height*bmpWidth)/bmpHeight;
113 118
        float factor = (float)height/bmpHeight;
114 119

  
115
        mWater.move( new Static3D((width-w)/2,0,0) );
116
        mWater.scale(factor);
120
        mQueues.move( new Static3D((width-w)/2,0,0) );
121
        mQueues.scale(factor);
117 122
        }
118 123
      else
119 124
        {
120 125
        int h = (width*bmpHeight)/bmpWidth;
121 126
        float factor = (float)width/bmpWidth;
122 127

  
123
        mWater.move( new Static3D(0,(height-h)/2,0) );
124
        mWater.scale(factor);
128
        mQueues.move( new Static3D(0,(height-h)/2,0) );
129
        mQueues.scale(factor);
125 130
        }
126 131
      
127 132
      Distorted.onSurfaceChanged(width, height); 
......
148 153
          } 
149 154
        catch(IOException e) { }
150 155
        }  
151
      
152
      mRnd = new Random(0);
153
      
156

  
154 157
      bmpHeight = bitmap.getHeight();
155 158
      bmpWidth  = bitmap.getWidth();
156 159

  
157
      mGrid  = new GridFlat(50,50*bmpHeight/bmpWidth);
158
      mWater = new DistortedObject(bmpWidth,bmpHeight,1);
159
      mWater.setTexture(bitmap);
160
      mWater.addEventListener(this);
161
      
160
      mGrid    = new GridFlat(50,50*bmpHeight/bmpWidth);
161
      mTexture = new DistortedTexture(bmpWidth,bmpHeight,0);
162
      mTexture.setTexture(bitmap);
163

  
162 164
      for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble();
163 165
      
164 166
      try

Also available in: Unified diff