Project

General

Profile

« Previous | Next » 

Revision 8647eae2

Added by Leszek Koltunski over 5 years ago

Improve the architecture of the Rubik App: new RubikCube class.

View differences:

src/main/java/org/distorted/examples/rubik/RubikActivity.java
1 1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
2
// Copyright 2019 Leszek Koltunski                                                               //
3 3
//                                                                                               //
4 4
// This file is part of Distorted.                                                               //
5 5
//                                                                                               //
src/main/java/org/distorted/examples/rubik/RubikRenderer.java
1 1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
2
// Copyright 2019 Leszek Koltunski                                                               //
3 3
//                                                                                               //
4 4
// This file is part of Distorted.                                                               //
5 5
//                                                                                               //
......
19 19

  
20 20
package org.distorted.examples.rubik;
21 21

  
22
import android.graphics.Bitmap;
23
import android.graphics.Canvas;
24
import android.graphics.Paint;
25 22
import android.opengl.GLSurfaceView;
26 23

  
27
import org.distorted.library.effect.MatrixEffectMove;
28
import org.distorted.library.effect.MatrixEffectQuaternion;
29
import org.distorted.library.effect.MatrixEffectRotate;
30
import org.distorted.library.effect.MatrixEffectScale;
31 24
import org.distorted.library.effect.VertexEffectSink;
32 25
import org.distorted.library.main.Distorted;
33
import org.distorted.library.main.DistortedEffects;
34 26
import org.distorted.library.main.DistortedScreen;
35
import org.distorted.library.main.DistortedTexture;
36
import org.distorted.library.mesh.MeshCubes;
37
import org.distorted.library.type.Dynamic1D;
38
import org.distorted.library.type.Static1D;
39 27
import org.distorted.library.type.Static3D;
40 28
import org.distorted.library.type.Static4D;
41 29

  
......
46 34

  
47 35
class RubikRenderer implements GLSurfaceView.Renderer
48 36
{
49
            static final int NUM_CUBES =   4;
50
    private static final int SIZE      = 200;
37
    static final int NUM_CUBES = 4;
51 38
    private static final float CUBE_SCREEN_RATIO = 0.5f;
52 39

  
53
    private static final Static3D VectX = new Static3D(1,0,0);
54
    private static final Static3D VectY = new Static3D(0,1,0);
55
    private static final Static3D VectZ = new Static3D(0,0,1);
56

  
57 40
    private GLSurfaceView mView;
58
    private DistortedTexture mTexture;
59 41
    private DistortedScreen mScreen;
60
    private Static3D mMove, mScale, mCenter;
61
    private MeshCubes[][][] mCubes;
62
    private DistortedEffects[][][] mEffects;
63
    private Static4D[][][] mQuatScramble;
64
    private Static3D[][][] mRotationAxis;
65
    private Dynamic1D[][][] mRotationAngle;
66
    private Static3D[][][] mCurrentPosition;
67
    private Static1D mRotationAngleStatic;
68
    private int mRotAxis, mRotRow;
69

  
70
    private int mScreenWidth, mScreenHeight;
71

  
42
    private Static3D mMove, mScale;
72 43
    private Static4D mQuatCurrent, mQuatAccumulated;
73 44
    private Static4D mTempCurrent, mTempAccumulated;
74
    int mScreenMin;
45
    private float mScaleFactor;
46
    private int mScreenWidth, mScreenHeight;
47
    private boolean mFinishRotation, mFinishDragCurrent, mFinishDragAccumulated;
48
    private RubikCube mCube;
75 49

  
76 50
///////////////////////////////////////////////////////////////////////////////////////////////////
77 51

  
......
80 54
      mView = v;
81 55

  
82 56
      mScreen = new DistortedScreen();
83
      mScreen.setProjection(90.0f, 0.1f);
84 57

  
85 58
      mTempCurrent     = new Static4D(0,0,0,1);
86 59
      mTempAccumulated = initializeQuat();
87 60
      mQuatCurrent     = new Static4D(0,0,0,1);
88 61
      mQuatAccumulated = initializeQuat();
89 62

  
90
      mCubes = new MeshCubes[NUM_CUBES][NUM_CUBES][NUM_CUBES];
91
      mEffects = new DistortedEffects[NUM_CUBES][NUM_CUBES][NUM_CUBES];
92
      Static3D[][][] cubeVectors = new Static3D[NUM_CUBES][NUM_CUBES][NUM_CUBES];
93

  
94
      mQuatScramble   = new Static4D[NUM_CUBES][NUM_CUBES][NUM_CUBES];
95
      mRotationAxis   = new Static3D[NUM_CUBES][NUM_CUBES][NUM_CUBES];
96
      mRotationAngle  = new Dynamic1D[NUM_CUBES][NUM_CUBES][NUM_CUBES];
97
      mCurrentPosition= new Static3D[NUM_CUBES][NUM_CUBES][NUM_CUBES];
98

  
99
      float sinkDegree = 3.0f - 1.8f/NUM_CUBES; // f(1)=1.2, f(inf)=3
100

  
101
      VertexEffectSink sink = new VertexEffectSink( new Static1D(sinkDegree),
102
                                                    new Static3D(SIZE*0.5f, SIZE*0.5f, SIZE*0.5f),
103
                                                    new Static4D(0,0,0, SIZE*0.72f) );
104 63
      mMove  = new Static3D(0,0,0);
105 64
      mScale = new Static3D(1,1,1);
106
      mCenter= new Static3D(0,0,0);
107

  
108
      mRotationAngleStatic = new Static1D(0);
109
      mRotAxis= RubikSurfaceView.VECTN;
110

  
111
      MatrixEffectMove       move  = new MatrixEffectMove(mMove);
112
      MatrixEffectScale      scale = new MatrixEffectScale(mScale);
113
      MatrixEffectQuaternion quat1 = new MatrixEffectQuaternion(mQuatCurrent    , mCenter);
114
      MatrixEffectQuaternion quat2 = new MatrixEffectQuaternion(mQuatAccumulated, mCenter);
115

  
116
      // 3x2 bitmap = 6 squares:
117
      //
118
      // RED     GREEN   BLUE
119
      // YELLOW  WHITE   BROWN
120

  
121
      final float ze = 0.0f;
122
      final float ot = 1.0f/3.0f;
123
      final float tt = 2.0f/3.0f;
124
      final float oh = 1.0f/2.0f;
125
      final float of = 1.0f/40.0f;
126

  
127
      final Static4D mapFront = new Static4D(ze,oh, ze+ot,oh+oh);
128
      final Static4D mapBack  = new Static4D(tt,ze, tt+ot,ze+oh);
129
      final Static4D mapLeft  = new Static4D(ot,ze, ot+ot,ze+oh);
130
      final Static4D mapRight = new Static4D(ze,ze, ze+ot,ze+oh);
131
      final Static4D mapTop   = new Static4D(tt,oh, tt+ot,oh+oh);
132
      final Static4D mapBottom= new Static4D(ot,oh, ot+ot,oh+oh);
133

  
134
      final Static4D mapBlack = new Static4D(ze,ze, ze+of,ze+of);
135

  
136
      Static4D tmpFront, tmpBack, tmpLeft, tmpRight, tmpTop, tmpBottom;
137
      float nc = 0.5f*(NUM_CUBES-1);
138
      int vertices = (int)(24.0f/NUM_CUBES + 2.0f);
139

  
140
      for(int x = 0; x< NUM_CUBES; x++)
141
        for(int y = 0; y< NUM_CUBES; y++)
142
          for(int z = 0; z< NUM_CUBES; z++)
143
            {
144
            if( x==0 || x==NUM_CUBES-1 || y==0 || y==NUM_CUBES-1 || z==0 || z==NUM_CUBES-1 ) // only the external walls
145
              {
146
              tmpLeft  = (x==            0 ? mapLeft  :mapBlack);
147
              tmpRight = (x== NUM_CUBES -1 ? mapRight :mapBlack);
148
              tmpFront = (z== NUM_CUBES -1 ? mapFront :mapBlack);
149
              tmpBack  = (z==            0 ? mapBack  :mapBlack);
150
              tmpTop   = (y== NUM_CUBES -1 ? mapTop   :mapBlack);
151
              tmpBottom= (y==            0 ? mapBottom:mapBlack);
152

  
153
              mCubes[x][y][z]           = new MeshCubes(vertices,vertices,vertices, tmpFront, tmpBack, tmpLeft, tmpRight, tmpTop, tmpBottom);
154
              cubeVectors[x][y][z]      = new Static3D( SIZE*(x-nc), SIZE*(y-nc), SIZE*(z-nc) );
155
              mQuatScramble[x][y][z]    = new Static4D(0,0,0,1);
156
              mRotationAngle[x][y][z]   = new Dynamic1D();
157
              mRotationAxis[x][y][z]    = new Static3D(1,0,0);
158
              mCurrentPosition[x][y][z] = new Static3D(x,y,z);
159

  
160
              mEffects[x][y][z] = new DistortedEffects();
161
              mEffects[x][y][z].apply(sink);
162
              mEffects[x][y][z].apply(move);
163
              mEffects[x][y][z].apply(scale);
164
              mEffects[x][y][z].apply(quat1);
165
              mEffects[x][y][z].apply(quat2);
166
              mEffects[x][y][z].apply( new MatrixEffectRotate( mRotationAngle[x][y][z], mRotationAxis[x][y][z], mCenter));
167
              mEffects[x][y][z].apply( new MatrixEffectQuaternion(mQuatScramble[x][y][z], mCenter));
168
              mEffects[x][y][z].apply( new MatrixEffectMove(cubeVectors[x][y][z]) );
169
              }
170
            }
65

  
66
      mFinishRotation        = false;
67
      mFinishDragCurrent     = false;
68
      mFinishDragAccumulated = false;
69

  
70
      mCube = new RubikCube(NUM_CUBES, mMove, mScale, mQuatCurrent, mQuatAccumulated);
171 71
      }
