Project

General

Profile

« Previous | Next » 

Revision d79a56d3

Added by Leszek Koltunski about 7 years ago

Major refactoring: convert the Matrix Effects to be independent of the resolution of the surface we render to.

Re-write the first 15 apps to work with this.

View differences:

src/main/java/org/distorted/examples/fbo/FBORenderer.java
103 103
    
104 104
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
105 105
      { 
106
      mEffects.abortEffects(EffectTypes.MATRIX);
107
         
108
      if( (float)lisaHeight/lisaWidth > (float)height/width )
109
        {
110
        int w = (height*lisaWidth)/lisaHeight;
111
        float factor = (float)height/lisaHeight;
112

  
113
        mEffects.move( new Static3D((width-w)/2,0,0) );
114
        mEffects.scale(factor);
115
        }
116
      else
117
        {
118
        int h = (width*lisaHeight)/lisaWidth;
119
        float factor = (float)width/lisaWidth;
106
      float qx = (float)width /lisaWidth;
107
      float qy = (float)height/lisaHeight;
120 108

  
121
        mEffects.move( new Static3D(0,(height-h)/2,0) );
122
        mEffects.scale(factor);
123
        }
109
      mEffects.abortEffects(EffectTypes.MATRIX);
110
      mEffects.scale(  qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) );
124 111
      
125 112
      mScreen.resize(width, height);
126 113
      }
......
164 151
      mGridTexture.setTexture(bitmap2);
165 152
      DistortedEffects gridEffects = new DistortedEffects();
166 153

  
167
      mEffects.abortAllEffects();
168

  
169 154
      mRoot = new DistortedNode(mLisaTexture, mEffects,new MeshFlat(1,1));
170 155
      mRoot.attach(mGridTexture,gridEffects,new MeshCubes(10,10,false));
171 156

  
......
174 159
      mScreen.detachAll();
175 160
      mScreen.attach(mRoot);
176 161

  
177
      float factor = lisaWidth/(2.0f*gridWidth);
178

  
179
      gridEffects.move( new Static3D( (lisaWidth-factor*gridWidth)/2,(lisaHeight-factor*gridHeight)/2,0) );
180
      gridEffects.scale(factor);
162
      gridEffects.scale(0.5f);
181 163

  
182 164
      Dynamic1D rotDyn = new Dynamic1D(12000,0.0f);
183 165
      rotDyn.add(new Static1D(  0));
184 166
      rotDyn.add(new Static1D(360));
185 167
      rotDyn.setMode(Dynamic.MODE_JUMP);
186 168

  
187
      gridEffects.rotate(rotDyn, new Static3D(1,0,0), new Static3D(gridWidth/2,gridHeight/2,gridHeight/10) );
169
      gridEffects.rotate(rotDyn, new Static3D(1,0,0), new Static3D(0,0,1.0f/10) );
188 170

  
189 171
      Dynamic1D sinkDyn = new Dynamic1D(3000,0.0f);
190 172
      sinkDyn.add(new Static1D(1.0f));

Also available in: Unified diff