Project

General

Profile

« Previous | Next » 

Revision 27a70eae

Added by Leszek Koltunski about 4 years ago

Make RubikCube and RubikCubeMovement generic and not visible outside of their package.

View differences:

src/main/java/org/distorted/object/RubikCubeMovement.java
22 22
import org.distorted.library.type.Static2D;
23 23
import org.distorted.library.type.Static4D;
24 24

  
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

  
25 29
///////////////////////////////////////////////////////////////////////////////////////////////////
26 30

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

  
37
    private static final int[] VECT = {RubikCube.VECTX,RubikCube.VECTY,RubikCube.VECTZ};
41
    private static final int[] VECT = {VECTX,VECTY,VECTZ};
38 42

  
39 43
    private float[] mPoint, mCamera, mDiff, mTouch;
40 44
    private int mRotationVect, mLastTouchedFace;
......
70 74
      switch(face)
71 75
        {
72 76
        case FRONT :
73
        case BACK  : return RubikCube.VECTX;
77
        case BACK  : return VECTX;
74 78
        case LEFT  :
75
        case RIGHT : return RubikCube.VECTZ;
79
        case RIGHT : return VECTZ;
76 80
        case TOP   :
77
        case BOTTOM: return RubikCube.VECTX;
81
        case BOTTOM: return VECTX;
78 82
        }
79 83

  
80 84
      return -1;
......
87 91
      switch(face)
88 92
        {
89 93
        case FRONT :
90
        case BACK  : return RubikCube.VECTY;
94
        case BACK  : return VECTY;
91 95
        case LEFT  :
92
        case RIGHT : return RubikCube.VECTY;
96
        case RIGHT : return VECTY;
93 97
        case TOP   :
94
        case BOTTOM: return RubikCube.VECTZ;
98
        case BOTTOM: return VECTZ;
95 99
        }
96 100

  
97 101
      return -1;
......
104 108
      switch(face)
105 109
        {
106 110
        case FRONT :
107
        case BACK  : return RubikCube.VECTZ;
111
        case BACK  : return VECTZ;
108 112
        case LEFT  :
109
        case RIGHT : return RubikCube.VECTX;
113
        case RIGHT : return VECTX;
110 114
        case TOP   :
111
        case BOTTOM: return RubikCube.VECTY;
115
        case BOTTOM: return VECTY;
112 116
        }
113 117

  
114 118
      return -1;
......
142 146
      output[2] = (mPoint[2]-mCamera[2])*ratio + mCamera[2];
143 147
      }
144 148

  
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146
// PUBLIC API
147 149
///////////////////////////////////////////////////////////////////////////////////////////////////
148 150

  
149
    public RubikCubeMovement()
151
    RubikCubeMovement()
150 152
      {
151 153
      mPoint = new float[3];
152 154
      mCamera= new float[3];
......
154 156
      mTouch = new float[3];
155 157
      }
156 158

  
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160
// PUBLIC API
157 161
///////////////////////////////////////////////////////////////////////////////////////////////////
158 162

  
159 163
    public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera)
160 164
      {
161
      float cubeHalfSize= RubikCube.CUBE_SCREEN_RATIO*0.5f;
165
      float cubeHalfSize= RubikObject.OBJECT_SCREEN_RATIO*0.5f;
162 166

  
163 167
      mPoint[0]  = rotatedTouchPoint.get0();
164 168
      mPoint[1]  = rotatedTouchPoint.get1();
......
190 194

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

  
195 199
      mPoint[0] = rotatedTouchPoint.get0();
196 200
      mPoint[1] = rotatedTouchPoint.get1();

Also available in: Unified diff