Project

General

Profile

« Previous | Next » 

Revision bdf04acf

Added by Leszek Koltunski almost 4 years ago

Convert Stencil app to the stretch-less API.

View differences:

src/main/java/org/distorted/examples/stencil/StencilRenderer.java
29 29
import org.distorted.library.effect.MatrixEffectMove;
30 30
import org.distorted.library.effect.MatrixEffectRotate;
31 31
import org.distorted.library.effect.MatrixEffectScale;
32
import org.distorted.library.effect.VertexEffectScale;
32 33
import org.distorted.library.main.DistortedLibrary;
33 34
import org.distorted.library.main.DistortedEffects;
34 35
import org.distorted.library.main.DistortedFramebuffer;
......
101 102
      DistortedEffects floorEffects = new DistortedEffects();
102 103
      DistortedEffects FBOEffects   = new DistortedEffects();
103 104

  
104
      quaFlo.setStretch(2,2,0);
105

  
106 105
      mCube1Node = new DistortedNode(mCubeTex , cube1Effects, cube   );
107 106
      mCube2Node = new DistortedNode(mCubeTex , cube2Effects, cube   );
108 107
      mFloorNode = new DistortedNode(mFloorTex, floorEffects, quaFlo );
......
146 145

  
147 146
      Static3D rotCenter  = new Static3D(0,0,0);
148 147

  
148
      VertexEffectScale  vertexScale = new VertexEffectScale( new Static3D(2,2,0) );
149

  
149 150
      MatrixEffectScale  scale = new MatrixEffectScale(mScale);
150
      MatrixEffectMove   move1 = new MatrixEffectMove( new Static3D( 0, 0, cube.getStretchX()/2) );
151
      MatrixEffectMove   move1 = new MatrixEffectMove( new Static3D( 0, 0, 0.5f) );
151 152
      MatrixEffectRotate rotaX = new MatrixEffectRotate(new Static1D(-60.0f), axisX, rotCenter);
152 153
      MatrixEffectRotate rotaZ = new MatrixEffectRotate(rotDyn, axisZ, rotCenter);
153 154

  
......
162 163
      cube1Effects.apply( rotaX );
163 164
      /////////////////////////////////////////////////////////////////////////////////////////////////////
164 165
      // Floor
166
      floorEffects.apply(vertexScale);
165 167
      floorEffects.apply( scale );
166 168
      floorEffects.apply( rotaZ );
167 169
      floorEffects.apply( rotaX );
......
190 192
    
191 193
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
192 194
      {
193
      float cw = mCube1Node.getMesh().getStretchX();
194
      float ch = mCube1Node.getMesh().getStretchY();
195

  
196
      float bw = mFBONode.getMesh().getStretchX();
197
      float bh = mFBONode.getMesh().getStretchY();
198

  
199
      float scale = 0.4f*(width>height ? height/ch:width/cw);
195
      float scale = 0.4f*(Math.min(width,height));
200 196

  
201 197
      mScale.set(scale,scale,scale);
202
      mFBOScale.set((float)width/bw, (float)height/bh, 1.0f );
198
      mFBOScale.set(width,height,1);
203 199

  
204 200
      mFBONode.resizeFBO(width,height);
205 201
      mScreen.resize( width,height);
......
228 224
      mCubeTex.setTexture(bitmap);
229 225
      mFloorTex.setColor(0xff000000);  // ARGB
230 226

  
227
      VertexEffectScale.enable();
231 228
      FragmentEffectBrightness.enable();
232 229

  
233 230
      try

Also available in: Unified diff