Revision d5380277
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistySquare.java | ||
---|---|---|
51 | 51 |
new Static3D(0,-1,0), |
52 | 52 |
}; |
53 | 53 |
|
54 |
static final int[] BASIC_ANGLE = new int[] { 12,2,12 }; |
|
55 |
|
|
56 | 54 |
static final int[] FACE_COLORS = new int[] |
57 | 55 |
{ |
58 | 56 |
COLOR_YELLOW, COLOR_WHITE, |
... | ... | |
60 | 58 |
COLOR_RED , COLOR_ORANGE |
61 | 59 |
}; |
62 | 60 |
|
63 |
static final Static4D[] QUATS = new Static4D[] |
|
61 |
int mLastRot; |
|
62 |
int[] mBasicAngle; |
|
63 |
Static4D[] mQuats; |
|
64 |
int[][] mQuatMult; |
|
65 |
|
|
66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
67 |
|
|
68 |
TwistySquare(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
|
69 |
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth) |
|
64 | 70 |
{ |
71 |
super(size, size, quat, texture, mesh, effects, moves, obj, res, scrWidth); |
|
72 |
} |
|
73 |
|
|
74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
75 |
|
|
76 |
void initializeQuats() |
|
77 |
{ |
|
78 |
mQuats = new Static4D[] |
|
79 |
{ |
|
65 | 80 |
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ), |
66 | 81 |
new Static4D( 0.0f, SIN15, 0.0f, COS15 ), |
67 | 82 |
new Static4D( 0.0f, 0.5f, 0.0f, SQ3/2 ), |
... | ... | |
87 | 102 |
new Static4D(-SQ2/2, 0.0f, SQ2/2, 0.0f ), |
88 | 103 |
new Static4D(-SQ3/2, 0.0f, 0.5f, 0.0f ), |
89 | 104 |
new Static4D(-COS15, 0.0f, SIN15, 0.0f ) |
90 |
}; |
|
91 |
|
|
92 |
static final double[][] VERTICES_MIDDLE = new double[][] |
|
93 |
{ |
|
94 |
{ -1.5-X, 0.5, 1.5 }, |
|
95 |
{ 0.0, 0.5, 1.5 }, |
|
96 |
{ 0.0, 0.5,-1.5 }, |
|
97 |
{ -1.5+X, 0.5,-1.5 }, |
|
98 |
{ -1.5-X,-0.5, 1.5 }, |
|
99 |
{ 0.0,-0.5, 1.5 }, |
|
100 |
{ 0.0,-0.5,-1.5 }, |
|
101 |
{ -1.5+X,-0.5,-1.5 } |
|
102 |
}; |
|
103 |
|
|
104 |
static final int[][] VERT_INDEXES_MIDDLE = new int[][] |
|
105 |
{ |
|
106 |
{0,1,2,3}, // counterclockwise! |
|
107 |
{4,5,6,7}, |
|
108 |
{4,5,1,0}, |
|
109 |
{5,6,2,1}, |
|
110 |
{6,7,3,2}, |
|
111 |
{7,4,0,3} |
|
112 |
}; |
|
113 |
|
|
114 |
static final double[][] VERTICES_EDGE = new double[][] |
|
115 |
{ |
|
116 |
{ -X, 0.5, 0.0 }, |
|
117 |
{ +X, 0.5, 0.0 }, |
|
118 |
{0.0, 0.5,-1.5 }, |
|
119 |
{ -X,-0.5, 0.0 }, |
|
120 |
{ +X,-0.5, 0.0 }, |
|
121 |
{0.0,-0.5,-1.5 }, |
|
122 |
}; |
|
123 |
|
|
124 |
static final int[][] VERT_INDEXES_EDGE = new int[][] |
|
125 |
{ |
|
126 |
{0,1,2}, // counterclockwise! |
|
127 |
{3,4,5}, |
|
128 |
{3,4,1,0}, |
|
129 |
{4,5,2,1}, |
|
130 |
{5,3,0,2} |
|
131 |
}; |
|
105 |
}; |
|
106 |
} |
|
132 | 107 |
|
133 |
// QUATS[i]*QUATS[j] = QUATS[QUAT_MULT[i][j]] |
|
134 |
static final int[][] QUAT_MULT = new int[][] |
|
135 |
{ |
|
136 |
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,}, |
|
137 |
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12,}, |
|
138 |
{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13,}, |
|
139 |
{ 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14,}, |
|
140 |
{ 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15,}, |
|
141 |
{ 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16,}, |
|
142 |
{ 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17,}, |
|
143 |
{ 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18,}, |
|
144 |
{ 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19,}, |
|
145 |
{ 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20,}, |
|
146 |
{ 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,}, |
|
147 |
{ 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,}, |
|
148 |
{ 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,}, |
|
149 |
{ 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,}, |
|
150 |
{ 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3,}, |
|
151 |
{ 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4,}, |
|
152 |
{ 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5,}, |
|
153 |
{ 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6,}, |
|
154 |
{ 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 6, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7,}, |
|
155 |
{ 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 7, 6, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8,}, |
|
156 |
{ 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 10, 9,}, |
|
157 |
{ 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 10,}, |
|
158 |
{ 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11,}, |
|
159 |
{ 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,} |
|
160 |
}; |
|
161 | 108 |
|
162 |
int mLastRot; |
|
109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
110 |
// QUATS[i]*QUATS[j] = QUATS[QUAT_MULT[i][j]] |
|
111 |
|
|
112 |
void initializeQuatMult() |
|
113 |
{ |
|
114 |
mQuatMult = new int[][] |
|
115 |
{ |
|
116 |
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,}, |
|
117 |
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12,}, |
|
118 |
{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13,}, |
|
119 |
{ 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 15, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14,}, |
|
120 |
{ 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 16, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15,}, |
|
121 |
{ 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 17, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16,}, |
|
122 |
{ 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17,}, |
|
123 |
{ 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18,}, |
|
124 |
{ 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19,}, |
|
125 |
{ 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 21, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20,}, |
|
126 |
{ 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 22, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,}, |
|
127 |
{ 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 23, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,}, |
|
128 |
{ 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,}, |
|
129 |
{ 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,}, |
|
130 |
{ 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 15, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3,}, |
|
131 |
{ 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 16, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4,}, |
|
132 |
{ 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 17, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5,}, |
|
133 |
{ 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6,}, |
|
134 |
{ 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 6, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7,}, |
|
135 |
{ 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 7, 6, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8,}, |
|
136 |
{ 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 21, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 10, 9,}, |
|
137 |
{ 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 10,}, |
|
138 |
{ 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11,}, |
|
139 |
{ 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,} |
|
140 |
}; |
|
141 |
} |
|
163 | 142 |
|
164 | 143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
165 | 144 |
|
166 |
TwistySquare(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
|
167 |
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth) |
|
145 |
void initializeBasicAngle() |
|
168 | 146 |
{ |
169 |
super(size, size, quat, texture, mesh, effects, moves, obj, res, scrWidth);
|
|
147 |
mBasicAngle = new int[] {12,2,12};
|
|
170 | 148 |
} |
171 | 149 |
|
172 | 150 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
173 | 151 |
|
174 | 152 |
Static4D[] getQuats() |
175 | 153 |
{ |
176 |
return QUATS; |
|
154 |
if( mQuats==null ) initializeQuats(); |
|
155 |
return mQuats; |
|
177 | 156 |
} |
178 | 157 |
|
179 | 158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
237 | 216 |
|
238 | 217 |
public int[] getBasicAngle() |
239 | 218 |
{ |
240 |
return BASIC_ANGLE; |
|
219 |
if( mBasicAngle ==null ) initializeBasicAngle(); |
|
220 |
return mBasicAngle; |
|
241 | 221 |
} |
242 | 222 |
} |
src/main/java/org/distorted/objects/TwistySquare1.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
class TwistySquare1 extends TwistySquare |
37 | 37 |
{ |
38 |
private static final int[] QUAT_NUMBER = new int[] |
|
39 |
{ |
|
40 |
0, 6, |
|
41 |
0, 9, 6, 3, 18, 15, 12, 21, |
|
42 |
0, 9, 6, 3, 15, 12, 21, 18 |
|
43 |
}; |
|
44 |
|
|
45 |
// centers of the 2 middles + 8 edges + 8 corners |
|
46 |
private static final float[][] CENTERS = new float[][] |
|
47 |
{ |
|
48 |
{ 1.5f, 0.0f, 0.0f }, |
|
49 |
{-1.5f, 0.0f, 0.0f }, |
|
50 |
|
|
51 |
{ 0.0f, 1.0f, 1.5f }, |
|
52 |
{ 1.5f, 1.0f, 0.0f }, |
|
53 |
{ 0.0f, 1.0f,-1.5f }, |
|
54 |
{-1.5f, 1.0f, 0.0f }, |
|
55 |
{ 0.0f,-1.0f, 1.5f }, |
|
56 |
{ 1.5f,-1.0f, 0.0f }, |
|
57 |
{ 0.0f,-1.0f,-1.5f }, |
|
58 |
{-1.5f,-1.0f, 0.0f }, |
|
59 |
|
|
60 |
{ 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f }, |
|
61 |
{ 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f }, |
|
62 |
{-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f }, |
|
63 |
{-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f }, |
|
64 |
{ 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f }, |
|
65 |
{ 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f }, |
|
66 |
{-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f }, |
|
67 |
{-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f } |
|
68 |
}; |
|
69 |
|
|
70 |
private static final double[][] VERTICES_CORNER = new double[][] |
|
71 |
{ |
|
72 |
{ X-1.5, 0.5, 0.0 }, |
|
73 |
{ 0.0, 0.5, 0.0 }, |
|
74 |
{ 0.0, 0.5,X-1.5 }, |
|
75 |
{ -1.5, 0.5, -1.5 }, |
|
76 |
{ X-1.5,-0.5, 0.0 }, |
|
77 |
{ 0.0,-0.5, 0.0 }, |
|
78 |
{ 0.0,-0.5,X-1.5 }, |
|
79 |
{ -1.5,-0.5, -1.5 } |
|
80 |
}; |
|
81 |
|
|
82 |
private static final int[][] VERT_INDEXES_CORNER = new int[][] |
|
83 |
{ |
|
84 |
{0,1,2,3}, // counterclockwise! |
|
85 |
{4,5,6,7}, |
|
86 |
{4,5,1,0}, |
|
87 |
{5,6,2,1}, |
|
88 |
{7,4,0,3}, |
|
89 |
{6,7,3,2} |
|
90 |
}; |
|
91 |
|
|
92 |
private static final float[][] STICKERS = new float[][] |
|
93 |
{ |
|
94 |
{ -0.5f, -0.26289170f, 0.5f, -0.26289170f, 0.5f, 0.26289170f, -0.5f, 0.26289170f }, // middle front |
|
95 |
{ -0.5f, -0.16666667f, 0.5f, -0.16666667f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }, // middle right |
|
96 |
{ -0.5f, -0.45534182f, 0.5f, -0.45534182f, 0.5f, 0.45534182f, -0.5f, 0.45534182f }, // middle back |
|
97 |
{ -0.20096192f, -0.25f, 0.20096192f, -0.25f, 0.0f, 0.5f }, // edge top |
|
98 |
{ -0.40192384f, -0.5f, 0.40192384f, -0.5f, 0.40192384f, 0.5f, -0.40192384f, 0.5f }, // edge face |
|
99 |
{ -0.2637079f, -0.38185397f, 0.38185397f, -0.38185397f, 0.38185397f, 0.2637079f, -0.5f, 0.5f } // corner top |
|
100 |
}; |
|
101 |
|
|
102 |
private static final int NUM_STICKERS = STICKERS.length; |
|
103 |
|
|
104 |
private static final int[][] mStickerType = new int[][] |
|
105 |
{ |
|
106 |
{ NUM_STICKERS,NUM_STICKERS,0, 1, 2,NUM_STICKERS }, |
|
107 |
{ 3,NUM_STICKERS,4,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS }, |
|
108 |
{ 5,NUM_STICKERS,2, 2,NUM_STICKERS,NUM_STICKERS } |
|
109 |
}; |
|
110 |
|
|
111 |
// YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5 |
|
112 |
private static final int[][] mStickerColor = new int[][] |
|
113 |
{ |
|
114 |
{ 0, 0, 4, 0, 5, 0 }, |
|
115 |
{ 0, 0, 5, 1, 4, 0 }, |
|
116 |
|
|
117 |
{ 2, 0, 4, 0, 0, 0 }, |
|
118 |
{ 2, 0, 0, 0, 0, 0 }, |
|
119 |
{ 2, 0, 5, 0, 0, 0 }, |
|
120 |
{ 2, 0, 1, 0, 0, 0 }, |
|
121 |
{ 3, 0, 4, 0, 0, 0 }, |
|
122 |
{ 3, 0, 0, 0, 0, 0 }, |
|
123 |
{ 3, 0, 5, 0, 0, 0 }, |
|
124 |
{ 3, 0, 1, 0, 0, 0 }, |
|
125 |
|
|
126 |
{ 2, 0, 4, 0, 0, 0 }, |
|
127 |
{ 2, 0, 0, 5, 0, 0 }, |
|
128 |
{ 2, 0, 5, 1, 0, 0 }, |
|
129 |
{ 2, 0, 1, 4, 0, 0 }, |
|
130 |
{ 3, 0, 0, 4, 0, 0 }, |
|
131 |
{ 3, 0, 5, 0, 0, 0 }, |
|
132 |
{ 3, 0, 1, 5, 0, 0 }, |
|
133 |
{ 3, 0, 4, 1, 0, 0 }, |
|
134 |
}; |
|
135 |
|
|
136 |
// quat indices that make corner cubits bandage the puzzle. |
|
137 |
private static final int[][] BAD_CORNER_QUATS = new int[][] |
|
138 |
{ |
|
139 |
{ 2, 8,17,23}, |
|
140 |
{ 5,11,14,20}, |
|
141 |
}; |
|
38 |
private static final int NUM_STICKERS = 6; |
|
142 | 39 |
|
143 | 40 |
private final int[][] mPermittedAngles; |
144 | 41 |
private final int[] mCornerQuat; |
145 | 42 |
private int mPermittedUp, mPermittedDo; |
146 |
|
|
147 |
private static final ObjectSticker[] mStickers; |
|
148 |
|
|
149 |
static |
|
150 |
{ |
|
151 |
mStickers = new ObjectSticker[NUM_STICKERS]; |
|
152 |
final float R1 = 0.06f; |
|
153 |
final float R2 = 0.04f; |
|
154 |
final float R3 = 0.11f; |
|
155 |
final float R4 = 0.03f; |
|
156 |
final float R5 = 0.11f; |
|
157 |
final float R6 = 0.08f; |
|
158 |
final float[][] radii = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6,R6} }; |
|
159 |
final float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.08f }; |
|
160 |
|
|
161 |
for(int s=0; s<NUM_STICKERS; s++) |
|
162 |
{ |
|
163 |
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); |
|
164 |
} |
|
165 |
} |
|
43 |
private ObjectSticker[] mStickers; |
|
44 |
private int[] mQuatNumber; |
|
45 |
private float[][] mCenters; |
|
46 |
private int[][] mBadCornerQuats; |
|
47 |
private int[][] mStickerColor; |
|
48 |
private int[][] mStickerType; |
|
166 | 49 |
|
167 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
168 | 51 |
|
... | ... | |
171 | 54 |
{ |
172 | 55 |
super(size, quat, texture, mesh, effects, moves, ObjectList.SQU1, res, scrWidth); |
173 | 56 |
|
57 |
if( mBasicAngle==null ) initializeBasicAngle(); |
|
174 | 58 |
mLastRot = LAST_SL; |
175 |
mPermittedAngles = new int[2][BASIC_ANGLE[0]];
|
|
59 |
mPermittedAngles = new int[2][mBasicAngle[0]];
|
|
176 | 60 |
mCornerQuat = new int[8]; |
177 | 61 |
} |
178 | 62 |
|
... | ... | |
180 | 64 |
|
181 | 65 |
int[] getSolvedQuats(int cubit, int numLayers) |
182 | 66 |
{ |
67 |
if( mQuats==null ) initializeQuats(); |
|
183 | 68 |
int status = retCubitSolvedStatus(cubit,numLayers); |
184 |
return status<0 ? null : buildSolvedQuats(MovementSquare.FACE_AXIS[status],QUATS);
|
|
69 |
return status<0 ? null : buildSolvedQuats(MovementSquare.FACE_AXIS[status],mQuats);
|
|
185 | 70 |
} |
186 | 71 |
|
187 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
192 | 77 |
|
193 | 78 |
if( variant==0 ) |
194 | 79 |
{ |
80 |
double[][] vertices = new double[][] |
|
81 |
{ |
|
82 |
{ -1.5-X, 0.5, 1.5 }, |
|
83 |
{ 0.0, 0.5, 1.5 }, |
|
84 |
{ 0.0, 0.5,-1.5 }, |
|
85 |
{ -1.5+X, 0.5,-1.5 }, |
|
86 |
{ -1.5-X,-0.5, 1.5 }, |
|
87 |
{ 0.0,-0.5, 1.5 }, |
|
88 |
{ 0.0,-0.5,-1.5 }, |
|
89 |
{ -1.5+X,-0.5,-1.5 } |
|
90 |
}; |
|
91 |
|
|
92 |
int[][] vert_indices = new int[][] |
|
93 |
{ |
|
94 |
{0,1,2,3}, |
|
95 |
{4,5,6,7}, |
|
96 |
{4,5,1,0}, |
|
97 |
{5,6,2,1}, |
|
98 |
{6,7,3,2}, |
|
99 |
{7,4,0,3} |
|
100 |
}; |
|
101 |
|
|
195 | 102 |
float[][] bands = new float[][] { {0.040f,35,0.8f,1.0f,5,2,1}, {0.020f,35,0.8f,1.0f,5,2,1}, {0.001f,35,0.8f,1.0f,5,2,1} }; |
196 | 103 |
int[] bandIndices = new int[] { 2,2,1,1,0,2 }; |
197 | 104 |
float[][] corners = new float[][] { {0.03f,0.05f} }; |
... | ... | |
199 | 106 |
float[][] centers = new float[][] { { -0.75f, 0.0f, 0.0f} }; |
200 | 107 |
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
201 | 108 |
|
202 |
return new ObjectShape(VERTICES_MIDDLE,VERT_INDEXES_MIDDLE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
109 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
203 | 110 |
} |
204 | 111 |
else if( variant==1 ) |
205 | 112 |
{ |
113 |
double[][] vertices = new double[][] |
|
114 |
{ |
|
115 |
{ -X, 0.5, 0.0 }, |
|
116 |
{ +X, 0.5, 0.0 }, |
|
117 |
{0.0, 0.5,-1.5 }, |
|
118 |
{ -X,-0.5, 0.0 }, |
|
119 |
{ +X,-0.5, 0.0 }, |
|
120 |
{0.0,-0.5,-1.5 }, |
|
121 |
}; |
|
122 |
|
|
123 |
int[][] vert_indices = new int[][] |
|
124 |
{ |
|
125 |
{0,1,2}, |
|
126 |
{3,4,5}, |
|
127 |
{3,4,1,0}, |
|
128 |
{4,5,2,1}, |
|
129 |
{5,3,0,2} |
|
130 |
}; |
|
131 |
|
|
206 | 132 |
float[][] bands = new float[][] { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} }; |
207 | 133 |
int[] bandIndices = new int[] { 0,1,0,1,1 }; |
208 | 134 |
float[][] corners = new float[][] { {0.04f,0.15f} }; |
... | ... | |
210 | 136 |
float[][] centers = new float[][] { { 0.0f, 0.0f,-0.5f} }; |
211 | 137 |
int[] centerIndices = new int[] { 0,0,-1,0,0,-1 }; |
212 | 138 |
|
213 |
return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
139 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
214 | 140 |
} |
215 | 141 |
else |
216 | 142 |
{ |
143 |
double[][] vertices = new double[][] |
|
144 |
{ |
|
145 |
{ X-1.5, 0.5, 0.0 }, |
|
146 |
{ 0.0, 0.5, 0.0 }, |
|
147 |
{ 0.0, 0.5,X-1.5 }, |
|
148 |
{ -1.5, 0.5, -1.5 }, |
|
149 |
{ X-1.5,-0.5, 0.0 }, |
|
150 |
{ 0.0,-0.5, 0.0 }, |
|
151 |
{ 0.0,-0.5,X-1.5 }, |
|
152 |
{ -1.5,-0.5, -1.5 } |
|
153 |
}; |
|
154 |
int[][] vert_indices = new int[][] |
|
155 |
{ |
|
156 |
{0,1,2,3}, |
|
157 |
{4,5,6,7}, |
|
158 |
{4,5,1,0}, |
|
159 |
{5,6,2,1}, |
|
160 |
{7,4,0,3}, |
|
161 |
{6,7,3,2} |
|
162 |
}; |
|
163 |
|
|
217 | 164 |
float[][] bands = new float[][] { {0.038f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} }; |
218 | 165 |
int[] bandIndices = new int[] { 0,1,0,0,1,1 }; |
219 | 166 |
float[][] corners = new float[][] { {0.05f,0.13f} }; |
... | ... | |
221 | 168 |
float[][] centers = new float[][] { { -0.5f, 0.0f,-0.5f} }; |
222 | 169 |
int[] centerIndices = new int[] { -1,0,-1,-1,-1,0,-1,-1 }; |
223 | 170 |
|
224 |
return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
171 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
225 | 172 |
} |
226 | 173 |
} |
227 | 174 |
|
... | ... | |
229 | 176 |
|
230 | 177 |
Static4D getQuat(int cubit, int numLayers) |
231 | 178 |
{ |
232 |
return QUATS[QUAT_NUMBER[cubit]]; |
|
179 |
if( mQuats==null ) initializeQuats(); |
|
180 |
if( mQuatNumber ==null ) |
|
181 |
{ |
|
182 |
mQuatNumber = new int[] |
|
183 |
{ |
|
184 |
0, 6, |
|
185 |
0, 9, 6, 3, 18, 15, 12, 21, |
|
186 |
0, 9, 6, 3, 15, 12, 21, 18 |
|
187 |
}; |
|
188 |
} |
|
189 |
|
|
190 |
return mQuats[mQuatNumber[cubit]]; |
|
233 | 191 |
} |
234 | 192 |
|
235 | 193 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
250 | 208 |
|
251 | 209 |
ObjectSticker retSticker(int face) |
252 | 210 |
{ |
211 |
if( mStickers==null ) |
|
212 |
{ |
|
213 |
float[][] STICKERS = new float[][] |
|
214 |
{ |
|
215 |
{ -0.5f, -0.26289170f, 0.5f, -0.26289170f, 0.5f, 0.26289170f, -0.5f, 0.26289170f }, // middle front |
|
216 |
{ -0.5f, -0.16666667f, 0.5f, -0.16666667f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }, // middle right |
|
217 |
{ -0.5f, -0.45534182f, 0.5f, -0.45534182f, 0.5f, 0.45534182f, -0.5f, 0.45534182f }, // middle back |
|
218 |
{ -0.20096192f, -0.25f, 0.20096192f, -0.25f, 0.0f, 0.5f }, // edge top |
|
219 |
{ -0.40192384f, -0.5f, 0.40192384f, -0.5f, 0.40192384f, 0.5f, -0.40192384f, 0.5f }, // edge face |
|
220 |
{ -0.2637079f, -0.38185397f, 0.38185397f, -0.38185397f, 0.38185397f, 0.2637079f, -0.5f, 0.5f } // corner top |
|
221 |
}; |
|
222 |
|
|
223 |
final float R1 = 0.06f; |
|
224 |
final float R2 = 0.04f; |
|
225 |
final float R3 = 0.11f; |
|
226 |
final float R4 = 0.03f; |
|
227 |
final float R5 = 0.11f; |
|
228 |
final float R6 = 0.08f; |
|
229 |
final float[][] radii = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6,R6} }; |
|
230 |
final float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.08f }; |
|
231 |
|
|
232 |
mStickers = new ObjectSticker[NUM_STICKERS]; |
|
233 |
|
|
234 |
for(int s=0; s<NUM_STICKERS; s++) |
|
235 |
{ |
|
236 |
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
253 | 240 |
return mStickers[face/NUM_FACES]; |
254 | 241 |
} |
255 | 242 |
|
... | ... | |
257 | 244 |
|
258 | 245 |
float[][] getCubitPositions(int numLayers) |
259 | 246 |
{ |
260 |
return CENTERS; |
|
247 |
if( mCenters==null ) |
|
248 |
{ |
|
249 |
mCenters = new float[][] |
|
250 |
{ |
|
251 |
{ 1.5f, 0.0f, 0.0f }, |
|
252 |
{-1.5f, 0.0f, 0.0f }, |
|
253 |
|
|
254 |
{ 0.0f, 1.0f, 1.5f }, |
|
255 |
{ 1.5f, 1.0f, 0.0f }, |
|
256 |
{ 0.0f, 1.0f,-1.5f }, |
|
257 |
{-1.5f, 1.0f, 0.0f }, |
|
258 |
{ 0.0f,-1.0f, 1.5f }, |
|
259 |
{ 1.5f,-1.0f, 0.0f }, |
|
260 |
{ 0.0f,-1.0f,-1.5f }, |
|
261 |
{-1.5f,-1.0f, 0.0f }, |
|
262 |
|
|
263 |
{ 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f }, |
|
264 |
{ 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f }, |
|
265 |
{-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f }, |
|
266 |
{-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f }, |
|
267 |
{ 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f }, |
|
268 |
{ 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f }, |
|
269 |
{-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f }, |
|
270 |
{-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f } |
|
271 |
}; |
|
272 |
} |
|
273 |
return mCenters; |
|
261 | 274 |
} |
262 | 275 |
|
263 | 276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
278 | 291 |
|
279 | 292 |
int getFaceColor(int cubit, int cubitface, int numLayers) |
280 | 293 |
{ |
294 |
if( mStickerColor==null ) |
|
295 |
{ |
|
296 |
// YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5 |
|
297 |
mStickerColor = new int[][] |
|
298 |
{ |
|
299 |
{ 0, 0, 4, 0, 5, 0 }, |
|
300 |
{ 0, 0, 5, 1, 4, 0 }, |
|
301 |
|
|
302 |
{ 2, 0, 4, 0, 0, 0 }, |
|
303 |
{ 2, 0, 0, 0, 0, 0 }, |
|
304 |
{ 2, 0, 5, 0, 0, 0 }, |
|
305 |
{ 2, 0, 1, 0, 0, 0 }, |
|
306 |
{ 3, 0, 4, 0, 0, 0 }, |
|
307 |
{ 3, 0, 0, 0, 0, 0 }, |
|
308 |
{ 3, 0, 5, 0, 0, 0 }, |
|
309 |
{ 3, 0, 1, 0, 0, 0 }, |
|
310 |
|
|
311 |
{ 2, 0, 4, 0, 0, 0 }, |
|
312 |
{ 2, 0, 0, 5, 0, 0 }, |
|
313 |
{ 2, 0, 5, 1, 0, 0 }, |
|
314 |
{ 2, 0, 1, 4, 0, 0 }, |
|
315 |
{ 3, 0, 0, 4, 0, 0 }, |
|
316 |
{ 3, 0, 5, 0, 0, 0 }, |
|
317 |
{ 3, 0, 1, 5, 0, 0 }, |
|
318 |
{ 3, 0, 4, 1, 0, 0 }, |
|
319 |
}; |
|
320 |
} |
|
321 |
|
|
322 |
if( mStickerType==null ) |
|
323 |
{ |
|
324 |
mStickerType = new int[][] |
|
325 |
{ |
|
326 |
{ NUM_STICKERS,NUM_STICKERS,0, 1, 2,NUM_STICKERS }, |
|
327 |
{ 3,NUM_STICKERS,4,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS }, |
|
328 |
{ 5,NUM_STICKERS,2, 2,NUM_STICKERS,NUM_STICKERS } |
|
329 |
}; |
|
330 |
} |
|
331 |
|
|
281 | 332 |
int variant = getCubitVariant(cubit,numLayers); |
282 | 333 |
return mStickerType[variant][cubitface]*FACE_COLORS.length + mStickerColor[cubit][cubitface]; |
283 | 334 |
} |
... | ... | |
314 | 365 |
|
315 | 366 |
private boolean quatIsBad(int quatIndex, int corner) |
316 | 367 |
{ |
368 |
if( mBadCornerQuats ==null ) |
|
369 |
{ |
|
370 |
// quat indices that make corner cubits bandage the puzzle. |
|
371 |
mBadCornerQuats = new int[][] { { 2, 8,17,23}, { 5,11,14,20} }; |
|
372 |
} |
|
373 |
|
|
317 | 374 |
int index = (corner%2); |
318 | 375 |
|
319 |
return ( quatIndex==BAD_CORNER_QUATS[index][0] ||
|
|
320 |
quatIndex==BAD_CORNER_QUATS[index][1] ||
|
|
321 |
quatIndex==BAD_CORNER_QUATS[index][2] ||
|
|
322 |
quatIndex==BAD_CORNER_QUATS[index][3] );
|
|
376 |
return ( quatIndex== mBadCornerQuats[index][0] ||
|
|
377 |
quatIndex== mBadCornerQuats[index][1] ||
|
|
378 |
quatIndex== mBadCornerQuats[index][2] ||
|
|
379 |
quatIndex== mBadCornerQuats[index][3] );
|
|
323 | 380 |
} |
324 | 381 |
|
325 | 382 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
326 | 383 |
|
327 | 384 |
private boolean isPermittedDo(int angle) |
328 | 385 |
{ |
386 |
if( mQuatMult==null ) initializeQuatMult(); |
|
387 |
|
|
329 | 388 |
for(int corner=0; corner<8; corner++) |
330 | 389 |
{ |
331 | 390 |
if( !cornerIsUp(corner) ) |
332 | 391 |
{ |
333 | 392 |
int currQuat = mCornerQuat[corner]; |
334 |
int finalQuat= QUAT_MULT[angle][currQuat];
|
|
393 |
int finalQuat= mQuatMult[angle][currQuat];
|
|
335 | 394 |
if( quatIsBad(finalQuat,corner) ) return false; |
336 | 395 |
} |
337 | 396 |
} |
... | ... | |
343 | 402 |
|
344 | 403 |
private boolean isPermittedUp(int angle) |
345 | 404 |
{ |
405 |
if( mQuatMult==null ) initializeQuatMult(); |
|
406 |
|
|
346 | 407 |
for(int corner=0; corner<8; corner++) |
347 | 408 |
{ |
348 | 409 |
if( cornerIsUp(corner) ) |
349 | 410 |
{ |
350 | 411 |
int currQuat = mCornerQuat[corner]; |
351 |
int finalQuat= QUAT_MULT[angle][currQuat];
|
|
412 |
int finalQuat= mQuatMult[angle][currQuat];
|
|
352 | 413 |
if( quatIsBad(finalQuat,corner) ) return false; |
353 | 414 |
} |
354 | 415 |
} |
... | ... | |
360 | 421 |
|
361 | 422 |
private void computePermittedAngles() |
362 | 423 |
{ |
424 |
if( mBasicAngle==null ) initializeBasicAngle(); |
|
425 |
|
|
363 | 426 |
mPermittedDo = 0; |
364 | 427 |
|
365 |
for(int angle=0; angle<BASIC_ANGLE[0]; angle++)
|
|
428 |
for(int angle=0; angle<mBasicAngle[0]; angle++)
|
|
366 | 429 |
{ |
367 | 430 |
if( isPermittedDo(angle ) ) mPermittedAngles[0][mPermittedDo++] = angle; |
368 | 431 |
} |
369 | 432 |
|
370 | 433 |
mPermittedUp = 0; |
371 | 434 |
|
372 |
for(int angle=0; angle<BASIC_ANGLE[0]; angle++)
|
|
435 |
for(int angle=0; angle<mBasicAngle[0]; angle++)
|
|
373 | 436 |
{ |
374 | 437 |
if( isPermittedUp(angle ) ) mPermittedAngles[1][mPermittedUp++] = angle; |
375 | 438 |
} |
... | ... | |
379 | 442 |
|
380 | 443 |
private int getNextAngle(Random rnd, int layer) |
381 | 444 |
{ |
382 |
int basic = BASIC_ANGLE[0]; |
|
445 |
if( mBasicAngle==null ) initializeBasicAngle(); |
|
446 |
int basic = mBasicAngle[0]; |
|
383 | 447 |
int num = layer==0 ? mPermittedDo:mPermittedUp; |
384 | 448 |
int index = rnd.nextInt(num); |
385 | 449 |
int angle = mPermittedAngles[layer][index]; |
... | ... | |
390 | 454 |
|
391 | 455 |
private int getNextAngleNotZero(Random rnd, int layer) |
392 | 456 |
{ |
393 |
int basic = BASIC_ANGLE[0]; |
|
457 |
if( mBasicAngle==null ) initializeBasicAngle(); |
|
458 |
int basic = mBasicAngle[0]; |
|
394 | 459 |
int num = layer==0 ? mPermittedDo:mPermittedUp; |
395 | 460 |
int index = rnd.nextInt(num-1); |
396 | 461 |
int angle = mPermittedAngles[layer][index+1]; |
... | ... | |
426 | 491 |
|
427 | 492 |
private void updateCornerQuats(int[] rotInfo) |
428 | 493 |
{ |
494 |
if( mQuatMult==null ) initializeQuatMult(); |
|
495 |
|
|
429 | 496 |
int axis = rotInfo[0]; |
430 | 497 |
int layer= rotInfo[1]; |
431 | 498 |
int index=-rotInfo[2]; |
... | ... | |
437 | 504 |
if( cornerBelongs(corner,axis,layer) ) |
438 | 505 |
{ |
439 | 506 |
int curr = mCornerQuat[corner]; |
440 |
mCornerQuat[corner] = QUAT_MULT[quat][curr];
|
|
507 |
mCornerQuat[corner] = mQuatMult[quat][curr];
|
|
441 | 508 |
} |
442 | 509 |
} |
443 | 510 |
} |
src/main/java/org/distorted/objects/TwistySquare2.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
class TwistySquare2 extends TwistySquare |
38 | 38 |
{ |
39 |
private static final float Y = 0.75f + X/2; |
|
40 |
private static final float Z = 0.75f - X/2; |
|
41 |
|
|
42 |
private static final int[] QUAT_NUMBER = new int[] |
|
43 |
{ |
|
44 |
0, 6, |
|
45 |
0, 9, 6, 3, 18, 15, 12, 21, |
|
46 |
0, 9, 6, 3, 0, 9, 6, 3, |
|
47 |
15, 12, 21, 18, 15, 12, 21, 18 |
|
48 |
}; |
|
49 |
|
|
50 |
// centers of the 2 middles + 8 edges + 8 left corners + 8 right corners |
|
51 |
private static final float[][] CENTERS = new float[][] |
|
52 |
{ |
|
53 |
{ 1.5f, 0.0f, 0.0f }, |
|
54 |
{-1.5f, 0.0f, 0.0f }, |
|
55 |
|
|
56 |
{ 0.0f, 1.0f, 1.5f }, |
|
57 |
{ 1.5f, 1.0f, 0.0f }, |
|
58 |
{ 0.0f, 1.0f,-1.5f }, |
|
59 |
{-1.5f, 1.0f, 0.0f }, |
|
60 |
{ 0.0f,-1.0f, 1.5f }, |
|
61 |
{ 1.5f,-1.0f, 0.0f }, |
|
62 |
{ 0.0f,-1.0f,-1.5f }, |
|
63 |
{-1.5f,-1.0f, 0.0f }, |
|
64 |
|
|
65 |
{ Y, 1.0f, 1.5f }, |
|
66 |
{ 1.5f, 1.0f, -Y }, |
|
67 |
{ -Y, 1.0f,-1.5f }, |
|
68 |
{-1.5f, 1.0f, Y }, |
|
69 |
{ Y,-1.0f, 1.5f }, |
|
70 |
{ 1.5f,-1.0f, -Y }, |
|
71 |
{ -Y,-1.0f,-1.5f }, |
|
72 |
{-1.5f,-1.0f, Y }, |
|
73 |
|
|
74 |
{ 1.5f, 1.0f, Y }, |
|
75 |
{ Y, 1.0f,-1.5f }, |
|
76 |
{-1.5f, 1.0f, -Y }, |
|
77 |
{ -Y, 1.0f, 1.5f }, |
|
78 |
{ 1.5f,-1.0f, Y }, |
|
79 |
{ Y,-1.0f,-1.5f }, |
|
80 |
{-1.5f,-1.0f, -Y }, |
|
81 |
{ -Y,-1.0f, 1.5f }, |
|
82 |
}; |
|
83 |
|
|
84 |
private static final double[][] VERTICES_CORNER = new double[][] |
|
85 |
{ |
|
86 |
{ X-1.5+Z, 0.5, 0.0 }, |
|
87 |
{ Z, 0.5, 0.0 }, |
|
88 |
{ -1.5+Z, 0.5, -1.5 }, |
|
89 |
{ X-1.5+Z,-0.5, 0.0 }, |
|
90 |
{ Z,-0.5, 0.0 }, |
|
91 |
{ -1.5+Z,-0.5, -1.5 } |
|
92 |
}; |
|
93 |
|
|
94 |
private static final int[][] VERT_INDEXES_CORNER = new int[][] |
|
95 |
{ |
|
96 |
{0,1,2}, // counterclockwise! |
|
97 |
{5,4,3}, |
|
98 |
{3,4,1,0}, |
|
99 |
{4,5,2,1}, |
|
100 |
{5,3,0,2} |
|
101 |
}; |
|
102 |
|
|
103 |
private static final float[][] STICKERS = new float[][] |
|
104 |
{ |
|
105 |
{ -0.5f, -0.26289170f, 0.5f, -0.26289170f, 0.5f, 0.26289170f, -0.5f, 0.26289170f }, // middle front |
|
106 |
{ -0.5f, -0.16666667f, 0.5f, -0.16666667f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }, // middle right |
|
107 |
{ -0.5f, -0.45534182f, 0.5f, -0.45534182f, 0.5f, 0.45534182f, -0.5f, 0.45534182f }, // middle back |
|
108 |
{ -0.20096192f, -0.25f, 0.20096192f, -0.25f, 0.0f, 0.5f }, // edge top |
|
109 |
{ -0.40192384f, -0.5f, 0.40192384f, -0.5f, 0.40192384f, 0.5f, -0.40192384f, 0.5f }, // edge face |
|
110 |
{ -0.11602539f, -0.25f, 0.4330127f, -0.25f, -0.3169873f, 0.5f } // corner top |
|
111 |
}; |
|
112 |
|
|
113 |
private static final int NUM_STICKERS = STICKERS.length; |
|
114 |
|
|
115 |
private static final int[][] mStickerType = new int[][] |
|
116 |
{ |
|
117 |
{ NUM_STICKERS,NUM_STICKERS,0, 1, 2,NUM_STICKERS }, |
|
118 |
{ 3,NUM_STICKERS,4,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS }, |
|
119 |
{ 5,NUM_STICKERS,2,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS }, |
|
120 |
{ NUM_STICKERS, 5,2,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS } |
|
121 |
}; |
|
122 |
|
|
123 |
// YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5 |
|
124 |
private static final int[][] mStickerColor = new int[][] |
|
125 |
{ |
|
126 |
{ 0, 0, 4, 0, 5, 0 }, // 0 |
|
127 |
{ 0, 0, 5, 1, 4, 0 }, |
|
128 |
|
|
129 |
{ 2, 0, 4, 0, 0, 0 }, // 2 |
|
130 |
{ 2, 0, 0, 0, 0, 0 }, |
|
131 |
{ 2, 0, 5, 0, 0, 0 }, |
|
132 |
{ 2, 0, 1, 0, 0, 0 }, |
|
133 |
{ 3, 0, 4, 0, 0, 0 }, |
|
134 |
{ 3, 0, 0, 0, 0, 0 }, |
|
135 |
{ 3, 0, 5, 0, 0, 0 }, |
|
136 |
{ 3, 0, 1, 0, 0, 0 }, |
|
137 |
|
|
138 |
{ 2, 0, 4, 0, 0, 0 }, // 10 |
|
139 |
{ 2, 0, 0, 0, 0, 0 }, |
|
140 |
{ 2, 0, 5, 0, 0, 0 }, |
|
141 |
{ 2, 0, 1, 0, 0, 0 }, |
|
142 |
{ 0, 3, 4, 0, 0, 0 }, |
|
143 |
{ 0, 3, 0, 0, 0, 0 }, |
|
144 |
{ 0, 3, 5, 0, 0, 0 }, |
|
145 |
{ 0, 3, 1, 0, 0, 0 }, |
|
146 |
|
|
147 |
{ 0, 2, 0, 0, 0, 0 }, // 18 |
|
148 |
{ 0, 2, 5, 0, 0, 0 }, |
|
149 |
{ 0, 2, 1, 0, 0, 0 }, |
|
150 |
{ 0, 2, 4, 0, 0, 0 }, |
|
151 |
{ 3, 0, 0, 0, 0, 0 }, |
|
152 |
{ 3, 0, 5, 0, 0, 0 }, |
|
153 |
{ 3, 0, 1, 0, 0, 0 }, |
|
154 |
{ 3, 0, 4, 0, 0, 0 }, |
|
155 |
}; |
|
156 |
|
|
157 |
private static final ObjectSticker[] mStickers; |
|
158 |
|
|
159 |
static |
|
160 |
{ |
|
161 |
mStickers = new ObjectSticker[NUM_STICKERS]; |
|
162 |
final float R1 = 0.06f; |
|
163 |
final float R2 = 0.04f; |
|
164 |
final float R3 = 0.11f; |
|
165 |
final float R4 = 0.03f; |
|
166 |
final float R5 = 0.11f; |
|
167 |
final float R6 = 0.025f; |
|
168 |
final float[][] radii = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6} }; |
|
169 |
final float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.06f }; |
|
170 |
|
|
171 |
for(int s=0; s<NUM_STICKERS; s++) |
|
172 |
{ |
|
173 |
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); |
|
174 |
} |
|
175 |
} |
|
39 |
private static final int NUM_STICKERS = 6; |
|
176 | 40 |
|
177 | 41 |
private int mCurrState; |
178 | 42 |
private int mIndexExcluded; |
179 | 43 |
private final ScrambleState[] mStates; |
180 | 44 |
private int[][] mScrambleTable; |
181 | 45 |
private int[] mNumOccurences; |
46 |
private int[] mQuatNumber; |
|
47 |
private float[][] mCenters; |
|
48 |
private int[][] mStickerColor; |
|
49 |
private int[][] mStickerType; |
|
50 |
private ObjectSticker[] mStickers; |
|
182 | 51 |
|
183 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
184 | 53 |
|
... | ... | |
218 | 87 |
|
219 | 88 |
if( variant==0 ) |
220 | 89 |
{ |
90 |
double[][] vertices = new double[][] |
|
91 |
{ |
|
92 |
{ -1.5-X, 0.5, 1.5 }, |
|
93 |
{ 0.0, 0.5, 1.5 }, |
|
94 |
{ 0.0, 0.5,-1.5 }, |
|
95 |
{ -1.5+X, 0.5,-1.5 }, |
|
96 |
{ -1.5-X,-0.5, 1.5 }, |
|
97 |
{ 0.0,-0.5, 1.5 }, |
|
98 |
{ 0.0,-0.5,-1.5 }, |
|
99 |
{ -1.5+X,-0.5,-1.5 } |
|
100 |
}; |
|
101 |
|
|
102 |
int[][] vert_indices = new int[][] |
|
103 |
{ |
|
104 |
{0,1,2,3}, |
|
105 |
{4,5,6,7}, |
|
106 |
{4,5,1,0}, |
|
107 |
{5,6,2,1}, |
|
108 |
{6,7,3,2}, |
|
109 |
{7,4,0,3} |
|
110 |
}; |
|
111 |
|
|
221 | 112 |
float[][] bands = new float[][] { {0.040f,35,0.8f,1.0f,5,2,1}, {0.020f,35,0.8f,1.0f,5,2,1}, {0.001f,35,0.8f,1.0f,5,2,1} }; |
222 | 113 |
int[] bandIndices = new int[] { 2,2,1,1,0,2 }; |
223 | 114 |
float[][] corners = new float[][] { {0.03f,0.05f} }; |
224 | 115 |
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
225 | 116 |
float[][] centers = new float[][] { { -0.75f, 0.0f, 0.0f} }; |
226 | 117 |
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
227 |
return new ObjectShape(VERTICES_MIDDLE,VERT_INDEXES_MIDDLE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
118 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
228 | 119 |
} |
229 | 120 |
else if( variant==1 ) |
230 | 121 |
{ |
122 |
double[][] vertices = new double[][] |
|
123 |
{ |
|
124 |
{ -X, 0.5, 0.0 }, |
|
125 |
{ +X, 0.5, 0.0 }, |
|
126 |
{0.0, 0.5,-1.5 }, |
|
127 |
{ -X,-0.5, 0.0 }, |
|
128 |
{ +X,-0.5, 0.0 }, |
|
129 |
{0.0,-0.5,-1.5 }, |
|
130 |
}; |
|
131 |
|
|
132 |
int[][] vert_indices = new int[][] |
|
133 |
{ |
|
134 |
{0,1,2}, |
|
135 |
{3,4,5}, |
|
136 |
{3,4,1,0}, |
|
137 |
{4,5,2,1}, |
|
138 |
{5,3,0,2} |
|
139 |
}; |
|
140 |
|
|
231 | 141 |
float[][] bands = new float[][] { {0.038f,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} }; |
232 | 142 |
int[] bandIndices = new int[] { 0,1,0,1,1 }; |
233 | 143 |
float[][] corners = new float[][] { {0.04f,0.15f} }; |
234 | 144 |
int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 }; |
235 | 145 |
float[][] centers = new float[][] { { 0.0f, 0.0f,-0.5f} }; |
236 | 146 |
int[] centerIndices = new int[] { 0,0,-1,0,0,-1 }; |
237 |
return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
147 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
238 | 148 |
} |
239 | 149 |
else |
240 | 150 |
{ |
151 |
double[][] vertices = new double[][] |
|
152 |
{ |
|
153 |
{-0.75f+X/2, 0.5, 0.0 }, |
|
154 |
{ 0.75f-X/2, 0.5, 0.0 }, |
|
155 |
{-0.75f-X/2, 0.5, -1.5 }, |
|
156 |
{-0.75f+X/2,-0.5, 0.0 }, |
|
157 |
{ 0.75f-X/2,-0.5, 0.0 }, |
|
158 |
{-0.75f-X/2,-0.5, -1.5 } |
|
159 |
}; |
|
160 |
int[][] vert_indices = new int[][] |
|
161 |
{ |
|
162 |
{0,1,2}, |
|
163 |
{5,4,3}, |
|
164 |
{3,4,1,0}, |
|
165 |
{4,5,2,1}, |
|
166 |
{5,3,0,2} |
|
167 |
}; |
|
168 |
|
|
241 | 169 |
float[][] bands = new float[][] { {0.030f,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} }; |
242 | 170 |
int[] bandIndices = new int[] { 0,0,0,1,1 }; |
243 | 171 |
float[][] corners = new float[][] { {0.05f,0.13f} }; |
244 | 172 |
int[] cornerIndices = new int[] { 0,0,-1,0,0,-1 }; |
245 | 173 |
float[][] centers = new float[][] { { 0.0f, 0.0f,-0.5f} }; |
246 | 174 |
int[] centerIndices = new int[] { 0,0,-1,0,0,-1 }; |
247 |
return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
175 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
|
248 | 176 |
} |
249 | 177 |
} |
250 | 178 |
|
... | ... | |
252 | 180 |
|
253 | 181 |
Static4D getQuat(int cubit, int numLayers) |
254 | 182 |
{ |
255 |
return QUATS[QUAT_NUMBER[cubit]]; |
|
183 |
if( mQuats==null ) initializeQuats(); |
|
184 |
|
|
185 |
if( mQuatNumber ==null ) |
|
186 |
{ |
|
187 |
mQuatNumber = new int[] |
|
188 |
{ |
|
189 |
0, 6, |
|
190 |
0, 9, 6, 3, 18, 15, 12, 21, |
|
191 |
0, 9, 6, 3, 0, 9, 6, 3, |
|
192 |
15, 12, 21, 18, 15, 12, 21, 18 |
|
193 |
}; |
|
194 |
} |
|
195 |
|
|
196 |
return mQuats[mQuatNumber[cubit]]; |
|
256 | 197 |
} |
257 | 198 |
|
258 | 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
273 | 214 |
|
274 | 215 |
ObjectSticker retSticker(int face) |
275 | 216 |
{ |
217 |
if( mStickers==null ) |
|
218 |
{ |
|
219 |
float[][] STICKERS = new float[][] |
|
220 |
{ |
|
221 |
{ -0.5f, -0.26289170f, 0.5f, -0.26289170f, 0.5f, 0.26289170f, -0.5f, 0.26289170f }, // middle front |
|
222 |
{ -0.5f, -0.16666667f, 0.5f, -0.16666667f, 0.5f, 0.16666667f, -0.5f, 0.16666667f }, // middle right |
|
223 |
{ -0.5f, -0.45534182f, 0.5f, -0.45534182f, 0.5f, 0.45534182f, -0.5f, 0.45534182f }, // middle back |
|
224 |
{ -0.20096192f, -0.25f, 0.20096192f, -0.25f, 0.0f, 0.5f }, // edge top |
|
225 |
{ -0.40192384f, -0.5f, 0.40192384f, -0.5f, 0.40192384f, 0.5f, -0.40192384f, 0.5f }, // edge face |
|
226 |
{ -0.11602539f, -0.25f, 0.4330127f, -0.25f, -0.3169873f, 0.5f } // corner top |
|
227 |
}; |
|
228 |
|
|
229 |
final float R1 = 0.06f; |
|
230 |
final float R2 = 0.04f; |
|
231 |
final float R3 = 0.11f; |
|
232 |
final float R4 = 0.03f; |
|
233 |
final float R5 = 0.11f; |
|
234 |
final float R6 = 0.025f; |
|
235 |
final float[][] radii = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6} }; |
|
236 |
final float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.06f }; |
|
237 |
|
|
238 |
mStickers = new ObjectSticker[NUM_STICKERS]; |
|
239 |
|
|
240 |
for(int s=0; s<NUM_STICKERS; s++) |
|
241 |
{ |
|
242 |
mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]); |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
276 | 246 |
return mStickers[face/NUM_FACES]; |
277 | 247 |
} |
278 | 248 |
|
... | ... | |
280 | 250 |
|
281 | 251 |
float[][] getCubitPositions(int numLayers) |
282 | 252 |
{ |
283 |
return CENTERS; |
|
253 |
if( mCenters ==null ) |
|
254 |
{ |
|
255 |
float Y = 0.75f + X/2; |
|
256 |
|
|
257 |
mCenters = new float[][] |
|
258 |
{ |
|
259 |
{ 1.5f, 0.0f, 0.0f }, |
|
260 |
{-1.5f, 0.0f, 0.0f }, |
|
261 |
|
|
262 |
{ 0.0f, 1.0f, 1.5f }, |
|
263 |
{ 1.5f, 1.0f, 0.0f }, |
|
264 |
{ 0.0f, 1.0f,-1.5f }, |
|
265 |
{-1.5f, 1.0f, 0.0f }, |
|
266 |
{ 0.0f,-1.0f, 1.5f }, |
|
267 |
{ 1.5f,-1.0f, 0.0f }, |
|
268 |
{ 0.0f,-1.0f,-1.5f }, |
|
269 |
{-1.5f,-1.0f, 0.0f }, |
|
270 |
|
|
271 |
{ Y, 1.0f, 1.5f }, |
|
272 |
{ 1.5f, 1.0f, -Y }, |
|
273 |
{ -Y, 1.0f,-1.5f }, |
|
274 |
{-1.5f, 1.0f, Y }, |
|
275 |
{ Y,-1.0f, 1.5f }, |
|
276 |
{ 1.5f,-1.0f, -Y }, |
|
277 |
{ -Y,-1.0f,-1.5f }, |
|
278 |
{-1.5f,-1.0f, Y }, |
|
279 |
|
|
280 |
{ 1.5f, 1.0f, Y }, |
|
281 |
{ Y, 1.0f,-1.5f }, |
|
282 |
{-1.5f, 1.0f, -Y }, |
|
283 |
{ -Y, 1.0f, 1.5f }, |
|
284 |
{ 1.5f,-1.0f, Y }, |
|
285 |
{ Y,-1.0f,-1.5f }, |
|
286 |
{-1.5f,-1.0f, -Y }, |
|
287 |
{ -Y,-1.0f, 1.5f }, |
|
288 |
}; |
|
289 |
} |
|
290 |
|
|
291 |
return mCenters; |
|
284 | 292 |
} |
285 | 293 |
|
286 | 294 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
301 | 309 |
|
302 | 310 |
int getFaceColor(int cubit, int cubitface, int numLayers) |
303 | 311 |
{ |
312 |
if( mStickerColor==null ) |
|
313 |
{ |
|
314 |
// YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5 |
|
315 |
mStickerColor = new int[][] |
|
316 |
{ |
|
317 |
{ 0, 0, 4, 0, 5, 0 }, // 0 |
|
318 |
{ 0, 0, 5, 1, 4, 0 }, |
|
319 |
|
|
320 |
{ 2, 0, 4, 0, 0, 0 }, // 2 |
|
321 |
{ 2, 0, 0, 0, 0, 0 }, |
|
322 |
{ 2, 0, 5, 0, 0, 0 }, |
|
323 |
{ 2, 0, 1, 0, 0, 0 }, |
|
324 |
{ 3, 0, 4, 0, 0, 0 }, |
|
325 |
{ 3, 0, 0, 0, 0, 0 }, |
|
326 |
{ 3, 0, 5, 0, 0, 0 }, |
|
327 |
{ 3, 0, 1, 0, 0, 0 }, |
|
328 |
|
|
329 |
{ 2, 0, 4, 0, 0, 0 }, // 10 |
|
330 |
{ 2, 0, 0, 0, 0, 0 }, |
|
331 |
{ 2, 0, 5, 0, 0, 0 }, |
|
332 |
{ 2, 0, 1, 0, 0, 0 }, |
|
333 |
{ 0, 3, 4, 0, 0, 0 }, |
|
334 |
{ 0, 3, 0, 0, 0, 0 }, |
|
335 |
{ 0, 3, 5, 0, 0, 0 }, |
|
336 |
{ 0, 3, 1, 0, 0, 0 }, |
|
337 |
|
|
338 |
{ 0, 2, 0, 0, 0, 0 }, // 18 |
|
339 |
{ 0, 2, 5, 0, 0, 0 }, |
|
340 |
{ 0, 2, 1, 0, 0, 0 }, |
|
341 |
{ 0, 2, 4, 0, 0, 0 }, |
|
342 |
{ 3, 0, 0, 0, 0, 0 }, |
|
343 |
{ 3, 0, 5, 0, 0, 0 }, |
|
344 |
{ 3, 0, 1, 0, 0, 0 }, |
|
345 |
{ 3, 0, 4, 0, 0, 0 }, |
|
346 |
}; |
|
347 |
} |
|
348 |
|
|
349 |
if( mStickerType==null ) |
|
350 |
{ |
|
351 |
mStickerType = new int[][] |
|
352 |
{ |
|
353 |
{ NUM_STICKERS,NUM_STICKERS,0, 1, 2,NUM_STICKERS }, |
|
354 |
{ 3,NUM_STICKERS,4,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS }, |
|
355 |
{ 5,NUM_STICKERS,2,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS }, |
|
356 |
{ NUM_STICKERS, 5,2,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS } |
|
357 |
}; |
|
358 |
} |
|
359 |
|
|
304 | 360 |
int type; |
305 | 361 |
|
306 | 362 |
if( cubit< 2 ) type = 0; |
Also available in: Unified diff
Remove statics from the Square classes.