Project

General

Profile

« Previous | Next » 

Revision 392e16fd

Added by Leszek Koltunski over 7 years ago

Change in the API: we always have to create a DistortedFramebuffer to render to.

View differences:

src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
26 26

  
27 27
import org.distorted.examples.R;
28 28
import org.distorted.library.Distorted;
29
import org.distorted.library.DistortedFramebuffer;
29 30
import org.distorted.library.DistortedTexture;
30 31
import org.distorted.library.GridFlat;
31 32
import org.distorted.library.DistortedEffectQueues;
......
48 49
{
49 50
    private GLSurfaceView mView;
50 51
    private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture;
51
    private DistortedEffectQueues mObjectQueues, mBackgroundQueues, mCenterQueues, mRegionQueues;
52
    private DistortedEffectQueues mObjectEffects, mBackgroundEffects, mCenterEffects, mRegionEffects;
53
    private DistortedFramebuffer mScreen;
52 54
    private GridFlat mQuad;
53 55
    private GridObject mObjectGrid;
54 56
    private int mObjWidth, mObjHeight, mObjDepth;
......
74 76

  
75 77
      mObjectTexture     = act.getTexture();
76 78
      mObjectGrid        = act.getGrid();
77
      mObjectQueues      = act.getQueues();
79
      mObjectEffects = act.getQueues();
78 80
      mBackgroundTexture = new DistortedTexture(100,100);
79 81
      mCenterTexture     = new DistortedTexture(100,100);
80 82
      mRegionTexture     = new DistortedTexture(100,100);
81 83
      mQuad              = new GridFlat(1,1);
82
      mBackgroundQueues  = new DistortedEffectQueues();
83
      mCenterQueues      = new DistortedEffectQueues();
84
      mRegionQueues      = new DistortedEffectQueues();
84
      mBackgroundEffects = new DistortedEffectQueues();
85
      mCenterEffects = new DistortedEffectQueues();
86
      mRegionEffects = new DistortedEffectQueues();
85 87

  
86 88
      mObjWidth = mObjectTexture.getWidth();
87 89
      mObjHeight= mObjectTexture.getHeight();
......
107 109
      mRegionScaleInter = new Dynamic3D();
108 110
      mRegionScalePoint = new Static3D(0,0,0);
109 111
      mRegionScaleInter.add(mRegionScalePoint);
112

  
113
      mScreen = new DistortedFramebuffer(0);
110 114
      }
111 115

  
112 116
///////////////////////////////////////////////////////////////////////////////////////////////////
......
133 137

  
134 138
      long time = System.currentTimeMillis();
135 139

  
136
      mBackgroundQueues.draw(time,mBackgroundTexture,mQuad);
137
      mObjectQueues.draw(time,mObjectTexture,mObjectGrid);
140
      mBackgroundEffects.draw(time,mBackgroundTexture,mQuad,mScreen);
141
      mObjectEffects.draw(time,mObjectTexture,mObjectGrid,mScreen);
138 142

  
139 143
      if( Effects3DActivity.supportsCenter() )
140 144
        {
141
        mCenterQueues.draw(time, mCenterTexture,mQuad);
142
        if( Effects3DActivity.supportsRegion() ) mRegionQueues.draw(time, mRegionTexture,mQuad);
145
        mCenterEffects.draw(time, mCenterTexture,mQuad,mScreen);
146
        if( Effects3DActivity.supportsRegion() ) mRegionEffects.draw(time, mRegionTexture,mQuad,mScreen);
143 147
        }
144 148
      }
145 149

  
......
149 153
      {
150 154
      mScreenMin = width<height ? width:height;
151 155

  
152
      mObjectQueues.abortEffects(EffectTypes.MATRIX);
153
      mBackgroundQueues.abortEffects(EffectTypes.MATRIX);
154
      mCenterQueues.abortEffects(EffectTypes.MATRIX);
155
      mRegionQueues.abortEffects(EffectTypes.MATRIX);
156
      mObjectEffects.abortEffects(EffectTypes.MATRIX);
157
      mBackgroundEffects.abortEffects(EffectTypes.MATRIX);
158
      mCenterEffects.abortEffects(EffectTypes.MATRIX);
159
      mRegionEffects.abortEffects(EffectTypes.MATRIX);
156 160

  
157 161
      float factorCen;
158 162
      int centerSize = mCenterTexture.getWidth();
......
178 182

  
179 183
      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
180 184

  
181
      mObjectQueues.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
182
      mObjectQueues.scale(mFactorObj);
183
      mObjectQueues.quaternion(mQuatInt1, rotateObj);
184
      mObjectQueues.quaternion(mQuatInt2, rotateObj);
185
      mObjectEffects.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
186
      mObjectEffects.scale(mFactorObj);
187
      mObjectEffects.quaternion(mQuatInt1, rotateObj);
188
      mObjectEffects.quaternion(mQuatInt2, rotateObj);
185 189

  
186 190
      Static3D rotateCen = new Static3D(width/2,height/2, 0);
187 191

  
188
      mCenterQueues.quaternion(mQuatInt1, rotateCen);
189
      mCenterQueues.quaternion(mQuatInt2, rotateCen);
192
      mCenterEffects.quaternion(mQuatInt1, rotateCen);
193
      mCenterEffects.quaternion(mQuatInt2, rotateCen);
190 194

  
191
      mCenterQueues.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
195
      mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
192 196
                                  (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) );
193
      mCenterQueues.move(mCenterInter);
194
      mCenterQueues.scale(factorCen);
197
      mCenterEffects.move(mCenterInter);
198
      mCenterEffects.scale(factorCen);
195 199

  
196
      mRegionQueues.quaternion(mQuatInt1, rotateCen);
197
      mRegionQueues.quaternion(mQuatInt2, rotateCen);
200
      mRegionEffects.quaternion(mQuatInt1, rotateCen);
201
      mRegionEffects.quaternion(mQuatInt2, rotateCen);
198 202

  
199
      mRegionQueues.move( new Static3D( (width -mFactorObj*mObjWidth )/2 ,
203
      mRegionEffects.move( new Static3D( (width -mFactorObj*mObjWidth )/2 ,
200 204
                                  (height-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+12) );
201
      mRegionQueues.move(mCenterInter);
202
      mRegionQueues.move(mRegionInter);
203
      mRegionQueues.scale(mRegionScaleInter);
204
      mRegionQueues.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
205
      mRegionEffects.move(mCenterInter);
206
      mRegionEffects.move(mRegionInter);
207
      mRegionEffects.scale(mRegionScaleInter);
208
      mRegionEffects.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
205 209

  
206 210
      int backgroundSize = mBackgroundTexture.getWidth();
207 211
      float factorBackX = ((float)width)/backgroundSize;
208 212
      float factorBackY = ((float)height)/backgroundSize;
209 213

  
210
      mBackgroundQueues.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
211
      mBackgroundQueues.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
214
      mBackgroundEffects.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
215
      mBackgroundEffects.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
212 216

  
213
      Distorted.onSurfaceChanged(width, height);
217
      mScreen.resize(width, height);
214 218
      }
215 219

  
216 220
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff