Revision 1dd8d3af
Added by Leszek Koltunski about 4 years ago
| src/main/java/org/distorted/objects/TwistyRedi.java | ||
|---|---|---|
| 37 | 37 | 
     | 
| 38 | 38 | 
    public class TwistyRedi extends TwistyObject  | 
| 39 | 39 | 
    {
   | 
| 40 | 
    private static final int FACES_PER_CUBIT =9;  | 
|
| 41 | 
     | 
|
| 42 | 
    // the four rotation axis of a RubikRedi. Must be normalized.  | 
|
| 40 | 
    // the four rotation axis of a Redi. Must be normalized.  | 
|
| 43 | 41 | 
    static final Static3D[] ROT_AXIS = new Static3D[]  | 
| 44 | 42 | 
             {
   | 
| 45 | 43 | 
    new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),  | 
| ... | ... | |
| 48 | 46 | 
    new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)  | 
| 49 | 47 | 
    };  | 
| 50 | 48 | 
     | 
| 51 | 
      private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
   | 
|
| 52 | 
     | 
|
| 53 | 49 | 
    private static final int[] FACE_COLORS = new int[]  | 
| 54 | 50 | 
             {
   | 
| 55 | 51 | 
    COLOR_YELLOW, COLOR_WHITE,  | 
| ... | ... | |
| 57 | 53 | 
    COLOR_RED , COLOR_ORANGE  | 
| 58 | 54 | 
    };  | 
| 59 | 55 | 
     | 
| 60 | 
    // All legal rotation quats of a RubikRedi  | 
|
| 61 | 
    private static final Static4D[] QUATS = new Static4D[]  | 
|
| 62 | 
             {
   | 
|
| 63 | 
    new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),  | 
|
| 64 | 
    new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),  | 
|
| 65 | 
    new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),  | 
|
| 66 | 
    new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),  | 
|
| 67 | 
     | 
|
| 68 | 
    new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ),  | 
|
| 69 | 
    new Static4D( 0.5f, 0.5f, 0.5f, -0.5f ),  | 
|
| 70 | 
    new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ),  | 
|
| 71 | 
    new Static4D( 0.5f, 0.5f, -0.5f, -0.5f ),  | 
|
| 72 | 
    new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ),  | 
|
| 73 | 
    new Static4D( 0.5f, -0.5f, 0.5f, -0.5f ),  | 
|
| 74 | 
    new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ),  | 
|
| 75 | 
    new Static4D( 0.5f, -0.5f, -0.5f, -0.5f )  | 
|
| 76 | 
    };  | 
|
| 77 | 
     | 
|
| 78 | 
    private static final float DIST_CORNER = 1.0f;  | 
|
| 79 | 
    private static final float DIST_EDGE = 1.5f;  | 
|
| 80 | 
     | 
|
| 81 | 
    // centers of the 8 corners + 12 edges ( i.e. of the all 20 cubits)  | 
|
| 82 | 
    private static final float[][] CENTERS = new float[][]  | 