172 72

  
173 73
///////////////////////////////////////////////////////////////////////////////////////////////////
......
176 76
      {
177 77
      mScreen.render( System.currentTimeMillis() );
178 78

  
179
      mQuatCurrent.set(mTempCurrent);
180
      mQuatAccumulated.set(mTempAccumulated);
79
      if( mFinishDragCurrent )
80
        {
81
        mFinishDragCurrent = false;
82
        mQuatCurrent.set(mTempCurrent);
83
        }
84

  
85
      if( mFinishDragAccumulated )
86
        {
87
        mFinishDragAccumulated = false;
88
        mQuatAccumulated.set(mTempAccumulated);
89
        }
90

  
91
      if( mFinishRotation )
92
        {
93
        mFinishRotation=false;
94
        mCube.finishRotationCalledOnNextRender();
95
        }
181 96
      }
182 97

  
183 98
///////////////////////////////////////////////////////////////////////////////////////////////////
184 99
    
185 100
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
186 101
      {
102
      mScreen.setProjection( width>height ? 60.0f : 90.0f, 0.1f);
103

  
187 104
      mScreenWidth = width;
188 105
      mScreenHeight= height;
189
      mScreenMin = width<height ? width:height;
190 106

  
191
      float w = mTexture.getWidth();
192
      float h = mTexture.getHeight();
193
      float d = mTexture.getDepth(mCubes[0][0][0]);
107
      float w = mCube.getWidth();
108
      float h = mCube.getHeight();
109
      float d = mCube.getDepth();
194 110

  
195
      float factor = CUBE_SCREEN_RATIO*(width>height ? height/h:width/w)/ NUM_CUBES;
111
      mScaleFactor = CUBE_SCREEN_RATIO*(width>height ? height/h:width/w)/ NUM_CUBES;
196 112

  
197
      mCenter.set(w/2,h/2,d/2);
198
      mMove.set( (width-factor*w)/2 , (height-factor*h)/2 , -factor*d/2 );
199
      mScale.set(factor,factor,factor);
113
      mMove.set( (width-mScaleFactor*w)/2 , (height-mScaleFactor*h)/2 , -mScaleFactor*d/2 );
114
      mScale.set(mScaleFactor,mScaleFactor,mScaleFactor);
200 115

  
201 116
      mScreen.resize(width, height);
202 117
      }
