Project

General

Profile

« Previous | Next » 

Revision 1b059065

Added by Leszek Koltunski almost 5 years ago

Correct the Rubik app for the recent changes to the library's Node.

View differences:

src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
161 161
    MeshBase mesh = node.getMesh();
162 162
    DistortedEffects effects = node.getEffects();
163 163

  
164
    float halfW = mesh.getStretchX() / 2.0f;
165
    float halfH = mesh.getStretchY() / 2.0f;
166
    float halfZ = mesh.getStretchZ() / 2.0f;
164
    float halfW = mesh.getBoundingX();
165
    float halfH = mesh.getBoundingY();
166
    float halfZ = mesh.getBoundingZ();
167 167

  
168 168
    int width   = buffer.getWidth();
169 169
    int height  = buffer.getHeight();
src/main/java/org/distorted/library/main/DistortedLibrary.java
441 441
    GLES31.glUniform1ui(DistortedLibrary.mMainOITNumRecordsH, (int)(DistortedLibrary.mBufferSize*surface.mWidth*surface.mHeight) );
442 442
    mesh.bindVertexAttribs(DistortedLibrary.mMainOITProgram);
443 443

  
444
    float halfX       = mesh.getStretchX() / 2.0f;
445
    float halfY       = mesh.getStretchY() / 2.0f;
446
    float halfZ       = mesh.getStretchZ() / 2.0f;
444
    float halfX       = mesh.getBoundingX();
445
    float halfY       = mesh.getBoundingY();
446
    float halfZ       = mesh.getBoundingZ();
447 447
    float inflate     = mesh.getInflate();
448 448
    float distance    = surface.mDistance;
449 449
    float mipmap      = surface.mMipmap;
......
473 473
    GLES31.glUniform1i(DistortedLibrary.mMainTextureH, 0);
474 474
    mesh.bindVertexAttribs(DistortedLibrary.mMainProgram);
475 475

  
476
    float halfX       = mesh.getStretchX() / 2.0f;
477
    float halfY       = mesh.getStretchY() / 2.0f;
478
    float halfZ       = mesh.getStretchZ() / 2.0f;
476
    float halfX       = mesh.getBoundingX();
477
    float halfY       = mesh.getBoundingY();
478
    float halfZ       = mesh.getBoundingZ();
479 479
    float inflate     = mesh.getInflate();
480 480
    float distance    = surface.mDistance;
481 481
    float mipmap      = surface.mMipmap;
src/main/java/org/distorted/library/main/DistortedScreen.java
27 27
import android.opengl.GLES31;
28 28

  
29 29
import org.distorted.library.effect.MatrixEffectMove;
30
import org.distorted.library.effect.MatrixEffectScale;
30 31
import org.distorted.library.mesh.MeshQuad;
31 32
import org.distorted.library.type.Static3D;
32 33

  
......
166 167
      fpsTexture.setTexture(fpsBitmap);
167 168
      fpsCanvas = new Canvas(fpsBitmap);
168 169
      fpsEffects = new DistortedEffects();
169
      fpsMesh.setStretch(FPS_W,FPS_H,0);
170
      fpsEffects.apply( new MatrixEffectScale( new Static3D(FPS_W,FPS_H,1) ) );
170 171
      fpsEffects.apply(mMoveEffect);
171 172

  
172 173
      mPaint = new Paint();
src/main/java/org/distorted/library/mesh/MeshBase.java
68 68
   private int mNumVertices;
69 69
   private float[] mVertAttribs;      // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ, TexS,TexT
70 70
   private float mInflate;
71
   private float mStretchX, mStretchY, mStretchZ;
71
   private float mBoundingX, mBoundingY, mBoundingZ;
72 72

  
73 73
   private class Component