|
| 83 | 
             {
   | 
|
| 84 | 
                 { DIST_CORNER, DIST_CORNER, DIST_CORNER },
   | 
|
| 85 | 
                 { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
   | 
|
| 86 | 
                 { DIST_CORNER,-DIST_CORNER, DIST_CORNER },
   | 
|
| 87 | 
                 { DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
   | 
|
| 88 | 
                 {-DIST_CORNER, DIST_CORNER, DIST_CORNER },
   | 
|
| 89 | 
                 {-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
   | 
|
| 90 | 
                 {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
   | 
|
| 91 | 
                 {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
   | 
|
| 92 | 
     | 
|
| 93 | 
                 {      0.0f, DIST_EDGE, DIST_EDGE },
   | 
|
| 94 | 
                 { DIST_EDGE,      0.0f, DIST_EDGE },
   | 
|
| 95 | 
                 {      0.0f,-DIST_EDGE, DIST_EDGE },
   | 
|
| 96 | 
                 {-DIST_EDGE,      0.0f, DIST_EDGE },
   | 
|
| 97 | 
                 { DIST_EDGE, DIST_EDGE,      0.0f },
   | 
|
| 98 | 
                 { DIST_EDGE,-DIST_EDGE,      0.0f },
   | 
|
| 99 | 
                 {-DIST_EDGE,-DIST_EDGE,      0.0f },
   | 
|
| 100 | 
                 {-DIST_EDGE, DIST_EDGE,      0.0f },
   | 
|
| 101 | 
                 {      0.0f, DIST_EDGE,-DIST_EDGE },
   | 
|
| 102 | 
                 { DIST_EDGE,      0.0f,-DIST_EDGE },
   | 
|
| 103 | 
                 {      0.0f,-DIST_EDGE,-DIST_EDGE },
   | 
|
| 104 | 
                 {-DIST_EDGE,      0.0f,-DIST_EDGE }
   | 
|
| 105 | 
    };  | 
|
| 106 | 
     | 
|
| 107 | 
    // Colors of the faces of cubits.  | 
|
| 108 | 
    // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5  | 
|
| 109 | 
    // YELLOW 6 WHITE 7 BLUE 8 GREEN 9 RED 10 ORANGE 11  | 
|
| 110 | 
    private static final int[][] mFaceMap = new int[][]  | 
|
| 111 | 
             {
   | 
|
| 112 | 
               {  4, 2, 0 },
   | 
|
| 113 | 
               {  2, 5, 0 },
   | 
|
| 114 | 
               {  3, 4, 0 },
   | 
|
| 115 | 
               {  5, 3, 0 },
   | 
|
| 116 | 
               {  1, 2, 4 },
   | 
|
| 117 | 
               {  5, 2, 1 },
   | 
|
| 118 | 
               {  4, 3, 1 },
   | 
|
| 119 | 
               {  1, 3, 5 },
   | 
|
| 120 | 
     | 
|
| 121 | 
               { 10, 8,12 },
   | 
|
| 122 | 
               {  6,10,12 },
   | 
|
| 123 | 
               { 10, 9,12 },
   | 
|
| 124 | 
               {  7,10,12 },
   | 
|
| 125 | 
               {  8, 6,12 },
   | 
|
| 126 | 
               {  9, 6,12 },
   | 
|
| 127 | 
               {  9, 7,12 },
   | 
|
| 128 | 
               {  8, 7,12 },
   | 
|
| 129 | 
               { 11, 8,12 },
   | 
|
| 130 | 
               {  6,11,12 },
   | 
|
| 131 | 
               { 11, 9,12 },
   | 
|
| 132 | 
               {  7,11,12 },
   | 
|
| 133 | 
    };  | 
|
| 134 | 
     | 
|
| 135 | 
    private static final double[][] VERTICES_CORNER = new double[][]  | 
|
| 136 | 
              {
   | 
|
| 137 | 
                 { 0.0f, 0.0f, 0.0f },
   | 
|
| 138 | 
                 {-0.5f, 0.5f, 0.5f },
   | 
|
| 139 | 
                 {-0.5f,-0.5f, 0.5f },
   | 
|
| 140 | 
                 { 0.5f, 0.5f, 0.5f },
   | 
|
| 141 | 
                 { 0.5f,-0.5f, 0.5f },
   | 
|
| 142 | 
                 { 0.5f, 0.5f,-0.5f },
   | 
|
| 143 | 
                 { 0.5f,-0.5f,-0.5f },
   | 
|
| 144 | 
                 {-0.5f, 0.5f,-0.5f },
   | 
|
| 145 | 
    };  | 
|
| 146 | 
     | 
|
| 147 | 
    private static final int[][] VERT_INDEXES_CORNER = new int[][]  | 
|
| 148 | 
              {
   | 
|
| 149 | 
                 { 2,4,3,1 },
   | 
|
| 150 | 
                 { 1,3,5,7 },
   | 
|
| 151 | 
                 { 4,6,5,3 },
   | 
|
| 152 | 
     | 
|
| 153 | 
                 { 2,4,0 },
   | 
|
| 154 | 
                 { 5,7,0 },
   | 
|
| 155 | 
                 { 4,6,0 },
   | 
|
| 156 | 
                 { 7,1,0 },
   | 
|
| 157 | 
                 { 1,2,0 },
   | 
|
| 158 | 
                 { 6,5,0 }
   | 
|
| 159 | 
    };  | 
|
| 160 | 
     | 
|
| 161 | 
    private static final double[][] VERTICES_EDGE = new double[][]  | 
|
| 162 | 
              {
   | 
|
| 163 | 
                 {-0.5f, 0.0f, 0.0f},
   | 
|
| 164 | 
                 { 0.5f, 0.0f, 0.0f},
   | 
|
| 165 | 
                 {-0.5f,-1.0f, 0.0f},
   | 
|
| 166 | 
                 { 0.5f,-1.0f, 0.0f},
   | 
|
| 167 | 
                 { 0.0f,-1.5f, 0.0f},
   | 
|
| 168 | 
                 {-0.5f, 0.0f,-1.0f},
   | 
|
| 169 | 
                 { 0.5f, 0.0f,-1.0f},
   | 
|
| 170 | 
                 { 0.0f, 0.0f,-1.5f},
   | 
|
| 171 | 
    };  | 
|
| 172 | 
     | 
|
| 173 | 
    private static final int[][] VERT_INDEXES_EDGE = new int[][]  | 
|
| 174 | 
              {
   | 
|
| 175 | 
                 { 0,2,4,3,1 },
   | 
|
| 176 | 
                 { 0,1,6,7,5 },
   | 
|
| 177 | 
                 { 1,3,6 },
   | 
|
| 178 | 
                 { 0,2,5 },
   | 
|
| 179 | 
                 { 4,7,6,3 },
   | 
|
| 180 | 
                 { 4,7,5,2 }
   | 
|
| 181 | 
    };  | 
|
| 182 | 
     | 
|
| 183 | 
    private static final float[][] STICKERS = new float[][]  | 
|
| 184 | 
              {
   | 
|
| 185 | 
                 { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f },
   | 
|
| 186 | 
                 { -0.3125f, 0.4375f, -0.3125f, -0.1875f, 0.0f, -0.5f, 0.3125f, -0.1875f, 0.3125f, 0.4375f }
   | 
|
| 187 | 
    };  | 
|
| 188 | 
     | 
|
| 189 | 
    private static final ObjectSticker[] mStickers;  | 
|
| 190 | 
     | 
|
| 191 | 
    static  | 
|
| 192 | 
        {
   | 
|
| 193 | 
    mStickers = new ObjectSticker[STICKERS.length];  | 
|
| 194 | 
    final float R0 = 0.09f;  | 
|
| 195 | 
    final float R1 = 0.06f;  | 
|
| 196 | 
        final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1,R1} };
   | 
|
| 197 | 
        final float[] strokes = { 0.09f,0.06f };
   | 
|
| 198 | 
     | 
|
| 199 | 
    for(int s=0; s<STICKERS.length; s++)  | 
|
| 200 | 
          {
   | 
|
| 201 | 
    mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);  | 
|
| 202 | 
    }  | 
|
| 203 | 
    }  | 
|
| 56 | 
    private static final int FACES_PER_CUBIT =9;  | 
|
| 204 | 57 | 
     | 
| 205 | 58 | 
    private int mCurrState;  | 
| 206 | 59 | 
    private int mIndexExcluded;  | 
| 207 | 60 | 
    private final ScrambleState[] mStates;  | 
| 208 | 61 | 
    private int[][] mScrambleTable;  | 
| 209 | 62 | 
    private int[] mNumOccurences;  | 
| 63 | 
    private int[] mBasicAngle;  | 
|
| 64 | 
    private Static4D[] mQuats;  | 
|
| 65 | 
    private float[][] mCenters;  | 
|
| 66 | 
    private int[][] mFaceMap;  | 
|
| 67 | 
    private ObjectSticker[] mStickers;  | 
|
| 210 | 68 | 
     | 
| 211 | 69 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| 212 | 70 | 
     | 
| ... | ... | |
| 229 | 87 | 
    };  | 
| 230 | 88 | 
    }  | 
