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/rubik/RubikRenderer.java
49 49
    private GLSurfaceView mView;
50 50
    private DistortedTexture mTexture;
51 51
    private DistortedScreen mScreen;
52
    private Static3D mMove, mScale, mCenter;
52
    private Static3D mScale;
53 53
    private MeshCubes[][][] mCubes;
54 54
    private DistortedEffects[][][] mEffects;
55 55

  
......
72 72
      mEffects = new DistortedEffects[CUBE_SIZE][CUBE_SIZE][CUBE_SIZE];
73 73
      Static3D[][][] cubeVectors = new Static3D[CUBE_SIZE][CUBE_SIZE][CUBE_SIZE];
74 74

  
75
      mMove  = new Static3D(0,0,0);
76 75
      mScale = new Static3D(1,1,1);
77
      mCenter= new Static3D(0,0,0);
76
      Static3D center= new Static3D(0,0,0);
78 77

  
79
      MatrixEffectMove       move  = new MatrixEffectMove(mMove);
80 78
      MatrixEffectScale      scale = new MatrixEffectScale(mScale);
81
      MatrixEffectQuaternion quat1 = new MatrixEffectQuaternion(mQuat1, mCenter);
82
      MatrixEffectQuaternion quat2 = new MatrixEffectQuaternion(mQuat2, mCenter);
79
      MatrixEffectQuaternion quat1 = new MatrixEffectQuaternion(mQuat1, center);
80
      MatrixEffectQuaternion quat2 = new MatrixEffectQuaternion(mQuat2, center);
83 81

  
84 82
      // 3x2 bitmap = 6 squares:
85 83
      //
......
120 118

  
121 119
            mEffects[x][y][z] = new DistortedEffects();
122 120

  
123
            mEffects[x][y][z].apply(move);
124 121
            mEffects[x][y][z].apply(scale);
125 122
            mEffects[x][y][z].apply(quat1);
126 123
            mEffects[x][y][z].apply(quat2);
......
143 140

  
144 141
      float w = mTexture.getWidth();
145 142
      float h = mTexture.getHeight();
146
      float d = mTexture.getDepth(mCubes[0][0][0]);
147

  
148 143
      float factor = 0.6f*(width>height ? height/h:width/w)/CUBE_SIZE;
149 144

  
150
      mCenter.set(w/2,h/2,d/2);
151
      mMove.set( (width-factor*w)/2 , (height-factor*h)/2 , -factor*d/2 );
152 145
      mScale.set(factor,factor,factor);
153

  
154 146
      mScreen.resize(width, height);
155 147
      }
156 148

  

Also available in: Unified diff