Revision a7496a08
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/MovementUltimate.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
class MovementUltimate extends Movement |
33 | 33 |
{ |
34 |
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5)/3;
|
|
35 |
static final float DIST2D = (0.5f*SIN54/COS54)/3;
|
|
34 |
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5)/2;
|
|
35 |
static final float DIST2D = (0.5f*SIN54/COS54)/2;
|
|
36 | 36 |
|
37 | 37 |
static final Static3D[] FACE_AXIS = new Static3D[] |
38 | 38 |
{ |
... | ... | |
61 | 61 |
|
62 | 62 |
int computeRowFromOffset(int face, int size, float offset) |
63 | 63 |
{ |
64 |
if( size==3 ) |
|
65 |
{ |
|
66 |
return offset<DIST2D ? 0:2; |
|
67 |
} |
|
68 |
if( size==5 ) |
|
69 |
{ |
|
70 |
float quot = offset / DIST2D; |
|
71 |
|
|
72 |
if( quot>0.00f && quot<=0.34f ) return 0; |
|
73 |
if( quot>0.34f && quot<=1.00f ) return 1; |
|
74 |
if( quot>1.00f && quot<=1.66f ) return 3; |
|
75 |
if( quot>1.66f && quot<=2.00f ) return 4; |
|
76 |
} |
|
77 |
|
|
78 |
return 0; |
|
64 |
return offset<DIST2D ? 0:1; |
|
79 | 65 |
} |
80 | 66 |
|
81 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
131 | 117 |
} |
132 | 118 |
|
133 | 119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 |
// Return 1,2,3,4,5 - the vertex of the pentagon to which point 'point' is the closest, if the |
|
135 |
// 'point' is inside the pentagon - or 0 otherwise. |
|
136 |
// The 'first' vertex is the one we meet the first when we rotate clockwise starting from 12:00. |
|
137 |
// This vertex makes angle 'returnAngle()' with the line coming out upwards from the center of the |
|
138 |
// pentagon. |
|
139 |
// Distance from the center to a vertex of the pentagon = 1/(6*COS54) |
|
140 | 120 |
|
141 | 121 |
private int returnPartOfThePentagon(float[] point, int face) |
142 | 122 |
{ |
... | ... | |
148 | 128 |
if( isOnTheLeft(point, DIST2D, (9-2*i)*A-angle) ) return 0; |
149 | 129 |
} |
150 | 130 |
|
151 |
if( isOnTheLeft(point, 0, 2.5f*A-angle) ) |
|
152 |
{ |
|
153 |
if( isOnTheLeft(point, 0, 3.5f*A-angle) ) |
|
154 |
{ |
|
155 |
return isOnTheLeft(point, 0, 5.5f*A-angle) ? 4 : 5; |
|
156 |
} |
|
157 |
else return 1; |
|
158 |
} |
|
159 |
else |
|
160 |
{ |
|
161 |
if( isOnTheLeft(point, 0, 4.5f*A-angle) ) |
|
162 |
{ |
|
163 |
return 3; |
|
164 |
} |
|
165 |
else |
|
166 |
{ |
|
167 |
return isOnTheLeft(point, 0, 6.5f*A-angle) ? 2 : 1; |
|
168 |
} |
|
169 |
} |
|
131 |
return 1; |
|
170 | 132 |
} |
171 | 133 |
|
172 | 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
180 | 142 |
|
181 | 143 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
182 | 144 |
{ |
183 |
int part = returnPartOfThePentagon(touchPoint,face); |
|
184 |
|
|
185 |
if( part>0 ) |
|
186 |
{ |
|
187 |
enabled[0] = 2; |
|
188 |
|
|
189 |
switch(face) |
|
190 |
{ |
|
191 |
case 0: switch(part) |
|
192 |
{ |
|
193 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
194 |
case 2: enabled[1]=3; enabled[2]=5; break; |
|
195 |
case 3: enabled[1]=5; enabled[2]=1; break; |
|
196 |
case 4: enabled[1]=1; enabled[2]=4; break; |
|
197 |
case 5: enabled[1]=4; enabled[2]=2; break; |
|
198 |
} |
|
199 |
break; |
|
145 |
enabled[0] = 2; |
|
200 | 146 |
|
201 |
case 1: switch(part) |
|
202 |
{ |
|
203 |
case 1: enabled[1]=0; enabled[2]=5; break; |
|
204 |
case 2: enabled[1]=5; enabled[2]=2; break; |
|
205 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
206 |
case 4: enabled[1]=3; enabled[2]=4; break; |
|
207 |
case 5: enabled[1]=4; enabled[2]=0; break; |
|
208 |
} |
|
209 |
break; |
|
210 |
|
|
211 |
case 2: switch(part) |
|
212 |
{ |
|
213 |
case 1: enabled[1]=3; enabled[2]=2; break; |
|
214 |
case 2: enabled[1]=2; enabled[2]=5; break; |
|
215 |
case 3: enabled[1]=5; enabled[2]=0; break; |
|
216 |
case 4: enabled[1]=0; enabled[2]=4; break; |
|
217 |
case 5: enabled[1]=4; enabled[2]=3; break; |
|
218 |
} |
|
219 |
break; |
|
220 |
|
|
221 |
case 3: switch(part) |
|
222 |
{ |
|
223 |
case 1: enabled[1]=1; enabled[2]=5; break; |
|
224 |
case 2: enabled[1]=5; enabled[2]=3; break; |
|
225 |
case 3: enabled[1]=3; enabled[2]=2; break; |
|
226 |
case 4: enabled[1]=2; enabled[2]=4; break; |
|
227 |
case 5: enabled[1]=4; enabled[2]=1; break; |
|
228 |
} |
|
229 |
break; |
|
230 |
|
|
231 |
case 4: switch(part) |
|
232 |
{ |
|
233 |
case 1: enabled[1]=3; enabled[2]=0; break; |
|
234 |
case 2: enabled[1]=0; enabled[2]=4; break; |
|
235 |
case 3: enabled[1]=4; enabled[2]=5; break; |
|
236 |
case 4: enabled[1]=5; enabled[2]=1; break; |
|
237 |
case 5: enabled[1]=1; enabled[2]=3; break; |
|
238 |
} |
|
239 |
break; |
|
240 |
|
|
241 |
case 5: switch(part) |
|
242 |
{ |
|
243 |
case 1: enabled[1]=2; enabled[2]=1; break; |
|
244 |
case 2: enabled[1]=1; enabled[2]=4; break; |
|
245 |
case 3: enabled[1]=4; enabled[2]=5; break; |
|
246 |
case 4: enabled[1]=5; enabled[2]=0; break; |
|
247 |
case 5: enabled[1]=0; enabled[2]=2; break; |
|
248 |
} |
|
249 |
break; |
|
250 |
|
|
251 |
case 6: switch(part) |
|
252 |
{ |
|
253 |
case 1: enabled[1]=5; enabled[2]=4; break; |
|
254 |
case 2: enabled[1]=4; enabled[2]=1; break; |
|
255 |
case 3: enabled[1]=1; enabled[2]=2; break; |
|
256 |
case 4: enabled[1]=2; enabled[2]=0; break; |
|
257 |
case 5: enabled[1]=0; enabled[2]=5; break; |
|
258 |
} |
|
259 |
break; |
|
260 |
|
|
261 |
case 7: switch(part) |
|
262 |
{ |
|
263 |
case 1: enabled[1]=5; enabled[2]=4; break; |
|
264 |
case 2: enabled[1]=4; enabled[2]=0; break; |
|
265 |
case 3: enabled[1]=0; enabled[2]=3; break; |
|
266 |
case 4: enabled[1]=3; enabled[2]=1; break; |
|
267 |
case 5: enabled[1]=1; enabled[2]=5; break; |
|
268 |
} |
|
269 |
break; |
|
270 |
|
|
271 |
case 8: switch(part) |
|
272 |
{ |
|
273 |
case 1: enabled[1]=2; enabled[2]=0; break; |
|
274 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
275 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
276 |
case 4: enabled[1]=3; enabled[2]=5; break; |
|
277 |
case 5: enabled[1]=5; enabled[2]=2; break; |
|
278 |
} |
|
279 |
break; |
|
280 |
|
|
281 |
case 9: switch(part) |
|
282 |
{ |
|
283 |
case 1: enabled[1]=3; enabled[2]=4; break; |
|
284 |
case 2: enabled[1]=4; enabled[2]=2; break; |
|
285 |
case 3: enabled[1]=2; enabled[2]=1; break; |
|
286 |
case 4: enabled[1]=1; enabled[2]=0; break; |
|
287 |
case 5: enabled[1]=0; enabled[2]=3; break; |
|
288 |
} |
|
289 |
break; |
|
290 |
|
|
291 |
case 10: switch(part) |
|
292 |
{ |
|
293 |
case 1: enabled[1]=2; enabled[2]=4; break; |
|
294 |
case 2: enabled[1]=4; enabled[2]=3; break; |
|
295 |
case 3: enabled[1]=3; enabled[2]=0; break; |
|
296 |
case 4: enabled[1]=0; enabled[2]=1; break; |
|
297 |
case 5: enabled[1]=1; enabled[2]=2; break; |
|
298 |
} |
|
299 |
break; |
|
300 |
|
|
301 |
case 11: switch(part) |
|
302 |
{ |
|
303 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
304 |
case 2: enabled[1]=1; enabled[2]=0; break; |
|
305 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
306 |
case 4: enabled[1]=2; enabled[2]=5; break; |
|
307 |
case 5: enabled[1]=5; enabled[2]=3; break; |
|
308 |
} |
|
309 |
break; |
|
310 |
} |
|
311 |
} |
|
312 |
else |
|
147 |
switch(face) |
|
313 | 148 |
{ |
314 |
enabled[0] = 0; |
|
149 |
case 0: enabled[1] = 2; enabled[2] = 3; break; |
|
150 |
case 1: enabled[1] = 1; enabled[2] = 3; break; |
|
151 |
case 2: enabled[1] = 1; enabled[2] = 3; break; |
|
152 |
case 3: enabled[1] = 2; enabled[2] = 3; break; |
|
153 |
case 4: enabled[1] = 0; enabled[2] = 3; break; |
|
154 |
case 5: enabled[1] = 0; enabled[2] = 2; break; |
|
155 |
case 6: enabled[1] = 0; enabled[2] = 2; break; |
|
156 |
case 7: enabled[1] = 0; enabled[2] = 3; break; |
|
157 |
case 8: enabled[1] = 1; enabled[2] = 2; break; |
|
158 |
case 9: enabled[1] = 0; enabled[2] = 1; break; |
|
159 |
case 10: enabled[1] = 0; enabled[2] = 1; break; |
|
160 |
case 11: enabled[1] = 1; enabled[2] = 2; break; |
|
315 | 161 |
} |
316 | 162 |
} |
317 | 163 |
} |
Also available in: Unified diff
Skewb Ultimate (hopefully) finished.