Project

General

Profile

« Previous | Next » 

Revision b424b062

Added by Leszek Koltunski over 5 years ago

Make Matrix effects Rotate and Quaternion actually correct when it comes to the Z-axis. Also corresponding adjustments in apps.

View differences:

src/main/java/org/distorted/examples/cubes/CubesRenderer.java
117 117
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (0.75f*height)/mObjHeight :  (0.75f*width)/mObjWidth;
118 118
      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
119 119
      mScale.set(factor,factor,factor);
120
      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, -(float)mObjDepth/2 );
120
      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
121 121
      mScreen.resize(width, height);
122 122
      }
123 123

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

  
98 98
      mObjWidth = mObjectTexture.getWidth();
99 99
      mObjHeight= mObjectTexture.getHeight();
100
      mObjDepth = mObjectTexture.getDepth(mesh);
100 101

  
101 102
      mQuat1 = new Static4D(0,0,0,1);  // unity
102 103
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
146 147
    void resetMatrixEffects()
147 148
      {
148 149
      Effects3DActivity2 act = (Effects3DActivity2)mView.getContext();
149

  
150 150
      DistortedEffects objectEffects= act.getEffects();
151
      MeshBase mesh  = act.getMesh();
152

  
153
      int objDepth = mObjectTexture.getDepth(mesh);
154

  
155
      Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, -(float)objDepth/2 );
151
      Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
156 152

  
157 153
      MatrixEffectQuaternion quat1obj = new MatrixEffectQuaternion(mQuat1,  rotateObj);
158 154
      MatrixEffectQuaternion quat2obj = new MatrixEffectQuaternion(mQuat2,  rotateObj);
src/main/java/org/distorted/examples/inflate/InflateRenderer.java
110 110
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight :  (SCALE*width)/mObjWidth;
111 111
      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
112 112
      mScale.set(factor,factor,factor);
113
      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, -(float)mObjDepth/2 );
113
      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
114 114
      mScreen.resize(width, height);
115 115
      }
116 116

  
src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java
169 169

  
170 170
    	float factor    = 0.15f*mScreenMin/OBJ_SIZE;
171 171
    	mScale.set(factor,factor,factor);
172
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
172
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, (float)OBJ_SIZE/2 );
173 173
      mMove.set( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0);
174 174
      computeMoveVectors();
175 175
      mScreen.resize(width, height);
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
117 117

  
118 118
    float factor = 0.5f*(width>height ? height/h:width/w);
119 119

  
120
    mCenter.set(w/2,h/2,-d/2);
120
    mCenter.set(w/2,h/2,d/2);
121 121
    mMove.set( (width-factor*w)/2 , (height-factor*h)/2 , 0 );
122 122
    mScale.set(factor,factor,factor);
123 123

  
src/main/java/org/distorted/examples/stencil/StencilRenderer.java
148 148
      float fh = mFloorTex.getHeight();
149 149
      float fd = mFloorTex.getDepth(mQuad);
150 150

  
151
      Static3D cubeCenter = new Static3D(cw/2,ch  ,-cd/2);
152
      Static3D floorCenter= new Static3D(fw/2,fh/2,-fd/2);
151
      Static3D cubeCenter = new Static3D(cw/2,ch  ,cd/2);
152
      Static3D floorCenter= new Static3D(fw/2,fh/2,fd/2);
153 153

  
154 154
      Static3D axisX = new Static3D(1,0,0);
155 155
      Static3D axisY = new Static3D(0,1,0);
src/main/java/org/distorted/examples/transparency/TransparencyRenderer.java
214 214

  
215 215
    public void onSurfaceChanged(GL10 glUnused, int width, int height)
216 216
      {
217
      float size= 0.02f*OBJ_SIZE;
217 218
      mScreenMin = width<height ? width:height;
218 219

  
219 220
      float factor = 0.70f*mScreenMin/OBJ_SIZE;
220 221
      mScale.set(factor,factor,factor);
221
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
222
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, (float)OBJ_SIZE/2 );
222 223
      mMove.set( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0);
223 224

  
224
      float size= 0.02f*OBJ_SIZE;
225

  
226 225
      for(int i=0; i<NUM_OBJECTS; i++)
227 226
        {
228 227
        mMoveVector[i].set(size*OBJECTS[NUM*i], size*OBJECTS[NUM*i+1], size*OBJECTS[NUM*i+2]);
src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
220 220
      float factor2 = 0.80f*factor1;
221 221
      mScale1.set(factor1,factor1,factor1);
222 222
      mScale2.set(factor2,factor2,factor2);
223
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, -(float)OBJ_SIZE/2 );
223
      mCenter.set((float)OBJ_SIZE/2, (float)OBJ_SIZE/2, (float)OBJ_SIZE/2 );
224 224
      mMove1.set( (width -factor1*OBJ_SIZE)/2 ,(height-factor1*OBJ_SIZE)/2 ,0);
225 225
      mMove2.set( (width -factor2*OBJ_SIZE)/2 ,(height-factor2*OBJ_SIZE)/2 ,0);
226 226
      mScreen.resize(width, height);

Also available in: Unified diff