......
205 120
    
206 121
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
207 122
      {
208
      Bitmap bitmap;
209

  
210
      final int S = 128;
211
      final int W = 3*S;
212
      final int H = 2*S;
213
      final int R = S/10;
214
      final int M = S/20;
215

  
216
      Paint paint = new Paint();
217
      bitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888);
218
      Canvas canvas = new Canvas(bitmap);
219

  
220
      paint.setAntiAlias(true);
221
      paint.setTextAlign(Paint.Align.CENTER);
222
      paint.setStyle(Paint.Style.FILL);
223

  
224
      // 3x2 bitmap = 6 squares:
225
      //
226
      // RED     GREEN   BLUE
227
      // YELLOW  WHITE   BROWN
228

  
229
      paint.setColor(0xff000000);                                  // BLACK BACKGROUND
230
      canvas.drawRect(0, 0, W, H, paint);                          //
231

  
232
      paint.setColor(0xffff0000);                                  // RED
233
      canvas.drawRoundRect(    M,   M,   S-M,   S-M, R, R, paint); //
234
      paint.setColor(0xff00ff00);                                  // GREEN
235
      canvas.drawRoundRect(  S+M,   M, 2*S-M,   S-M, R, R, paint); //
236
      paint.setColor(0xff0000ff);                                  // BLUE
