Project

General

Profile

« Previous | Next » 

Revision 3c4a326c

Added by Leszek Koltunski about 4 years ago

More work on making new types of RubikObjects easily creatable.

View differences:

src/main/java/org/distorted/object/RubikCubeMovement.java
19 19

  
20 20
package org.distorted.object;
21 21

  
22
import org.distorted.library.type.Static2D;
23 22
import org.distorted.library.type.Static4D;
24 23

  
25
import static org.distorted.object.RubikObjectList.VECTX;
26
import static org.distorted.object.RubikObjectList.VECTY;
27
import static org.distorted.object.RubikObjectList.VECTZ;
28

  
29 24
///////////////////////////////////////////////////////////////////////////////////////////////////
30 25

  
31 26
class RubikCubeMovement extends RubikObjectMovement
32 27
{
33 28
    private final static int NONE   =-1;
34
    private final static int FRONT  = 0;  // has to be 6 consecutive ints
35
    private final static int BACK   = 1;  // FRONT ... BOTTOM
36
    private final static int LEFT   = 2;  //
37
    private final static int RIGHT  = 3;  //
29
    private final static int FRONT  = 0;  //
30
    private final static int BACK   = 1;  //
31
    private final static int LEFT   = 2;  // has to be 6 consecutive ints
32
    private final static int RIGHT  = 3;  // FRONT ... BOTTOM
38 33
    private final static int TOP    = 4;  //
39 34
    private final static int BOTTOM = 5;  //
40 35

  
36
    private static final int VECTX  = 0;  //
37
    private static final int VECTY  = 1;  // don't change this
38
    private static final int VECTZ  = 2;  //
39

  
41 40
    private static final int[] VECT = {VECTX,VECTY,VECTZ};
42 41

  
43 42
    private float[] mPoint, mCamera, mDiff, mTouch;
......
192 191

  
193 192
///////////////////////////////////////////////////////////////////////////////////////////////////
194 193

  
195
    public Static2D newRotation(Static4D rotatedTouchPoint)
194
    public Static4D newRotation(Static4D rotatedTouchPoint)
196 195
      {
197 196
      float cubeHalfSize= RubikObject.OBJECT_SCREEN_RATIO*0.5f;
198 197

  
......
215 214
      mTouch[1] = mPoint[1];
216 215
      mTouch[2] = mPoint[2];
217 216

  
218
      return new Static2D(mRotationVect,offset);
217
      Static4D result=null;
218

  
219
      switch(mRotationVect)
220
        {
221
        case VECTX: result = new Static4D(1,0,0,offset); break;
222
        case VECTY: result = new Static4D(0,1,0,offset); break;
223
        case VECTZ: result = new Static4D(0,0,1,offset); break;
224
        }
225

  
226
      return result;
219 227
      }
220 228

  
221 229
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff