Project

General

Profile

« Previous | Next » 

Revision 410dfc37

Added by Leszek Koltunski almost 4 years ago

Convert ObjectTree to stretchless API.

View differences:

src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java
30 30
import org.distorted.library.effect.FragmentEffectChroma;
31 31
import org.distorted.library.effect.MatrixEffectRotate;
32 32
import org.distorted.library.effect.MatrixEffectScale;
33
import org.distorted.library.effect.VertexEffectScale;
33 34
import org.distorted.library.effect.VertexEffectSink;
34 35
import org.distorted.library.main.DistortedEffects;
35 36
import org.distorted.library.main.DistortedFramebuffer;
......
56 57
class ObjectTreeRenderer implements GLSurfaceView.Renderer
57 58
{
58 59
   private static final int NODE_FBO_SIZE = 300;
59
   private static final int GRID = 20;
60
   private static final int GRID = 10;
60 61

  
61 62
   private GLSurfaceView mView;
62 63
   private DistortedEffects mEffectsNode, mEffectsGrid;
......
97 98
      MatrixEffectRotate rotate = new MatrixEffectRotate(rotDyn, new Static3D(1,0,0), new Static3D(0,0,0));
98 99
      mEffectsGrid.apply(rotate);
99 100

  
101
      VertexEffectScale vScale = new VertexEffectScale( new Static3D(GRID,GRID,1) );
102
      mEffectsGrid.apply(vScale);
103

  
100 104
      Dynamic1D sinkDyn = new Dynamic1D(3000,0.0f);
101 105
      sinkDyn.add(new Static1D(1.0f));
102 106
      sinkDyn.add(new Static1D(0.3f));
103
      VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(0,0,0), new Static4D(0,0,0,10) );
107
      VertexEffectSink sink = new VertexEffectSink(sinkDyn, new Static3D(0,0,0), new Static4D(0,0,0,GRID*0.5f) );
104 108
      mEffectsGrid.apply(sink);
105 109

  
106 110
      mScreen = new DistortedScreen();
......
139 143
    
140 144
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
141 145
      {
142
      float hor   = width /mLisaAspectRatio;
143
      float ver   = height;
144
      float factor= hor>ver ? ver : hor;
145

  
146
      float factor= Math.min(width/mLisaAspectRatio, height);
146 147
      mScale.set( factor,factor,factor );
147 148
      mScreen.resize(width, height);
148 149
      }
......
185 186
      final Static4D mapTB = new Static4D(0.0f,0.0f,1.0f     ,1.0f/GRID);
186 187

  
187 188
      if( mMeshQuad ==null ) mMeshQuad = new MeshQuad();
188
      if( mMeshCubes==null )
189
        {
190
        mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
191
        mMeshCubes.setStretch(GRID,GRID,1);
192
        }
193

  
189
      if( mMeshCubes==null ) mMeshCubes= new MeshCubes(GRID,GRID,1, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB);
194 190

  
195 191
      mRoot = new DistortedNode(mLisaTexture, mEffectsNode, mMeshQuad);
196 192
      mRoot.resizeFBO(NODE_FBO_SIZE,NODE_FBO_SIZE);
......
201 197
      mScreen.detachAll();
202 198
      mScreen.attach(mRoot);
203 199

  
200
      VertexEffectScale.enable();
204 201
      VertexEffectSink.enable();
205 202
      FragmentEffectChroma.enable();
206 203

  

Also available in: Unified diff