Project

General

Profile

« Previous | Next » 

Revision 16b22aab

Added by Leszek Koltunski about 5 years ago

Fix several more apps for the 'center-of-matrix-effects-in-screen-center' change.

View differences:

src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
57 57
    private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture;
58 58
    private DistortedScreen mScreen;
59 59
    private DistortedNode mCenterNode, mRegionNode;
60
    private int mObjWidth, mObjHeight, mObjDepth;
60
    private int mObjWidth, mObjHeight;
61 61
    private Static3D mCenterPoint, mRegionPoint, mRegionScalePoint;
62 62
    private Static3D mRotateCen, mMoveObject, mScaleObject, mMoveCenter, mScaleCenter, mMoveRegion, mMoveBackground, mScaleBackground;
63 63
    private boolean mShowingCenter=false;
......
103 103

  
104 104
      mObjWidth = mObjectTexture.getWidth();
105 105
      mObjHeight= mObjectTexture.getHeight();
106
      mObjDepth = mObjectTexture.getDepth(mesh);
107 106

  
108 107
      mQuat1 = new Static4D(0,0,0,1);  // unity
109 108
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
143 142

  
144 143
      resetMatrixEffects();
145 144

  
146
      // quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() )
147 145
      backgroundEffects.apply(new MatrixEffectMove(mMoveBackground) );
148 146
      backgroundEffects.apply(new MatrixEffectScale(mScaleBackground) );
149 147
      }
......
154 152
      {
155 153
      Effects3DActivity2 act = (Effects3DActivity2)mView.getContext();
156 154
      DistortedEffects objectEffects= act.getEffects();
157
      Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
155
      Static3D rotateObj = new Static3D( 0,0,0 );
158 156

  
159 157
      MatrixEffectQuaternion quat1obj = new MatrixEffectQuaternion(mQuat1,  rotateObj);
160 158
      MatrixEffectQuaternion quat2obj = new MatrixEffectQuaternion(mQuat2,  rotateObj);
......
253 251
      mRegionPoint.set(mFactorObj*act.getRegionX(),-mFactorObj*act.getRegionY(),0);
254 252
      mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize;
255 253
      mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg);
256
      mMoveObject.set( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , -mFactorObj*mObjDepth );
257 254
      mRotateCen.set(width/2,height/2, 0);
258 255
      mScaleObject.set(mFactorObj,mFactorObj,mFactorObj);
259
      mMoveCenter.set( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
260
                       (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 15 );
256
      mMoveCenter.set( 0,0,15);//(width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
257
                    //   (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 15 );
261 258
      mScaleCenter.set(factorCen,factorCen,factorCen);
262 259
      mMoveRegion.set( (width -mFactorObj*mObjWidth )/2 ,(height-mFactorObj*mObjHeight)/2 , 12 );
263 260

  
......
266 263
      float factorBackY = ((float)height)/backgroundSize;
267 264

  
268 265
      // quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() )
269
      mMoveBackground.set( -width/2, -height/2, -0.9f*height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360)) );
266
      mMoveBackground.set( 0, 0, -0.9f*height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360)) );
270 267
      mScaleBackground.set( 2*factorBackX, 2*factorBackY, 1.0f );
271 268

  
272 269
      mScreen.resize(width, height);

Also available in: Unified diff