237
      canvas.drawRoundRect(2*S+M,   M, 3*S-M,   S-M, R, R, paint); //
238
      paint.setColor(0xffffff00);                                  // YELLOW
239
      canvas.drawRoundRect(    M, S+M,   S-M, 2*S-M, R, R, paint); //
240
      paint.setColor(0xffffffff);                                  // WHITE
241
      canvas.drawRoundRect(  S+M, S+M, 2*S-M, 2*S-M, R, R, paint); //
242
      paint.setColor(0xffb5651d);                                  // BROWN
243
      canvas.drawRoundRect(2*S+M, S+M, 3*S-M, 2*S-M, R, R, paint); //
244

  
245
      if( mTexture==null ) mTexture = new DistortedTexture(SIZE,SIZE);
246
      mTexture.setTexture(bitmap);
247

  
123
      mCube.createTexture();
248 124
      mScreen.detachAll();
249

  
250
      for(int x = 0; x< NUM_CUBES; x++)
251
        for(int y = 0; y< NUM_CUBES; y++)
252
          for(int z = 0; z< NUM_CUBES; z++)
253
            if( x==0 || x==NUM_CUBES-1 || y==0 || y==NUM_CUBES-1 || z==0 || z==NUM_CUBES-1 ) // only the external walls
254
              {
255
              mScreen.attach(mTexture,mEffects[x][y][z],mCubes[x][y][z]);
256
              }
125
      mCube.attachToScreen(mScreen);
257 126

  
258 127
      VertexEffectSink.enable();
259 128

  
......
267 136
        }
268 137
      }
269 138

  
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140
// no this will not race with onDrawFrame
141

  
142
    void finishRotation()
143
      {
144
      mFinishRotation = true;
145
      }
146

  
270 147
///////////////////////////////////////////////////////////////////////////////////////////////////
271 148

  
272 149
    float returnCameraDistance()
......
279 156
      }
280 157

  
281 158
///////////////////////////////////////////////////////////////////////////////////////////////////
282
// NUM_CUBES individual little cubes, each SIZE in size, times 'scaleFactor' (see onSurfaceChanged)
159
// NUM_CUBES individual little cubes, each TEXTURE_SIZE in size, times 'scaleFactor' (see onSurfaceChanged)
283 160

  
284 161
    float returnCubeSize()
285 162
      {
286
      float w = mTexture.getWidth();
287
      float h = mTexture.getHeight();
288
      float max = (mScreenWidth>mScreenHeight ? mScreenHeight/h:mScreenWidth/w);
289
      float scaleFactor = CUBE_SCREEN_RATIO*max/NUM_CUBES;
290

  
291
      return scaleFactor*NUM_CUBES*SIZE;
292
      }
293

  
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295

  
296
    void addNewRotation(int vector, int row )
297
      {
298
      Static3D axis = VectX;
299

  
300
      switch(vector)
301
        {
302
        case RubikSurfaceView.VECTX: axis = VectX; break;
303
        case RubikSurfaceView.VECTY: axis = VectY; break;
304
        case RubikSurfaceView.VECTZ: axis = VectZ; break;
305
        }
306

  
307
      mRotAxis = vector;
308
      mRotRow  = row;
309

  
310
      mRotationAngleStatic.set1(0.0f);
311

  
312
      for(int x = 0; x< NUM_CUBES; x++)
313
        for(int y = 0; y< NUM_CUBES; y++)
314
          for(int z = 0; z< NUM_CUBES; z++)
315
            if( x==0 || x==NUM_CUBES-1 || y==0 || y==NUM_CUBES-1 || z==0 || z==NUM_CUBES-1 )
316
              {
317
              if( belongsToRotation(x,y,z,vector,row) )
318
                {
319
                mRotationAxis[x][y][z].set(axis);
320
                mRotationAngle[x][y][z].add(mRotationAngleStatic);
321
                }
322
              }
323
      }