| 231 | 89 | 
     | 
| 90 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
|
| 91 | 
     | 
|
| 92 | 
    private void initializeQuats()  | 
|
| 93 | 
        {
   | 
|
| 94 | 
    mQuats = new Static4D[]  | 
|
| 95 | 
             {
   | 
|
| 96 | 
    new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),  | 
|
| 97 | 
    new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),  | 
|
| 98 | 
    new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),  | 
|
| 99 | 
    new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),  | 
|
| 100 | 
     | 
|
| 101 | 
    new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ),  | 
|
| 102 | 
    new Static4D( 0.5f, 0.5f, 0.5f, -0.5f ),  | 
|
| 103 | 
    new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ),  | 
|
| 104 | 
    new Static4D( 0.5f, 0.5f, -0.5f, -0.5f ),  | 
|
| 105 | 
    new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ),  | 
|
| 106 | 
    new Static4D( 0.5f, -0.5f, 0.5f, -0.5f ),  | 
|
| 107 | 
    new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ),  | 
|
| 108 | 
    new Static4D( 0.5f, -0.5f, -0.5f, -0.5f )  | 
|
| 109 | 
    };  | 
|
| 110 | 
    }  | 
|
| 111 | 
     | 
|
| 232 | 112 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| 233 | 113 | 
     | 
