Project

General

Profile

« Previous | Next » 

Revision fce25d04

Added by Leszek Koltunski over 7 years ago

Revert "Progress with the last 2 Apps: Effects3D and Wind (not done yet)"

This reverts commit 752c6b57bb227292e6c28438b955fcb892f7acc6.

View differences:

src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java
131 131
                              float sinAnorm = (float)Math.sin(qa/2)/len;
132 132
                              mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA);
133 133
                              break;
134
      case MOVE             : float s  = 0.04f;
135
                              float xm = (mInter[0]-50)*s;
136
                              float ym = (mInter[1]-50)*s;
137
                              float zm = (mInter[2]-50)*s;
134
      case MOVE             : float sw = mAct.get().getScreenWidth()/50.0f;
135
                              float sh = mAct.get().getScreenWidth()/50.0f;
136
                              float xm = (mInter[0]-50)*sw;
137
                              float ym = (mInter[1]-50)*sh;
138
                              float zm = (mInter[2]-50)*(sw+sh)/2;
138 139
                              mSta3.set(xm,ym,zm);
139 140
                              break;
140
      case SCALE            : double coeff = Math.PI / 100;
141

  
142
                              if( mInter[0]<=  0 ) mInter[0]= 1;
143
                              if( mInter[0]>=100 ) mInter[0]=99;
144
                              if( mInter[1]<=  0 ) mInter[1]= 1;
145
                              if( mInter[1]>=100 ) mInter[1]=99;
146
                              if( mInter[2]<=  0 ) mInter[2]= 1;
147
                              if( mInter[2]>=100 ) mInter[2]=99;
148

  
149
                              float xs = (float)Math.tan((mInter[0]-50)*coeff);
150
                              float ys = (float)Math.tan((mInter[1]-50)*coeff);
151
                              float zs = (float)Math.tan((mInter[2]-50)*coeff);
141
      case SCALE            : float xs = (mInter[0]>50 ? 0.18f : 0.018f)*(mInter[0]-50) + 1;
142
                              float ys = (mInter[1]>50 ? 0.18f : 0.018f)*(mInter[1]-50) + 1;
143
                              float zs = (mInter[2]>50 ? 0.18f : 0.018f)*(mInter[2]-50) + 1;
152 144
                              mSta3.set(xs,ys,zs);
153 145
                              break;
154 146
      case SHEAR            : float xsh = (mInter[0]-50)/25.0f;
......
213 205
      case 1: mInter[0] = 50;
214 206
      }
215 207

  
216
    if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION )
217
      {
218
      mInter[1]= 100;
219
      }
220
    if( mName==EffectNames.SCALE )
221
      {
222
      mInter[0]= 75;
223
      mInter[1]= 75;
224
      mInter[2]= 75;
225
      }
208
    if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION ) mInter[1]= 100;
226 209
    }
227 210

  
228 211
///////////////////////////////////////////////////////////////////////////////////////////////////
......
278 261

  
279 262
  private void fillCenterStatics()
280 263
    {
281
    float x = (mInterCenter[0]-50)*0.02f;
282
    float y = (mInterCenter[1]-50)*0.02f;
283
    float z = (mInterCenter[2]-50)*0.02f;
264
    Effects3DActivity act = mAct.get();
265

  
266
    float x = (mInterCenter[0]*0.012f - 0.1f)*act.getWidth();
267
    float y = (mInterCenter[1]*0.012f - 0.1f)*act.getHeight();
268
    float z = (mInterCenter[2]*0.012f - 0.1f)*act.getDepth();
284 269

  
285 270
    mCenterSta.set(x,y,z);
286 271
    }
......
298 283

  
299 284
  private void setCenterText()
300 285
    {
301
    float f0 = ((int)(mCenterSta.getX()*100))/100.0f;
302
    float f1 = ((int)(mCenterSta.getY()*100))/100.0f;
303
    float f2 = ((int)(mCenterSta.getZ()*100))/100.0f;
286
    int f0 = (int)mCenterSta.getX();
287
    int f1 = (int)mCenterSta.getY();
288
    int f2 = (int)mCenterSta.getZ();
304 289

  
305 290
    mTextCenter.setText("center ("+f0+","+f1+","+f2+")");
306 291
    }
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
173 173
    public void onSurfaceChanged(GL10 glUnused, int width, int height)
