Project

General

Profile

« Previous | Next » 

Revision e8b2f311

Added by Leszek Koltunski almost 8 years ago

boundingVertices fully work now!

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
86 86

  
87 87
  private boolean matrixCloned, vertexCloned, fragmentCloned, postprocessCloned;
88 88

  
89
private int mL, mR, mT, mB;
90

  
91 89
///////////////////////////////////////////////////////////////////////////////////////////////////
92 90

  
93 91
  static void createProgram(Resources resources)
......
184 182
///////////////////////////////////////////////////////////////////////////////////////////////////
185 183
// DEBUG ONLY
186 184

  
185
  @SuppressWarnings("unused")
187 186
  private void displayBoundingRect(float halfX, float halfY, float halfZ, DistortedFramebuffer df, float[] mvp, float[] vertices)
188 187
    {
189 188
    int len  = vertices.length/3;
......
193 192
    int maxy = Integer.MIN_VALUE;
194 193
    int wx,wy;
195 194

  
196
int l=-1,r=-1,t=-1,b=-1;
197

  
198 195
    float x,y,z, X,Y,W, ndcX,ndcY;
199 196

  
200 197
    for(int i=0; i<len; i++)
......
213 210
      wx = (int)(df.mWidth *(ndcX+1)/2);
214 211
      wy = (int)(df.mHeight*(ndcY+1)/2);
215 212

  
216
      if( wx<minx ) { minx = wx; l = i; }
217
      if( wx>maxx ) { maxx = wx; r = i; }
218
      if( wy<miny ) { miny = wy; t = i; }
219
      if( wy>maxy ) { maxy = wy; b = i; }
213
      if( wx<minx ) minx = wx;
214
      if( wx>maxx ) maxx = wx;
215
      if( wy<miny ) miny = wy;
216
      if( wy>maxy ) maxy = wy;
220 217
      }
221 218

  
222 219
    mDebugProgram.useProgram();
......
236 233

  
237 234
    GLES20.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES20.GL_FLOAT, false, 0, mQuadPositions);
238 235
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
239

  
240
    if( l!=mL )
241
      {
242
      mL = l;
243
      android.util.Log.e("effects", "l="+l+" ("+vertices[3*l]+","+vertices[3*l+1]+","+vertices[3*l+2]+")");
244
      }
245 236
    }
246 237

  
247 238
///////////////////////////////////////////////////////////////////////////////////////////////////
......
300 291
      }
301 292

  
302 293
    /// DEBUG ONLY //////
303
    displayBoundingRect(halfInputH, halfInputW, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
294
    // displayBoundingRect(halfInputH, halfInputW, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
304 295
    /// END DEBUG ///////
305 296
    }
306 297

  
src/main/java/org/distorted/library/MeshCubes.java
292 292
  private int addLeftmost(float[] temp, int row, int index)
293 293
    {
294 294
    float x2 = retLeftmost(row)/mCols - 0.5f;
295
    float y2 = (float)row      /mRows - 0.5f;
295
    float y2 = 0.5f - (float)row/mRows;
296 296

  
297 297
    if( index>1 )
298 298
      {
......
301 301
      float x1 = temp[2*index-2];
302 302
      float y1 = temp[2*index-1];
303 303

  
304
      while( (x0-x2)*(y0-y1) <= (x0-x1)*(y0-y2) )
304
      while( (x0-x2)*(y0-y1) >= (x0-x1)*(y0-y2) )
305 305
        {
306 306
        if( --index>1 )
307 307
          {
......
324 324
  private int addRightmost(float[] temp, int row, int index)
325 325
    {
326 326
    float x2 = retRightmost(row)/mCols - 0.5f;
327
    float y2 = (float)row       /mRows - 0.5f;
327
    float y2 = 0.5f - (float)row/mRows;
328 328

  
329 329
    if( index>1 )
330 330
      {
......
333 333
      float x1 = temp[2*index-2];
334 334
      float y1 = temp[2*index-1];
335 335

  
336
      while( (x0-x2)*(y0-y1) >= (x0-x1)*(y0-y2) )
336
      while( (x0-x2)*(y0-y1) <= (x0-x1)*(y0-y2) )
337 337
        {
338 338
        if( --index>1 )
339 339
          {

Also available in: Unified diff