| 234 | 114 | 
    int[] getSolvedQuats(int cubit, int numLayers)  | 
| 235 | 115 | 
        {
   | 
| 116 | 
    if( mQuats==null ) initializeQuats();  | 
|
| 236 | 117 | 
    int status = retCubitSolvedStatus(cubit,numLayers);  | 
| 237 | 
        return status<0 ? null : buildSolvedQuats(MovementRedi.FACE_AXIS[status],QUATS);
   | 
|
| 118 | 
        return status<0 ? null : buildSolvedQuats(MovementRedi.FACE_AXIS[status],mQuats);
   | 
|
| 238 | 119 | 
    }  | 
| 239 | 120 | 
     | 
| 240 | 121 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| ... | ... | |
| 248 | 129 | 
     | 
| 249 | 130 | 
    Static4D[] getQuats()  | 
| 250 | 131 | 
        {
   | 
| 251 | 
    return QUATS;  | 
|
| 132 | 
    if( mQuats==null ) initializeQuats();  | 
|
| 133 | 
    return mQuats;  | 
|
| 252 | 134 | 
    }  | 
| 253 | 135 | 
     | 
| 254 | 136 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| ... | ... | |
| 276 | 158 | 
     | 
| 277 | 159 | 
    int getNumStickerTypes(int numLayers)  | 
| 278 | 160 | 
        {
   | 
| 279 | 
        return STICKERS.length;
   | 
|
| 161 | 
        return 2;
   | 
|
| 280 | 162 | 
    }  | 
| 281 | 163 | 
     | 
| 282 | 164 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| ... | ... | |
| 299 | 181 | 
     | 
| 300 | 182 | 
    float[][] getCubitPositions(int size)  | 
