Revision e6734aa9
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/MovementSquare.java | ||
---|---|---|
67 | 67 |
|
68 | 68 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
69 | 69 |
{ |
70 |
enabled[0] = 2; |
|
71 |
|
|
72 | 70 |
switch(face) |
73 | 71 |
{ |
74 | 72 |
case 0: |
75 |
case 1: enabled[1]=1; enabled[2]=2; break;
|
|
73 |
case 1: enabled[0]=1; enabled[1]=0; break;
|
|
76 | 74 |
case 2: |
77 |
case 3: enabled[1]=0; enabled[2]=2; break;
|
|
75 |
case 3: enabled[0]=1; enabled[1]=1; break;
|
|
78 | 76 |
case 4: |
79 |
case 5: enabled[1]=0; enabled[2]=1; break; |
|
77 |
case 5: enabled[0]=2; enabled[1]=0; enabled[2]=1; break;
|
|
80 | 78 |
} |
81 | 79 |
} |
82 | 80 |
} |
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java | ||
---|---|---|
425 | 425 |
|
426 | 426 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
427 | 427 |
|
428 |
float[] getCuts(int numLayers) |
|
428 |
float[][] getCuts(int numLayers)
|
|
429 | 429 |
{ |
430 |
float[] cuts = new float[numLayers-1];
|
|
430 |
float[][] cuts = new float[3][numLayers-1];
|
|
431 | 431 |
|
432 | 432 |
for(int i=0; i<numLayers-1; i++) |
433 | 433 |
{ |
434 |
cuts[i] = (2-numLayers)*0.5f + i; |
|
434 |
float cut = (2-numLayers)*0.5f + i; |
|
435 |
cuts[0][i] = cut; |
|
436 |
cuts[1][i] = cut; |
|
437 |
cuts[2][i] = cut; |
|
435 | 438 |
} |
436 | 439 |
|
437 | 440 |
return cuts; |
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
232 | 232 |
|
233 | 233 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
234 | 234 |
|
235 |
float[] getCuts(int numLayers) |
|
235 |
float[][] getCuts(int numLayers)
|
|
236 | 236 |
{ |
237 |
float[] cuts = new float[numLayers-1];
|
|
237 |
float[][] cuts = new float[3][numLayers-1];
|
|
238 | 238 |
|
239 | 239 |
for(int i=0; i<numLayers-1; i++) |
240 | 240 |
{ |
241 |
cuts[i] = (2-numLayers)*0.5f + i; |
|
241 |
float cut = (2-numLayers)*0.5f + i; |
|
242 |
cuts[0][i] = cut; |
|
243 |
cuts[1][i] = cut; |
|
244 |
cuts[2][i] = cut; |
|
242 | 245 |
} |
243 | 246 |
|
244 | 247 |
return cuts; |
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
185 | 185 |
|
186 | 186 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
187 | 187 |
|
188 |
float[] getCuts(int numLayers) |
|
188 |
float[][] getCuts(int numLayers)
|
|
189 | 189 |
{ |
190 | 190 |
if( numLayers<2 ) |
191 | 191 |
{ |
... | ... | |
193 | 193 |
} |
194 | 194 |
else |
195 | 195 |
{ |
196 |
float[] cuts = new float[numLayers-1];
|
|
196 |
float[][] cuts = new float[4][numLayers-1];
|
|
197 | 197 |
float dist = SQ6*0.666f*DIST; |
198 | 198 |
float cut = 0.5f*dist*(2-numLayers); |
199 | 199 |
|
200 | 200 |
for(int i=0; i<numLayers-1; i++) |
201 | 201 |
{ |
202 |
cuts[i] = cut; |
|
202 |
cuts[0][i] = cut; |
|
203 |
cuts[1][i] = cut; |
|
204 |
cuts[2][i] = cut; |
|
205 |
cuts[3][i] = cut; |
|
203 | 206 |
cut += dist; |
204 | 207 |
} |
205 | 208 |
|
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
143 | 143 |
|
144 | 144 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
145 | 145 |
|
146 |
float[] getCuts(int size) |
|
146 |
float[][] getCuts(int size)
|
|
147 | 147 |
{ |
148 |
return new float[] { -SQ3/3, +SQ3/3 }; |
|
148 |
float[] cut = new float[] { -SQ3/3, +SQ3/3 }; |
|
149 |
return new float[][] { cut,cut,cut,cut }; |
|
149 | 150 |
} |
150 | 151 |
|
151 | 152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
275 | 275 |
|
276 | 276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
277 | 277 |
|
278 |
float[] getCuts(int size) |
|
278 |
float[][] getCuts(int size)
|
|
279 | 279 |
{ |
280 |
float[] cuts = new float[2]; |
|
281 |
|
|
282 |
cuts[0] = -SQ2/4; |
|
283 |
cuts[1] = +SQ2/4; |
|
284 |
|
|
285 |
return cuts; |
|
280 |
float[] cut = new float[] { -SQ2/4, +SQ2/4 }; |
|
281 |
return new float[][] { cut,cut,cut,cut,cut,cut }; |
|
286 | 282 |
} |
287 | 283 |
|
288 | 284 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
152 | 152 |
|
153 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
154 | 154 |
|
155 |
float[] getCuts(int numLayers) |
|
155 |
float[][] getCuts(int numLayers)
|
|
156 | 156 |
{ |
157 |
float[] cuts = new float[1]; |
|
158 |
cuts[0] = 0.0f; |
|
159 |
|
|
160 |
return cuts; |
|
157 |
float[] cut = new float[] {0.0f}; |
|
158 |
return new float[][] { cut,cut,cut,cut }; |
|
161 | 159 |
} |
162 | 160 |
|
163 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyKilominx.java | ||
---|---|---|
117 | 117 |
|
118 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
119 | 119 |
|
120 |
float[] getCuts(int numLayers) |
|
120 |
float[][] getCuts(int numLayers)
|
|
121 | 121 |
{ |
122 |
float[] cuts = new float[numLayers-1];
|
|
122 |
float[][] cuts = new float[6][numLayers-1];
|
|
123 | 123 |
float D = numLayers*MovementMinx.DIST3D; |
124 | 124 |
float E = 2*SIN54; |
125 | 125 |
float X = 2*D*E/(1+2*E); // height of the 'upper' part of a dodecahedron, i.e. put it on a table, |
... | ... | |
131 | 131 |
|
132 | 132 |
for(int i=0; i<num; i++) |
133 | 133 |
{ |
134 |
cuts[ i] = -D + (i+0.5f)*G; |
|
135 |
cuts[2*num-1-i] = -cuts[i]; |
|
134 |
float cut = -D + (i+0.5f)*G; |
|
135 |
int j = 2*num-1-i; |
|
136 |
cuts[0][i] = +cut; |
|
137 |
cuts[0][j] = -cut; |
|
138 |
cuts[1][i] = +cut; |
|
139 |
cuts[1][j] = -cut; |
|
140 |
cuts[2][i] = +cut; |
|
141 |
cuts[2][j] = -cut; |
|
142 |
cuts[3][i] = +cut; |
|
143 |
cuts[3][j] = -cut; |
|
144 |
cuts[4][i] = +cut; |
|
145 |
cuts[4][j] = -cut; |
|
146 |
cuts[5][i] = +cut; |
|
147 |
cuts[5][j] = -cut; |
|
136 | 148 |
} |
137 | 149 |
|
138 | 150 |
return cuts; |
src/main/java/org/distorted/objects/TwistyMegaminx.java | ||
---|---|---|
96 | 96 |
|
97 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
98 | 98 |
|
99 |
float[] getCuts(int numLayers) |
|
99 |
float[][] getCuts(int numLayers)
|
|
100 | 100 |
{ |
101 |
float[] cuts = new float[numLayers-1];
|
|
101 |
float[][] cuts = new float[6][numLayers-1];
|
|
102 | 102 |
float D = numLayers*MovementMinx.DIST3D; |
103 | 103 |
float E = 2*SIN54; |
104 | 104 |
float X = 2*D*E/(1+2*E); // height of the 'upper' part of a dodecahedron, i.e. put it on a table, |
... | ... | |
110 | 110 |
|
111 | 111 |
for(int i=0; i<num; i++) |
112 | 112 |
{ |
113 |
cuts[ i] = -D + (i+0.5f)*G; |
|
114 |
cuts[2*num-1-i] = -cuts[i]; |
|
113 |
float cut = -D + (i+0.5f)*G; |
|
114 |
int j = 2*num-1-i; |
|
115 |
cuts[0][i] = +cut; |
|
116 |
cuts[0][j] = -cut; |
|
117 |
cuts[1][i] = +cut; |
|
118 |
cuts[1][j] = -cut; |
|
119 |
cuts[2][i] = +cut; |
|
120 |
cuts[2][j] = -cut; |
|
121 |
cuts[3][i] = +cut; |
|
122 |
cuts[3][j] = -cut; |
|
123 |
cuts[4][i] = +cut; |
|
124 |
cuts[4][j] = -cut; |
|
125 |
cuts[5][i] = +cut; |
|
126 |
cuts[5][j] = -cut; |
|
115 | 127 |
} |
116 | 128 |
|
117 | 129 |
return cuts; |
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
98 | 98 |
|
99 | 99 |
private final int mNumCubitFaces; |
100 | 100 |
private final Static3D[] mAxis; |
101 |
private final float[] mCuts; |
|
102 |
private final int mNumCuts; |
|
101 |
private final float[][] mCuts;
|
|
102 |
private final int[] mNumCuts;
|
|
103 | 103 |
private final int mNodeSize; |
104 | 104 |
private final float[][] mOrigPos; |
105 | 105 |
private final Static3D mNodeScale; |
... | ... | |
138 | 138 |
mAxis = getRotationAxis(); |
139 | 139 |
mInitScreenRatio = getScreenRatio(); |
140 | 140 |
mNumCubitFaces = getNumCubitFaces(); |
141 |
|
|
141 | 142 |
mCuts = getCuts(mNumLayers); |
142 |
mNumCuts = mCuts== null ? 0: mCuts.length; |
|
143 |
mNumCuts = new int[mAxis.length]; |
|
144 |
if( mCuts==null ) for(int i=0; i<mAxis.length; i++) mNumCuts[i] = 0; |
|
145 |
else for(int i=0; i<mAxis.length; i++) mNumCuts[i] = mCuts[i].length; |
|
143 | 146 |
|
144 | 147 |
QUATS = getQuats(); |
145 | 148 |
NUM_CUBITS = mOrigPos.length; |
... | ... | |
302 | 305 |
|
303 | 306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
304 | 307 |
|
305 |
int computeRow(float[] pos, int rotIndex)
|
|
308 |
int computeRow(float[] pos, int axisIndex)
|
|
306 | 309 |
{ |
307 | 310 |
int ret=0; |
308 | 311 |
int len = pos.length / 3; |
309 |
Static3D axis = mAxis[rotIndex];
|
|
312 |
Static3D axis = mAxis[axisIndex];
|
|
310 | 313 |
float axisX = axis.get0(); |
311 | 314 |
float axisY = axis.get1(); |
312 | 315 |
float axisZ = axis.get2(); |
316 |
float casted; |
|
313 | 317 |
|
314 | 318 |
for(int i=0; i<len; i++) |
315 | 319 |
{ |
316 |
ret |= computeRow(pos[3*i]*axisX + pos[3*i+1]*axisY + pos[3*i+2]*axisZ); |
|
320 |
casted = pos[3*i]*axisX + pos[3*i+1]*axisY + pos[3*i+2]*axisZ; |
|
321 |
ret |= computeSingleRow(axisIndex,casted); |
|
317 | 322 |
} |
318 | 323 |
|
319 | 324 |
return ret; |
... | ... | |
321 | 326 |
|
322 | 327 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
323 | 328 |
|
324 |
private int computeRow(float casted)
|
|
329 |
private int computeSingleRow(int axisIndex,float casted)
|
|
325 | 330 |
{ |
326 |
for(int i=0; i<mNumCuts; i++) |
|
331 |
int num = mNumCuts[axisIndex]; |
|
332 |
|
|
333 |
for(int i=0; i<num; i++) |
|
327 | 334 |
{ |
328 |
if( casted<mCuts[i] ) return (1<<i); |
|
335 |
if( casted<mCuts[axisIndex][i] ) return (1<<i);
|
|
329 | 336 |
} |
330 | 337 |
|
331 |
return (1<<mNumCuts);
|
|
338 |
return (1<<num);
|
|
332 | 339 |
} |
333 | 340 |
|
334 | 341 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
959 | 966 |
abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top); |
960 | 967 |
abstract int getFaceColor(int cubit, int cubitface, int numLayers); |
961 | 968 |
abstract float returnMultiplier(); |
962 |
abstract float[] getCuts(int numLayers); |
|
969 |
abstract float[][] getCuts(int numLayers);
|
|
963 | 970 |
abstract boolean shouldResetTextureMaps(); |
964 | 971 |
abstract Static3D[] getRotationAxis(); |
965 | 972 |
|
src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
---|---|---|
218 | 218 |
|
219 | 219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
220 | 220 |
|
221 |
float[] getCuts(int size) |
|
221 |
float[][] getCuts(int size)
|
|
222 | 222 |
{ |
223 |
float[] cuts = new float[size-1];
|
|
223 |
float[][] cuts = new float[4][size-1];
|
|
224 | 224 |
|
225 | 225 |
for(int i=0; i<size-1; i++) |
226 | 226 |
{ |
227 |
cuts[i] = (1.0f-0.25f*size+i)*(SQ6/3); |
|
227 |
float cut = (1.0f-0.25f*size+i)*(SQ6/3); |
|
228 |
cuts[0][i] = cut; |
|
229 |
cuts[1][i] = cut; |
|
230 |
cuts[2][i] = cut; |
|
231 |
cuts[3][i] = cut; |
|
228 | 232 |
} |
229 | 233 |
|
230 | 234 |
return cuts; |
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
248 | 248 |
|
249 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
250 | 250 |
|
251 |
float[] getCuts(int size) |
|
251 |
float[][] getCuts(int size)
|
|
252 | 252 |
{ |
253 |
float[] cuts = new float[2]; |
|
254 |
|
|
255 |
cuts[0] = -SQ3/3 -0.05f; |
|
256 |
cuts[1] = +SQ3/3 +0.05f; |
|
257 |
|
|
258 |
return cuts; |
|
253 |
float[] cut = new float[] { -SQ3/3 -0.05f, +SQ3/3 +0.05f }; |
|
254 |
return new float[][] { cut,cut,cut,cut }; |
|
259 | 255 |
} |
260 | 256 |
|
261 | 257 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyRex.java | ||
---|---|---|
182 | 182 |
|
183 | 183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
184 | 184 |
|
185 |
float[] getCuts(int numLayers) |
|
185 |
float[][] getCuts(int numLayers)
|
|
186 | 186 |
{ |
187 |
float C = SQ3*0.15f; // bit less than 1/6 of the length of the main diagonal |
|
188 |
|
|
189 |
return new float[] {-C,+C}; |
|
187 |
float[] cut = new float[] {-SQ3*0.15f,+SQ3*0.15f}; // bit less than 1/6 of the length of the main diagonal |
|
188 |
return new float[][] { cut,cut,cut,cut }; |
|
190 | 189 |
} |
191 | 190 |
|
192 | 191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
243 | 243 |
|
244 | 244 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
245 | 245 |
|
246 |
float[] getCuts(int numLayers) |
|
246 |
float[][] getCuts(int numLayers)
|
|
247 | 247 |
{ |
248 |
float[] cuts = new float[numLayers-1]; |
|
249 |
|
|
250 | 248 |
switch(numLayers) |
251 | 249 |
{ |
252 |
case 2: cuts[0] = 0; |
|
253 |
break; |
|
254 |
case 3: cuts[0] = -SQ3/12; |
|
255 |
cuts[1] = +SQ3/12; |
|
256 |
break; |
|
257 |
case 4: cuts[0] = -SQ3/9; |
|
258 |
cuts[1] = 0; |
|
259 |
cuts[2] = +SQ3/9; |
|
260 |
break; |
|
250 |
case 2: float[] c2 = new float[] {0.0f}; |
|
251 |
return new float[][] { c2,c2,c2,c2 }; |
|
252 |
case 3: float[] c3 = new float[] {-SQ3/12,+SQ3/12}; |
|
253 |
return new float[][] { c3,c3,c3,c3 }; |
|
261 | 254 |
} |
262 |
return cuts;
|
|
255 |
return null;
|
|
263 | 256 |
} |
264 | 257 |
|
265 | 258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistySquare1.java | ||
---|---|---|
433 | 433 |
} |
434 | 434 |
|
435 | 435 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
436 |
// TODO |
|
437 | 436 |
|
438 |
float[] getCuts(int numLayers) |
|
437 |
float[][] getCuts(int numLayers)
|
|
439 | 438 |
{ |
440 |
float[] cuts = new float[numLayers-1]; |
|
441 |
|
|
442 |
for(int i=0; i<numLayers-1; i++) |
|
443 |
{ |
|
444 |
cuts[i] = (2-numLayers)*0.5f + i; |
|
445 |
} |
|
446 |
|
|
447 |
return cuts; |
|
439 |
return new float[][] { {-0.5f,+0.5f}, {0.0f} }; |
|
448 | 440 |
} |
449 | 441 |
|
450 | 442 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyUltimate.java | ||
---|---|---|
397 | 397 |
|
398 | 398 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
399 | 399 |
|
400 |
float[] getCuts(int numLayers) |
|
400 |
float[][] getCuts(int numLayers)
|
|
401 | 401 |
{ |
402 |
float[] cuts = new float[1]; |
|
403 |
cuts[0] = 0.0f; |
|
404 |
|
|
405 |
return cuts; |
|
402 |
float[] cut = new float[] {0.0f}; |
|
403 |
return new float[][] { cut,cut,cut,cut }; |
|
406 | 404 |
} |
407 | 405 |
|
408 | 406 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Make it possible for an object to have different 'cuts' along each of its axis.