Project

General

Profile

« Previous | Next » 

Revision e8b6aa95

Added by Leszek Koltunski over 7 years ago

Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.

View differences:

src/main/java/org/distorted/examples/listener/ListenerRenderer.java
29 29
import org.distorted.examples.R;
30 30

  
31 31
import org.distorted.library.Distorted;
32
import org.distorted.library.DistortedBitmap;
32
import org.distorted.library.DistortedBitmapGrid;
33
import org.distorted.library.DistortedObject;
33 34
import org.distorted.library.EffectNames;
34 35
import org.distorted.library.EffectTypes;
35 36
import org.distorted.library.type.Dynamic3D;
36
import org.distorted.library.type.Static2D;
37 37
import org.distorted.library.type.Static3D;
38 38
import org.distorted.library.type.Static4D;
39 39
import org.distorted.library.message.EffectListener;
......
51 51
   private final int NUM_BUBBLES = 12;
52 52

  
53 53
   private GLSurfaceView mView;
54
   private DistortedBitmap water;
54
   private DistortedObject mWater;
55
   private DistortedBitmapGrid mGrid;
55 56
   private int bmpHeight, bmpWidth;
56 57
   private Random mRnd;
57 58

  
......
77 78
      dDistort.add(new Static3D(0,0,     0));
78 79
      dDistort.add(new Static3D(0,0,height));
79 80

  
80
      return water.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
81
      return mWater.distort(dDistort, new Static3D(pointx,pointy,0), new Static4D(0,0,radius,radius));
81 82
      }
82 83
   
83 84
///////////////////////////////////////////////////////////////////////////////////////////////////
......
97 98
    public void onDrawFrame(GL10 glUnused) 
98 99
      {
99 100
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
100
      water.draw(System.currentTimeMillis());
101
      mWater.draw(System.currentTimeMillis(), mGrid);
101 102
      }
102 103

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

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

  
122
        water.move( new Static3D(0,(height-h)/2,0) );
123
        water.scale(factor);
123
        mWater.move( new Static3D(0,(height-h)/2,0) );
124
        mWater.scale(factor);
124 125
        }
125 126
      
126 127
      Distorted.onSurfaceChanged(width, height); 
......
152 153
      
153 154
      bmpHeight = bitmap.getHeight();
154 155
      bmpWidth  = bitmap.getWidth();
155
      
156
      water = new DistortedBitmap(bitmap, 50);
157
      water.addEventListener(this);
156

  
157
      mGrid  = new DistortedBitmapGrid(50,50*bmpHeight/bmpWidth);
158
      mWater = new DistortedObject(bmpWidth,bmpHeight,1);
159
      mWater.setTexture(bitmap);
160
      mWater.addEventListener(this);
158 161
      
159 162
      for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble();
160 163
      

Also available in: Unified diff