| 301 | 183 | 
        {
   | 
| 302 | 
    return CENTERS;  | 
|
| 184 | 
    if( mCenters==null )  | 
|
| 185 | 
          {
   | 
|
| 186 | 
    final float DIST_CORNER = 1.0f;  | 
|
| 187 | 
    final float DIST_EDGE = 1.5f;  | 
|
| 188 | 
     | 
|
| 189 | 
    mCenters = new float[][]  | 
|
| 190 | 
             {
   | 
|
| 191 | 
                 { DIST_CORNER, DIST_CORNER, DIST_CORNER },
   | 
|
| 192 | 
                 { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
   | 
|
| 193 | 
                 { DIST_CORNER,-DIST_CORNER, DIST_CORNER },
   | 
|
| 194 | 
                 { DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
   | 
|
| 195 | 
                 {-DIST_CORNER, DIST_CORNER, DIST_CORNER },
   | 
|
| 196 | 
                 {-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
   | 
|
| 197 | 
                 {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
   | 
|
| 198 | 
                 {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
   | 
|
| 199 | 
     | 
|
| 200 | 
                 {      0.0f, DIST_EDGE, DIST_EDGE },
   | 
|
| 201 | 
                 { DIST_EDGE,      0.0f, DIST_EDGE },
   | 
|
| 202 | 
                 {      0.0f,-DIST_EDGE, DIST_EDGE },
   | 
|
| 203 | 
                 {-DIST_EDGE,      0.0f, DIST_EDGE },
   | 
|
| 204 | 
                 { DIST_EDGE, DIST_EDGE,      0.0f },
   | 
|
| 205 | 
                 { DIST_EDGE,-DIST_EDGE,      0.0f },
   | 
|
| 206 | 
                 {-DIST_EDGE,-DIST_EDGE,      0.0f },
   | 
|
| 207 | 
                 {-DIST_EDGE, DIST_EDGE,      0.0f },
   | 
|
| 208 | 
                 {      0.0f, DIST_EDGE,-DIST_EDGE },
   | 
|
| 209 | 
                 { DIST_EDGE,      0.0f,-DIST_EDGE },
   | 
|
| 210 | 
                 {      0.0f,-DIST_EDGE,-DIST_EDGE },
   | 
|
| 211 | 
                 {-DIST_EDGE,      0.0f,-DIST_EDGE }
   | 
|
| 212 | 
    };  | 
|
| 213 | 
    }  | 
|
| 214 | 
     | 
|
| 215 | 
    return mCenters;  | 
|
| 303 | 216 | 
    }  | 
| 304 | 217 | 
     | 
| 305 | 218 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| ... | ... | |
| 310 | 223 | 
     | 
| 311 | 224 | 
    if( variant==0 )  | 
| 312 | 225 | 
          {
   | 
| 226 | 
    double[][] vertices = new double[][]  | 
|
| 227 | 
              {
   | 
|
| 228 | 
                 { 0.0f, 0.0f, 0.0f },
   | 
|
| 229 | 
                 {-0.5f, 0.5f, 0.5f },
   | 
|
| 230 | 
                 {-0.5f,-0.5f, 0.5f },
   | 
|
| 231 | 
                 { 0.5f, 0.5f, 0.5f },
   | 
|
| 232 | 
                 { 0.5f,-0.5f, 0.5f },
   | 
|
| 233 | 
                 { 0.5f, 0.5f,-0.5f },
   | 
|
| 234 | 
                 { 0.5f,-0.5f,-0.5f },
   | 
|
| 235 | 
                 {-0.5f, 0.5f,-0.5f },
   | 
|
| 236 | 
    };  | 
|
| 237 | 
     | 
|
| 238 | 
    int[][] vert_indices = new int[][]  | 
|
| 239 | 
              {
   | 
|
| 240 | 
                 { 2,4,3,1 },
   | 
|
| 241 | 
                 { 1,3,5,7 },
   | 
|
| 242 | 
                 { 4,6,5,3 },
   | 
|
| 243 | 
     | 
|
| 244 | 
                 { 2,4,0 },
   | 
|
| 245 | 
                 { 5,7,0 },
   | 
|
| 246 | 
                 { 4,6,0 },
   | 
|
| 247 | 
                 { 7,1,0 },
   | 
|
| 248 | 
                 { 1,2,0 },
   | 
|
| 249 | 
                 { 6,5,0 }
   | 
|
| 250 | 
    };  | 
|
| 251 | 
     | 
|
| 313 | 252 | 
          float[][] bands     = new float[][] { {0.06f,35,0.5f,0.7f,5,2,2}, {0.01f,35,0.2f,0.4f,5,2,2} };
   | 
| 314 | 253 | 
          int[] bandIndices   = new int[] { 0,0,0,1,1,1,1,1,1 };
   | 
| 315 | 254 | 
          float[][] corners   = new float[][] { {0.06f,0.12f} };
   | 
| 316 | 255 | 
          int[] cornerIndices = new int[]  { -1,0,-1,0,0,0,-1,-1 };
   | 
| 317 | 256 | 
          float[][] centers   = new float[][] { { 0.0f, 0.0f, 0.0f} };
   | 
| 318 | 257 | 
          int[] centerIndices = new int[] { -1,0,-1,0,0,0,-1,-1 };
   | 
| 319 | 
          return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
   | 
|
| 258 | 
          return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
   | 
|
| 320 | 259 | 
    }  | 
| 321 | 260 | 
    else  | 
| 322 | 261 | 
          {
   | 
| 262 | 
    double[][] vertices = new double[][]  | 
|
| 263 | 
              {
   | 
|
| 264 | 
                 {-0.5f, 0.0f, 0.0f},
   | 
|
| 265 | 
                 { 0.5f, 0.0f, 0.0f},
   | 
|
| 266 | 
                 {-0.5f,-1.0f, 0.0f},
   | 
|
| 267 | 
                 { 0.5f,-1.0f, 0.0f},
   | 
|
| 268 | 
                 { 0.0f,-1.5f, 0.0f},
   | 
|
| 269 | 
                 {-0.5f, 0.0f,-1.0f},
   | 
|
| 270 | 
                 { 0.5f, 0.0f,-1.0f},
   | 
|
| 271 | 
                 { 0.0f, 0.0f,-1.5f},
   | 
|
| 272 | 
    };  | 
|
| 273 | 
     | 
|
| 274 | 
    int[][] vert_indices = new int[][]  | 
|
| 275 | 
              {
   | 
|
| 276 | 
                 { 0,2,4,3,1 },
   | 
|
| 277 | 
                 { 0,1,6,7,5 },
   | 
|
| 278 | 
                 { 1,3,6 },
   | 
|
| 279 | 
                 { 0,2,5 },
   | 
|
| 280 | 
                 { 4,7,6,3 },
   | 
|
| 281 | 
                 { 4,7,5,2 }
   | 
|
| 282 | 
    };  | 
|
| 283 | 
     | 
|
| 323 | 284 | 
          float[][] bands     = new float[][] { {0.038f,35,0.250f,0.7f,7,2,2}, {0.020f,35,0.125f,0.2f,3,1,2}, {0.020f,35,0.125f,0.2f,3,1,1} };
   | 
| 324 | 285 | 
          int[] bandIndices   = new int[] { 0,0,1,1,2,2 };
   | 
| 325 | 286 | 
          float[][] corners   = new float[][] { {0.06f,0.20f} };
   | 
| 326 | 287 | 
          int[] cornerIndices = new int[] { 0,0,-1,-1,-1,-1,-1,-1 };
   | 
| 327 | 288 | 
          float[][] centers   = new float[][] { { 0.0f,-0.75f,-0.75f} };
   | 
| 328 | 289 | 
          int[] centerIndices = new int[] { 0,0,-1,-1,-1,-1,-1,-1 };
   | 
| 329 | 
          return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
   | 
|
| 290 | 
          return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
   | 
|
| 330 | 291 | 
    }  | 
| 331 | 292 | 
    }  | 
| 332 | 293 | 
     | 
| ... | ... | |
| 334 | 295 | 
     | 
| 335 | 296 | 
    Static4D getQuat(int cubit, int numLayers)  | 
| 336 | 297 | 
        {
   | 
| 298 | 
    if( mQuats==null ) initializeQuats();  | 
|
| 299 | 
     | 
|
| 337 | 300 | 
    switch(cubit)  | 
| 338 | 301 | 
          {
   | 
| 339 | 
          case  0: return QUATS[0];                          //  unit quat
   | 
|
| 302 | 
          case  0: return mQuats[0];                         //  unit quat
   | 
|
| 340 | 303 | 
    case 1: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along X  | 
| 341 | 304 | 
    case 2: return new Static4D(-SQ2/2,0,0,SQ2/2); // -90 along X  | 
| 342 | 
          case  3: return QUATS[1];                          // 180 along X
   | 
|
| 305 | 
          case  3: return mQuats[1];                         // 180 along X
   | 
|
| 343 | 306 | 
    case 4: return new Static4D(0, SQ2/2,0,SQ2/2); // 90 along Y  | 
| 344 | 
          case  5: return QUATS[2];                          // 180 along Y
   | 
|
| 345 | 
          case  6: return QUATS[3];                          // 180 along Z
   | 
|
| 307 | 
          case  5: return mQuats[2];                         // 180 along Y
   | 
|
| 308 | 
          case  6: return mQuats[3];                         // 180 along Z
   | 
|
| 346 | 309 | 
    case 7: return new Static4D(SQ2/2,0,-SQ2/2,0); // 180 along (SQ2/2,0,-SQ2/2)  | 
| 347 | 310 | 
     | 
| 348 | 
          case  8: return QUATS[0];
   | 
|
| 349 | 
          case  9: return QUATS[5];
   | 
|
| 350 | 
          case 10: return QUATS[3];
   | 
|
| 351 | 
          case 11: return QUATS[11];
   | 
|
| 352 | 
          case 12: return QUATS[4];
   | 
|
| 353 | 
          case 13: return QUATS[7];
   | 
|
| 354 | 
          case 14: return QUATS[9];
   | 
|
| 355 | 
          case 15: return QUATS[10];
   | 
|
| 356 | 
          case 16: return QUATS[2];
   | 
|
| 357 | 
          case 17: return QUATS[8];
   | 
|
| 358 | 
          case 18: return QUATS[1];
   | 
|
| 359 | 
          case 19: return QUATS[6];
   | 
|
| 311 | 
          case  8: return mQuats[0];
   | 
|
| 312 | 
          case  9: return mQuats[5];
   | 
|
| 313 | 
          case 10: return mQuats[3];
   | 
|
| 314 | 
          case 11: return mQuats[11];
   | 
|
| 315 | 
          case 12: return mQuats[4];
   | 
|
| 316 | 
          case 13: return mQuats[7];
   | 
|
| 317 | 
          case 14: return mQuats[9];
   | 
|
| 318 | 
          case 15: return mQuats[10];
   | 
|
| 319 | 
          case 16: return mQuats[2];
   | 
|
| 320 | 
          case 17: return mQuats[8];
   | 
|
| 321 | 
          case 18: return mQuats[1];
   | 
|
| 322 | 
          case 19: return mQuats[6];
   | 
|
| 360 | 323 | 
    }  | 
| 361 | 324 | 
     | 
| 362 | 325 | 
    return null;  | 
| ... | ... | |
| 380 | 343 | 
     | 
| 381 | 344 | 
    int getFaceColor(int cubit, int cubitface, int size)  | 
| 382 | 345 | 
        {
   | 
| 383 | 
    return cubitface<3 ? mFaceMap[cubit][cubitface] : STICKERS.length*FACE_COLORS.length;  | 
|
| 346 | 
    if( mFaceMap==null )  | 
|
| 347 | 
          {
   | 
|
| 348 | 
    // Colors of the faces of cubits.  | 
|
| 349 | 
    // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5  | 
|
| 350 | 
    // YELLOW 6 WHITE 7 BLUE 8 GREEN 9 RED 10 ORANGE 11  | 
|
| 351 | 
    mFaceMap = new int[][]  | 
|
| 352 | 
             {
   | 
|
| 353 | 
               {  4, 2, 0 },
   | 
|
| 354 | 
               {  2, 5, 0 },
   | 
|
| 355 | 
               {  3, 4, 0 },
   | 
|
| 356 | 
               {  5, 3, 0 },
   | 
|
| 357 | 
               {  1, 2, 4 },
   | 
|
| 358 | 
               {  5, 2, 1 },
   | 
|
| 359 | 
               {  4, 3, 1 },
   | 
|
| 360 | 
               {  1, 3, 5 },
   | 
|
| 361 | 
     | 
|
| 362 | 
               { 10, 8,12 },
   | 
|
| 363 | 
               {  6,10,12 },
   | 
|
| 364 | 
               { 10, 9,12 },
   | 
|
| 365 | 
               {  7,10,12 },
   | 
|
| 366 | 
               {  8, 6,12 },
   | 
|
| 367 | 
               {  9, 6,12 },
   | 
|
| 368 | 
               {  9, 7,12 },
   | 
|
| 369 | 
               {  8, 7,12 },
   | 
|
| 370 | 
               { 11, 8,12 },
   | 
|
| 371 | 
               {  6,11,12 },
   | 
|
| 372 | 
               { 11, 9,12 },
   | 
|
| 373 | 
               {  7,11,12 },
   | 
|
| 374 | 
    };  | 
|
| 375 | 
    }  | 
|
| 376 | 
     | 
|
| 377 | 
    return cubitface<3 ? mFaceMap[cubit][cubitface] : NUM_TEXTURES;  | 
|
| 384 | 378 | 
    }  | 
| 385 | 379 | 
     | 
| 386 | 380 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| ... | ... | |
| 394 | 388 | 
     | 
| 395 | 389 | 
    ObjectSticker retSticker(int face)  | 
| 396 | 390 | 
        {
   | 
| 391 | 
    if( mStickers==null )  | 
|
| 392 | 
          {
   | 
|
| 393 | 
    float[][] STICKERS = new float[][]  | 
|
| 394 | 
              {
   | 
|
| 395 | 
                 { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f },
   | 
|
| 396 | 
                 { -0.3125f, 0.4375f, -0.3125f, -0.1875f, 0.0f, -0.5f, 0.3125f, -0.1875f, 0.3125f, 0.4375f }
   | 
|
| 397 | 
    };  | 
|
| 398 | 
     | 
|
| 399 | 
    final float R0 = 0.09f;  | 
|
| 400 | 
    final float R1 = 0.06f;  | 
|
| 401 | 
          final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1,R1} };
   | 
|
| 402 | 
          final float[] strokes = { 0.09f,0.06f };
   | 
|
| 403 | 
     | 
|
| 404 | 
    mStickers = new ObjectSticker[STICKERS.length];  | 
|
| 405 | 
     | 
|
| 406 | 
    for(int s=0; s<STICKERS.length; s++)  | 
|
| 407 | 
            {
   | 
|
| 408 | 
    mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);  | 
|
| 409 | 
    }  | 
|
| 410 | 
    }  | 
|
| 411 | 
     | 
|
| 397 | 412 | 
    return mStickers[face/NUM_FACES];  | 
| 398 | 413 | 
    }  | 
| 399 | 414 | 
     | 
| ... | ... | |
| 464 | 479 | 
     | 
| 465 | 480 | 
    public int[] getBasicAngle()  | 
| 466 | 481 | 
        {
   | 
| 467 | 
    return BASIC_ANGLE;  | 
|
| 482 | 
        if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
   | 
|
| 483 | 
    return mBasicAngle;  | 
|
| 468 | 484 | 
    }  | 
| 469 | 485 | 
     | 
| 470 | 486 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
Also available in: Unified diff
Remove statics from the Redi class.