Project

General

Profile

« Previous | Next » 

Revision 687263cc

Added by Leszek Koltunski about 4 years ago

Move the 'pre-multiply mesh before applying any effects' thing from [(Xsize of texture, Ysize of texture) x Mesh's zFactor] to Effects.setStretch(sx,sy,sz)

View differences:

src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
84 84
      dRight.add( new Static3D(  0,  0, 0) );
85 85
      dRight.add( new Static3D( 20, 10, 0) );
86 86

  
87
      mEffects = new DistortedEffects();
87
      mEffects = new DistortedEffects(1);
88 88
      mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) );
89 89
      mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) );
90 90

  
......
150 150
      bmpHeight = bitmap.getHeight();
151 151
      bmpWidth  = bitmap.getWidth();
152 152

  
153
      // This will make the Mesh stretched by bmpWidth x bmpHeight even before any effects
154
      // are applied to it (the Mesh - MeshRectangles - is flat, so the third parameter does not
155
      // not matter). bmpWight x bmpHeight is the size of the Bitmap, thus this means that we can
156
      // conveniently work with Effects thinking in Bitmap's native size in pixels. The origin is
157
      // in Bitmap's lower-left corner, thus e.g. a rotation which is meant to rotate the bitmap
158
      // around its center has to be centered at (bmpWidth/2, bmpHeight/2, 0).
159
      // Without this call, the default size of the Mesh is 1x1x0 ( or 1x1x1 in case of not-flat
160
      // Meshes) so we would need to be rotating around (0.5,0.5,0.0).
161
      mEffects.setStretch(bmpWidth,bmpHeight,0);
162

  
153 163
      // We could have gotten here after the activity went to the background
154 164
      // for a brief amount of time; in this case mTexture is already created.
155 165
      // Do not leak memory by creating it the second time around.
156
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
166
      if( mTexture==null ) mTexture = new DistortedTexture();
157 167

  
158 168
      // likewise the Mesh
159 169
      if( mMesh==null ) mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth);

Also available in: Unified diff