Revision acf165d9
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistyUltimate.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
26 | 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
27 | 28 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
244 | 245 |
|
245 | 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
246 | 247 |
|
247 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
248 |
ObjectShape getObjectShape(int cubit, int numLayers)
|
|
248 | 249 |
{ |
249 |
if( mMeshes==null ) |
|
250 |
{ |
|
251 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
252 |
factory.clear(); |
|
253 |
mMeshes = new MeshBase[3]; |
|
254 |
} |
|
250 |
int variant = getCubitVariant(cubit,numLayers); |
|
255 | 251 |
|
256 |
MeshBase mesh; |
|
257 |
|
|
258 |
if( cubit<4 ) |
|
252 |
if( variant==0 ) |
|
259 | 253 |
{ |
260 |
if( mMeshes[0]==null ) |
|
261 |
{ |
|
262 |
float[][] bands= new float[][] |
|
263 |
{ |
|
264 |
{0.03f,17,0.5f,0.2f,5, 2,2}, |
|
265 |
{0.01f, 1,0.5f,0.2f,5, 2,2} |
|
266 |
}; |
|
267 |
int[] bandIndexes = new int[] { 0,0,0,1,1,1 }; |
|
268 |
float[][] corners = new float[][] { { 0.013f, 0.08f } }; |
|
269 |
int[] cornerIndexes = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 }; |
|
270 |
float[][] centers = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } }; |
|
271 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 }; |
|
272 |
|
|
273 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
274 |
factory.createNewFaceTransform(VERTICES_SMALL_RIGHT,VERT_INDEXES_SMALL_RIGHT); |
|
275 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_SMALL_RIGHT, VERT_INDEXES_SMALL_RIGHT, |
|
276 |
bands, bandIndexes, |
|
277 |
corners, cornerIndexes, |
|
278 |
centers, centerIndexes, |
|
279 |
getNumCubitFaces(), null ); |
|
280 |
} |
|
281 |
mesh = mMeshes[0].copy(true); |
|
254 |
float[][] bands = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} }; |
|
255 |
int[] bandIndices = new int[] { 0,0,0,1,1,1 }; |
|
256 |
float[][] corners = new float[][] { { 0.013f, 0.08f } }; |
|
257 |
int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 }; |
|
258 |
float[][] centers = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } }; |
|
259 |
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
|
260 |
|
|
261 |
return new ObjectShape(VERTICES_SMALL_RIGHT,VERT_INDEXES_SMALL_RIGHT,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
282 | 262 |
} |
283 |
else if( cubit<8 )
|
|
263 |
else if( variant==1 )
|
|
284 | 264 |
{ |
285 |
if( mMeshes[1]==null ) |
|
286 |
{ |
|
287 |
float[][] bands= new float[][] |
|
288 |
{ |
|
289 |
{0.03f,17,0.5f,0.2f,5, 2,2}, |
|
290 |
{0.01f, 1,0.5f,0.2f,5, 2,2} |
|
291 |
}; |
|
292 |
int[] bandIndexes = new int[] { 0,0,0,1,1,1 }; |
|
293 |
float[][] corners = new float[][] { { 0.013f, 0.08f } }; |
|
294 |
int[] cornerIndexes = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 }; |
|
295 |
float[][] centers = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } }; |
|
296 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 }; |
|
297 |
|
|
298 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
299 |
factory.createNewFaceTransform(VERTICES_SMALL_LEFT,VERT_INDEXES_SMALL_LEFT); |
|
300 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_SMALL_LEFT, VERT_INDEXES_SMALL_LEFT, |
|
301 |
bands, bandIndexes, |
|
302 |
corners, cornerIndexes, |
|
303 |
centers, centerIndexes, |
|
304 |
getNumCubitFaces(), null ); |
|
305 |
} |
|
306 |
mesh = mMeshes[1].copy(true); |
|
265 |
float[][] bands = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} }; |
|
266 |
int[] bandIndices = new int[] { 0,0,0,1,1,1 }; |
|
267 |
float[][] corners = new float[][] { { 0.013f, 0.08f } }; |
|
268 |
int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 }; |
|
269 |
float[][] centers = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } }; |
|
270 |
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
|
271 |
return new ObjectShape(VERTICES_SMALL_LEFT,VERT_INDEXES_SMALL_LEFT,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
307 | 272 |
} |
308 | 273 |
else |
309 | 274 |
{ |
310 |
if( mMeshes[2]==null ) |
|
311 |
{ |
|
312 |
float[][] bands= new float[][] |
|
313 |
{ |
|
314 |
{0.04f,17,0.5f,0.2f,5, 2,2}, |
|
315 |
{0.03f,17,0.5f,0.2f,5, 2,2}, |
|
316 |
{0.01f, 1,0.5f,0.2f,5, 2,2} |
|
317 |
}; |
|
318 |
int[] bandIndexes = new int[] { 0,0,1,1,2,2,2,2 }; |
|
319 |
float[][] corners = new float[][] { { 0.013f, 0.08f } }; |
|
320 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,-1 }; |
|
321 |
float[][] centers = new float[][] { { -(SQ5+1)/8, 0.25f, -(SQ5+5)/8 } }; |
|
322 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,0 }; |
|
323 |
|
|
324 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
325 |
factory.createNewFaceTransform(VERTICES_BIG,VERT_INDEXES_BIG); |
|
326 |
mMeshes[2] = factory.createRoundedSolid(VERTICES_BIG, VERT_INDEXES_BIG, |
|
327 |
bands, bandIndexes, |
|
328 |
corners, cornerIndexes, |
|
329 |
centers, centerIndexes, |
|
330 |
getNumCubitFaces(), null ); |
|
331 |
} |
|
332 |
mesh = mMeshes[2].copy(true); |
|
275 |
float[][] bands = new float[][] { {0.04f,17,0.5f,0.2f,5,2,2}, {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} }; |
|
276 |
int[] bandIndices = new int[] { 0,0,1,1,2,2,2,2 }; |
|
277 |
float[][] corners = new float[][] { { 0.013f, 0.08f } }; |
|
278 |
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,-1 }; |
|
279 |
float[][] centers = new float[][] { { -(SQ5+1)/8, 0.25f, -(SQ5+5)/8 } }; |
|
280 |
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,0 }; |
|
281 |
return new ObjectShape(VERTICES_BIG,VERT_INDEXES_BIG,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
333 | 282 |
} |
283 |
} |
|
334 | 284 |
|
335 |
Static4D q = QUATS[getQuatIndex(cubit)]; |
|
336 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( q, new Static3D(0,0,0) ); |
|
337 |
mesh.apply(quat,0xffffffff,0); |
|
285 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
338 | 286 |
|
339 |
return mesh; |
|
287 |
private Static4D getQuat(int cubit, int numLayers) |
|
288 |
{ |
|
289 |
return QUATS[QUAT_INDEX[cubit]]; |
|
340 | 290 |
} |
341 | 291 |
|
342 | 292 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
343 | 293 |
|
344 |
float[][] getCubitPositions(int numLayers)
|
|
294 |
private int getNumCubitVariants(int numLayers)
|
|
345 | 295 |
{ |
346 |
return CENTERS; |
|
296 |
return 3; |
|
297 |
} |
|
298 |
|
|
299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
300 |
|
|
301 |
int getCubitVariant(int cubit, int numLayers) |
|
302 |
{ |
|
303 |
return cubit<4 ? 0 : (cubit<8 ? 1:2); |
|
347 | 304 |
} |
348 | 305 |
|
349 | 306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
350 | 307 |
|
351 |
private int getQuatIndex(int cubit)
|
|
308 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
352 | 309 |
{ |
353 |
return QUAT_INDEX[cubit]; |
|
310 |
int variant = getCubitVariant(cubit,numLayers); |
|
311 |
|
|
312 |
if( mMeshes==null ) |
|
313 |
{ |
|
314 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
315 |
factory.clear(); |
|
316 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)]; |
|
317 |
} |
|
318 |
|
|
319 |
if( mMeshes[variant]==null ) |
|
320 |
{ |
|
321 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
322 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
323 |
factory.createNewFaceTransform(shape); |
|
324 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
325 |
} |
|
326 |
|
|
327 |
MeshBase mesh = mMeshes[variant].copy(true); |
|
328 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) ); |
|
329 |
mesh.apply(quat,0xffffffff,0); |
|
330 |
|
|
331 |
return mesh; |
|
332 |
} |
|
333 |
|
|
334 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
335 |
|
|
336 |
float[][] getCubitPositions(int numLayers) |
|
337 |
{ |
|
338 |
return CENTERS; |
|
354 | 339 |
} |
355 | 340 |
|
356 | 341 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert the last object, Skewb Ultimate, to the new scheme.