324

  
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

  
327
    void continueRotation(float angle)
328
      {
329
      mRotationAngleStatic.set1(200.0f*angle/mScreenMin);
330
      }
331

  
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

  
334
    void finishRotation()
335
      {
336
      float nearestAngle = (mRotationAngleStatic.get1()+45.0f)/90.0f;
337
      if( nearestAngle<0 ) nearestAngle-=1.0f;
338
      int nearestAngleInDegrees = 90*(4-((int)nearestAngle+4)%4);
339
      double nearestAngleInRadians = nearestAngleInDegrees*Math.PI/180;
340
      float sinA = (float)Math.sin(nearestAngleInRadians*0.5);
341
      float cosA = (float)Math.cos(nearestAngleInRadians*0.5);
342

  
343
      mRotationAngleStatic.set1(0);
344

  
345
      float qx=0,qy=0,qz=0;
346

  
347
      switch(mRotAxis)
348
        {
349
        case RubikSurfaceView.VECTX: qx=1; break;
350
        case RubikSurfaceView.VECTY: qy=1; break;
351
        case RubikSurfaceView.VECTZ: qz=1; break;
352
        }
353

  
354
      Static4D quat = new Static4D(qx*sinA, qy*sinA, qz*sinA, cosA);
355

  
356
      for(int x = 0; x< NUM_CUBES; x++)
357
        for(int y = 0; y< NUM_CUBES; y++)
358
          for(int z = 0; z< NUM_CUBES; z++)
359
            if( x==0 || x==NUM_CUBES-1 || y==0 || y==NUM_CUBES-1 || z==0 || z==NUM_CUBES-1 )
360
              {
361
              if( belongsToRotation(x,y,z,mRotAxis,mRotRow) )
362
                {
363
                mRotationAngle[x][y][z].removeAll();
364
                mQuatScramble[x][y][z].set(RubikSurfaceView.quatMultiply(quat,mQuatScramble[x][y][z]));
365
                modifyCurrentPosition(x,y,z,quat);
366
                }
367
              }
163
      return mScaleFactor*NUM_CUBES*RubikCube.TEXTURE_SIZE;
368 164
      }
369 165

  
370 166
///////////////////////////////////////////////////////////////////////////////////////////////////
371 167

  
372
    private boolean belongsToRotation(int x, int y, int z, int vector, int row)
168
    float getScreenWidth()
373 169
      {
374
      switch(vector)
375
        {
376
        case RubikSurfaceView.VECTX: return mCurrentPosition[x][y][z].get1()==row;
377
        case RubikSurfaceView.VECTY: return mCurrentPosition[x][y][z].get2()==row;
378
        case RubikSurfaceView.VECTZ: return mCurrentPosition[x][y][z].get3()==row;
379
        }
380

  
381
      return false;
170
      return mScreenWidth;
382 171
      }
383 172

  
384 173
///////////////////////////////////////////////////////////////////////////////////////////////////
385 174

  
386
    private void modifyCurrentPosition(int x, int y, int z, Static4D quat)
175
    float getScreenHeight()
387 176
      {
388
      Static3D current = mCurrentPosition[x][y][z];
389
      float beforeX = current.get1();
390
      float beforeY = current.get2();
391
      float beforeZ = current.get3();
392

  
393
      float diff = 0.5f*(NUM_CUBES-1);
394

  
395
      float cubitCenterX = beforeX - diff;
396
      float cubitCenterY = beforeY - diff;
397
      float cubitCenterZ = beforeZ - diff;
398

  
399
      Static4D cubitCenter =  new Static4D(cubitCenterX, cubitCenterY, cubitCenterZ, 0);
400
      Static4D rotatedCenter = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat);
401

  
402
      float rotatedX = rotatedCenter.get1() + diff;
403
      float rotatedY = rotatedCenter.get2() + diff;
404
      float rotatedZ = rotatedCenter.get3() + diff;
405

  
406
      int roundedX = (int)(rotatedX+0.1f);
407
      int roundedY = (int)(rotatedY+0.1f);
408
      int roundedZ = (int)(rotatedZ+0.1f);
409

  
410
      //android.util.Log.e("rubik", "before: ("+((int)beforeX)+","+((int)beforeY)+","+((int)beforeZ)+") after: ("+roundedX+","+roundedY+","+roundedZ+")");
