Project

General

Profile

« Previous | Next » 

Revision a56bc359

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/library/DistortedObject.java
59 59
 * deletion now - actually delete on next render' thing.
60 60
 * We need to be able to quickly retrieve an Object by its ID, thus a HashMap.
61 61
 */
62
public abstract class DistortedObject 
62
public class DistortedObject
63 63
  {
64 64
  private static long mNextID =0;
65 65
  private static HashMap<Long,DistortedObject> mObjects = new HashMap<>();
......
73 73
  private int mSizeX, mSizeY, mSizeZ; // in screen space
74 74
  private int mHalfX, mHalfY, mHalfZ; // halfs of the above
75 75

  
76
  protected DistortedObjectGrid mGrid = null;
77

  
78 76
  private Bitmap[] mBmp= null; //
79 77
  int[] mTextureDataH;         // have to be shared among all the cloned Objects
80 78
  boolean[] mBitmapSet;        //
......
99 97

  
100 98
///////////////////////////////////////////////////////////////////////////////////////////////////
101 99

  
102
  protected abstract DistortedObject deepCopy(int flags);
103

  
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

  
106
  protected void initializeData(int x, int y, int z)
100
  private void initializeData(int x, int y, int z)
107 101
    {
108 102
    mSizeX= x; mHalfX = x/2;
109 103
    mSizeY= y; mHalfY = y/2;
......
190 184
  
191 185
///////////////////////////////////////////////////////////////////////////////////////////////////
192 186
   
193
  void drawPriv(long currTime, DistortedFramebuffer df)
187
  void drawPriv(long currTime, DistortedObjectGrid grid, DistortedFramebuffer df)
194 188
    {
195 189
    DistortedFramebuffer.deleteAllMarked();
196 190

  
......
204 198
        
205 199
    mF.compute(currTime);
206 200
    mF.send(mHalfX,mHalfY);
207
       
208
    mGrid.draw();
201

  
202
    grid.draw();
209 203
    }
210 204

  
211 205
///////////////////////////////////////////////////////////////////////////////////////////////////
212 206
   
213
  void drawNoEffectsPriv(DistortedFramebuffer df)
207
  void drawNoEffectsPriv(DistortedObjectGrid grid, DistortedFramebuffer df)
214 208
    {
215 209
    GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
216 210

  
217 211
    mM.sendZero(df,mHalfX,mHalfY,mHalfZ);
218 212
    mV.sendZero();
219 213
    mF.sendZero();
220
    mGrid.draw();
214

  
215
    grid.draw();
221 216
    }
222 217
    
223 218
///////////////////////////////////////////////////////////////////////////////////////////////////
......
229 224
    if( !fragmentCloned) mF.abortAll(false);
230 225

  
231 226
    mBmp          = null;
232
    mGrid         = null;
233 227
    mM            = null;
234 228
    mV            = null;
235 229
    mF            = null;
......
270 264
// PUBLIC API
271 265
///////////////////////////////////////////////////////////////////////////////////////////////////
272 266
/**
273
 * Default empty constructor so that derived classes can call it
267
 * Create empty effect queue with no Bitmap.
274 268
 */
275
  public DistortedObject()
269
  public DistortedObject(int width, int height, int depth)
276 270
    {
277

  
271
    initializeData(width,height,depth);
278 272
    }
279 273

  
280 274
///////////////////////////////////////////////////////////////////////////////////////////////////
......
302 296
    mHalfX = dc.mHalfX;
303 297
    mHalfY = dc.mHalfY;
304 298
    mHalfZ = dc.mHalfZ;
305
    mGrid  = dc.mGrid;
306 299

  
307 300
    if( (flags & Distorted.CLONE_BITMAP) != 0 )
308 301
      {
......
331 324
 *        This gets passed on to Dynamics inside the Effects that are currently applied to the
332 325
 *        Object.
333 326
 */
334
  public void draw(long currTime)
327
  public void draw(long currTime, DistortedObjectGrid grid)
335 328
    {
336 329
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
337 330
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
338
    drawPriv(currTime, Distorted.mFramebuffer);
331
    drawPriv(currTime, grid, Distorted.mFramebuffer);
339 332
    }
340 333

  
341 334
///////////////////////////////////////////////////////////////////////////////////////////////////
......
345 338
 * @param currTime Current time, in milliseconds.
346 339
 * @param df       Framebuffer to render this to.
347 340
 */
348
  public void draw(long currTime, DistortedFramebuffer df)
341
  public void draw(long currTime, DistortedObjectGrid grid, DistortedFramebuffer df)
349 342
    {
350 343
    df.setAsOutput();
351 344
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
352
    drawPriv(currTime,df);
345
    drawPriv(currTime,grid, df);
353 346
    }
354 347

  
355 348
///////////////////////////////////////////////////////////////////////////////////////////////////
......
372 365
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
373 366
 */
374 367
   
375
  public void setBitmap(Bitmap bmp)
368
  public void setTexture(Bitmap bmp)
376 369
    {
377 370
    mBitmapSet[0] = true;
378 371

  

Also available in: Unified diff