174 174
      {
175 175
      mScreenMin = width<height ? width:height;
176
      Static3D centerRot = new Static3D(0,0,0);
177

  
178
      //// BACKGROUND ////////////
179
      // quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() )
180
      float distToScreen = height/(2.0f*(float)Math.tan(FOV*Math.PI/360));
181
      float distToFar    = distToScreen*(2-NEAR);
182
      float factor       = distToFar / distToScreen;
183
      mBackgroundEffects.abortEffects(EffectTypes.MATRIX);
184
      mBackgroundEffects.move(new Static3D( 0, 0, -(distToFar-distToScreen)/width ) );
185
      mBackgroundEffects.scale(new Static3D(factor,factor,1.0f) );
186

  
187
      //// OBJECT //////////////
188
      float qObj= ((float)width/height)*((float)mObjHeight/mObjWidth);
189
      float sObj= 0.8f;
190 176

  
191 177
      mObjectEffects.abortEffects(EffectTypes.MATRIX);
192
      mObjectEffects.quaternion(mQuatInt1, centerRot);
193
      mObjectEffects.quaternion(mQuatInt2, centerRot);
194
      mObjectEffects.scale(  qObj<1 ? (new Static3D(sObj,sObj*qObj,sObj)) : (new Static3D(sObj/qObj,sObj,sObj/qObj)) );
195

  
196

  
197

  
178
      mBackgroundEffects.abortEffects(EffectTypes.MATRIX);
179
      mCenterEffects.abortEffects(EffectTypes.MATRIX);
180
      mRegionEffects.abortEffects(EffectTypes.MATRIX);
198 181

  
199
      /*
200 182
      float factorCen;
201 183
      int centerSize = mCenterTexture.getWidth();
202 184
      int regionSize = mRegionTexture.getWidth();
......
218 200

  
219 201
      mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize;
220 202
      mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg);
221
      */
222 203

  
204
      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
223 205

  
224
      //// CENTER //////////////
225
      float qCen= ((float)width/height);
226
      float sCen= 0.1f;
206
      mObjectEffects.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
207
      mObjectEffects.scale(mFactorObj);
208
      mObjectEffects.quaternion(mQuatInt1, rotateObj);
209
      mObjectEffects.quaternion(mQuatInt2, rotateObj);
227 210

  
228
      mCenterEffects.abortEffects(EffectTypes.MATRIX);
229
      /*
230
      mCenterEffects.quaternion(mQuatInt1, centerRot);
231
      mCenterEffects.quaternion(mQuatInt2, centerRot);
232
      mCenterEffects.move( new Static3D(0,0,0.5f) );
211
      Static3D rotateCen = new Static3D(width/2,height/2, 0);
212

  
213
      mCenterEffects.quaternion(mQuatInt1, rotateCen);
214
      mCenterEffects.quaternion(mQuatInt2, rotateCen);
215

  
216
      mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
217
                                  (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) );
233 218
      mCenterEffects.move(mCenterInter);
234
      mCenterEffects.scale(qObj<1 ? (new Static3D(sCen,sCen*qCen,sCen)) : (new Static3D(sCen/qCen,sCen,sCen/qCen)));
235
      */
236
/*
237
      //// REGION //////////////
238
      mRegionEffects.abortEffects(EffectTypes.MATRIX);
219
      mCenterEffects.scale(factorCen);
239 220

  
240 221
      mRegionEffects.quaternion(mQuatInt1, rotateCen);
241 222
      mRegionEffects.quaternion(mQuatInt2, rotateCen);
......
246 227
      mRegionEffects.move(mRegionInter);
247 228
      mRegionEffects.scale(mRegionScaleInter);
248 229
      mRegionEffects.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
249
      */
230

  
231
      int backgroundSize = mBackgroundTexture.getWidth();
232
      float factorBackX = ((float)width)/backgroundSize;
233
      float factorBackY = ((float)height)/backgroundSize;
234

  
235
      // quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() )
236
      mBackgroundEffects.move(new Static3D( -width/2, -height/2, -height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360))) );
237
      mBackgroundEffects.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
238

  
250 239
      mScreen.resize(width, height);
251 240
      }
252 241

  
src/main/java/org/distorted/examples/wind/WindRenderer.java
21 21

  
22 22
import android.graphics.Bitmap;
23 23
import android.graphics.BitmapFactory;
24
import android.opengl.GLES30;
24 25
import android.opengl.GLSurfaceView;
25 26

  
26 27
import org.distorted.examples.R;
......
84 85
      }
85 86

  
86 87
///////////////////////////////////////////////////////////////////////////////////////////////////
87

  
88
    
88 89
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
89 90
      {
90
      float q= ((float)width/height)*((float)mObjHeight/mObjWidth);
91
      float scale = 0.5f;
91
      mEffects.abortAllEffects();
92

  
93
      float factor = ( (float)(width<height? width:height) )/(mObjHeight + 1.4f*mObjWidth);
94

  
95
      mEffects.move( new Static3D( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0) );
96
      mEffects.scale(factor);
97

  
92 98
      Static1D angle = new Static1D(-45);
93 99
      Static3D axis  = new Static3D(0,0,1);
94
      Static3D center= new Static3D( -scale/2,0,0 );
95
      Static3D move  = new Static3D( 0,((float)width/height)*(1-scale/2)-0.5f,0 );
96

  
97
      mEffects.abortAllEffects();
98
      //mEffects.move( move );
99
      //mEffects.rotate(angle, axis, center);
100
      //mManager.apply(mEffects,mWind);
101
      mEffects.scale(q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)));
100
      Static3D center= new Static3D(0,mObjHeight/2,0);
102 101

  
102
      mEffects.rotate(angle, axis, center);
103
      mManager.apply(mEffects,mWind);
103 104
      mScreen.resize(width, height);
104 105
      }
105 106

  

Also available in: Unified diff