411

  
412
      mCurrentPosition[x][y][z].set1(roundedX);
413
      mCurrentPosition[x][y][z].set2(roundedY);
414
      mCurrentPosition[x][y][z].set3(roundedZ);
177
      return mScreenHeight;
415 178
      }
416 179

  
417 180
///////////////////////////////////////////////////////////////////////////////////////////////////
418 181

  
419
    float getScreenWidth()
182
    RubikCube getCube()
420 183
      {
421
      return mScreenWidth;
184
      return mCube;
422 185
      }
423 186

  
424 187
///////////////////////////////////////////////////////////////////////////////////////////////////
425 188

  
426
    float getScreenHeight()
189
    int getScreenMin()
427 190
      {
428
      return mScreenHeight;
191
      return mScreenWidth<mScreenHeight ? mScreenWidth:mScreenHeight;
429 192
      }
430 193

  
431 194
///////////////////////////////////////////////////////////////////////////////////////////////////
......
441 204
    void setQuatCurrent(Static4D current)
442 205
      {
443 206
      mTempCurrent.set(current);
207
      mFinishDragCurrent = true;
444 208
      }
445 209

  
446 210
///////////////////////////////////////////////////////////////////////////////////////////////////
......
448 212
    void setQuatAccumulated(Static4D accumulated)
449 213
      {
450 214
      mTempAccumulated.set(accumulated);
215
      mFinishDragAccumulated = true;
451 216
      }
452 217
}
src/main/java/org/distorted/examples/rubik/RubikSurfaceView.java
1 1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
2
// Copyright 2019 Leszek Koltunski                                                               //
3 3
//                                                                                               //
4 4
// This file is part of Distorted.                                                               //
5 5
//                                                                                               //
......
54 54
    private Static4D mQuatCurrent, mQuatAccumulated;
55 55
    private int mRotationVect;
56 56
    private RubikRenderer mRenderer;
57
    private RubikCube mCube;
57 58

  
58 59
    private float mPoiX, mPoiY, mPoiZ, mCamX, mCamY, mCamZ;
59 60
    private float mStartX, mStartY, mStartZ;
......
70 71
      mRotationVect = VECTN;
71 72

  
72 73
      mRenderer = new RubikRenderer(this);
74
      mCube = mRenderer.getCube();
73 75

  
74 76
      mQuatCurrent     = new Static4D(0,0,0,1);
75 77
      mQuatAccumulated = mRenderer.initializeQuat();
......
113 115
                                         }
114 116
                                       else if( mRotating )
115 117
                                         {
116
                                         int minimumToRotate = (mRenderer.mScreenMin*mRenderer.mScreenMin)/36;
118
                                         int screenMin = mRenderer.getScreenMin();
119
                                         int minimumToRotate = (screenMin*screenMin)/64;
117 120

  
118 121
                                         if( (mX-x)*(mX-x)+(mY-y)*(mY-y)>minimumToRotate )
119 122
                                           {
......
191 194
      mStartY = diffY + mStartY;
192 195
      mStartZ = diffZ + mStartZ;
193 196

  
194
      mRenderer.addNewRotation(mRotationVect,row);
197
      mCube.addNewRotation(mRotationVect,row);
195 198
      }
196 199

  
197 200
///////////////////////////////////////////////////////////////////////////////////////////////////
......
241 244
      float dY = mY-y;
242 245
      float calibration = (float)Math.sqrt(dX*dX+dY*dY);
243 246

  
244
      mRenderer.continueRotation(calibration*sign);
247
      mCube.continueRotation(calibration*sign, mRenderer.getScreenMin());
245 248
      }
246 249

  
247 250
///////////////////////////////////////////////////////////////////////////////////////////////////
......
249 252
    private void finishRotation()
250 253
      {
251 254
      mRotationVect = VECTN;
252

  
253 255
      mRenderer.finishRotation();
254 256
      }
255 257

  
......
339 341
        axisY /= axisL;
340 342
        axisZ /= axisL;
341 343

  
342
        float cosA = (float)Math.cos(axisL*Math.PI/mRenderer.mScreenMin);
344
        float cosA = (float)Math.cos(axisL*Math.PI/mRenderer.getScreenMin());
343 345
        float sinA = (float)Math.sqrt(1-cosA*cosA);
344 346

  
345 347
        return new Static4D(axisX*sinA, axisY*sinA, axisZ*sinA, cosA);

Also available in: Unified diff