74 74
     {
......
100 100

  
101 101
///////////////////////////////////////////////////////////////////////////////////////////////////
102 102

  
103
   MeshBase(float sx, float sy, float sz)
103
   MeshBase(float bx, float by, float bz)
104 104
     {
105
     mStretchX = sx;
106
     mStretchY = sy;
107
     mStretchZ = sz;
105
     mBoundingX = bx/2;
106
     mBoundingY = by/2;
107
     mBoundingZ = bz/2;
108 108

  
109 109
     mShowNormals = false;
110 110
     mInflate     = 0.0f;
......
120 120

  
121 121
   MeshBase(MeshBase original)
122 122
     {
123
     mStretchX = original.mStretchX;
124
     mStretchY = original.mStretchY;
125
     mStretchZ = original.mStretchZ;
123
     mBoundingX = original.mBoundingX;
124
     mBoundingY = original.mBoundingY;
125
     mBoundingZ = original.mBoundingZ;
126 126

  
127 127
     mShowNormals = original.mShowNormals;
128 128
     mInflate     = original.mInflate;
......
183 183

  
184 184
///////////////////////////////////////////////////////////////////////////////////////////////////
185 185
/**
186
 * Sets the stretch parameters. Coordinates of all vertices will be first pre-multiplied by those.
187
 */
188
  public void setStretch(int sx, int sy, int sz)
189
    {
190
    mStretchX = sx;
191
    mStretchY = sy;
192
    mStretchZ = sz;
193
    }
194

  
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196
/**
197
 * X coordinates of all vertices will be first pre-multiplied by this parameter.
186
 * Each mesh has its 'bounding box' - return half of its X-length.
187
 * <p>
188
 * In case of all 'simple' Meshes, the bounding box is always 1x1x1 (Sphere, Cubes) or 1x1x0
189
 * (Rectangles, Triangles, Quad - i.e. all 'flat' Meshes). But this can be something else in case of
190
 * MeshComponent.
198 191
 */
199
  public float getStretchX()
192
   public float getBoundingX()
200 193
    {
201
    return mStretchX;
194
    return mBoundingX;
202 195
    }
203 196

  
204 197
///////////////////////////////////////////////////////////////////////////////////////////////////
205 198
/**
206
 * Y coordinates of all vertices will be first pre-multiplied by this parameter.
199
 * Each mesh has its 'bounding box' - return half of its Y-length.
207 200
 */
208
  public float getStretchY()
201
   public float getBoundingY()
209 202
    {
210
    return mStretchY;
203
    return mBoundingY;
211 204
    }
212 205

  
213 206
///////////////////////////////////////////////////////////////////////////////////////////////////
214 207
/**
215
 * Z coordinates of all vertices will be first pre-multiplied by this parameter.
208
 * Each mesh has its 'bounding box' - return half of its Z-length.
216 209
 */
217
  public float getStretchZ()
210
   public float getBoundingZ()
218 211
    {
219
    return mStretchZ;
212
    return mBoundingZ;
220 213
    }
221 214

  
222 215
///////////////////////////////////////////////////////////////////////////////////////////////////
......
352 345
         mVertAttribs[index+POS_ATTRIB+1] = tmp[1]*x + tmp[5]*y + tmp[ 9]*z + tmp[13];
353 346
         mVertAttribs[index+POS_ATTRIB+2] = tmp[2]*x + tmp[6]*y + tmp[10]*z + tmp[14];
354 347

  
355
//android.util.Log.e("mesh", "vert BEFORE: ("+x+","+y+","+z+")");
356
//android.util.Log.e("mesh", "vert AFTER: ("+mVertAttribs[index+POS_ATTRIB  ]+","+mVertAttribs[index+POS_ATTRIB+1]+","+mVertAttribs[index+POS_ATTRIB+2]+")");
357

  
358 348
         x = mVertAttribs[index+NOR_ATTRIB  ];
359 349
         y = mVertAttribs[index+NOR_ATTRIB+1];
360 350
         z = mVertAttribs[index+NOR_ATTRIB+2];
......
484 474

  
485 475
       }
486 476
     }
477

  
478

  
479

  
480
///////////////////////////////////////////////////////////////////////////////////////////////////
481

  
482
   public void setStretch(int sx, int sy, int sz)
483
     {
484
     mBoundingX = sx/2.0f;
485
     mBoundingY = sy/2.0f;
486
     mBoundingZ = sz/2.0f;
487
     }
488

  
489
   public float getStretchX()
490
    {
491
    return mBoundingX*2;
492
    }
493
   public float getStretchY()
494
    {
495
    return mBoundingY*2;
496
    }
497
   public float getStretchZ()
498
    {
499
    return mBoundingZ*2;
500
    }
501

  
502

  
487 503
   }
488 504

  
489 505

  

Also available in: Unified diff