Revision 045d8cbd
Added by Leszek Koltunski about 4 years ago
| src/main/java/org/distorted/objects/TwistyPyraminx.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; |
| 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
| 26 | 28 |
import org.distorted.library.main.DistortedEffects; |
| 27 | 29 |
import org.distorted.library.main.DistortedTexture; |
| 28 | 30 |
import org.distorted.library.mesh.MeshBase; |
| ... | ... | |
| 300 | 302 |
} |
| 301 | 303 |
} |
| 302 | 304 |
|
| 305 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 306 |
|
|
| 307 |
ObjectShape getObjectShape(int cubit, int numLayers) |
|
| 308 |
{
|
|
| 309 |
int variant = getCubitVariant(cubit,numLayers); |
|
| 310 |
|
|
| 311 |
if( variant==0 ) |
|
| 312 |
{
|
|
| 313 |
int N = numLayers==3? 6 : 5; |
|
| 314 |
int E = numLayers==3? 2 : 1; |
|
| 315 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
|
|
| 316 |
int[] bandIndices = new int[] { 0,0,0,0,0,0,0,0 };
|
|
| 317 |
float[][] corners = new float[][] { {0.04f,0.20f} };
|
|
| 318 |
int[] cornerIndices = new int[] { 0,0,0,0,0,0 };
|
|
| 319 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 320 |
int[] centerIndices = new int[] { 0,0,0,0,0,0 };
|
|
| 321 |
return new ObjectShape(VERTICES_OCTA,VERT_INDEXES_OCTA,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
| 322 |
} |
|
| 323 |
else |
|
| 324 |
{
|
|
| 325 |
int N = numLayers==3? 6 : 5; |
|
| 326 |
int E = numLayers==3? 2 : 1; |
|
| 327 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
|
|
| 328 |
int[] bandIndices = new int[] { 0,0,0,0 };
|
|
| 329 |
float[][] corners = new float[][] { {0.06f,0.15f} };
|
|
| 330 |
int[] cornerIndices = new int[] { 0,0,0,0 };
|
|
| 331 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 332 |
int[] centerIndices = new int[] { 0,0,0,0 };
|
|
| 333 |
return new ObjectShape(VERTICES_TETRA,VERT_INDEXES_TETRA,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
| 334 |
} |
|
| 335 |
} |
|
| 336 |
|
|
| 337 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 338 |
|
|
| 339 |
private Static4D getQuat(int cubit, int numLayers) |
|
| 340 |
{
|
|
| 341 |
return QUATS[0]; |
|
| 342 |
} |
|
| 343 |
|
|
| 344 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 345 |
|
|
| 346 |
private int getNumCubitVariants(int numLayers) |
|
| 347 |
{
|
|
| 348 |
return 2; |
|
| 349 |
} |
|
| 350 |
|
|
| 351 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 352 |
|
|
| 353 |
int getCubitVariant(int cubit, int numLayers) |
|
| 354 |
{
|
|
| 355 |
return cubit<getNumOctahedrons(numLayers) ? 0:1; |
|
| 356 |
} |
|
| 357 |
|
|
| 303 | 358 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 304 | 359 |
|
| 305 | 360 |
MeshBase createCubitMesh(int cubit, int numLayers) |
| 306 | 361 |
{
|
| 362 |
int variant = getCubitVariant(cubit,numLayers); |
|
| 363 |
|
|
| 307 | 364 |
if( mMeshes==null ) |
| 308 | 365 |
{
|
| 309 | 366 |
FactoryCubit factory = FactoryCubit.getInstance(); |
| 310 | 367 |
factory.clear(); |
| 311 |
mMeshes = new MeshBase[2];
|
|
| 368 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
|
|
| 312 | 369 |
} |
| 313 | 370 |
|
| 314 |
MeshBase mesh; |
|
| 315 |
int numO = getNumOctahedrons(numLayers); |
|
| 316 |
|
|
| 317 |
if( cubit<numO ) |
|
| 371 |
if( mMeshes[variant]==null ) |
|
| 318 | 372 |
{
|
| 319 |
if( mMeshes[0]==null ) |
|
| 320 |
{
|
|
| 321 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,6,2,2} };
|
|
| 322 |
int[] bandIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
|
| 323 |
float[][] corners = new float[][] { {0.04f,0.20f} };
|
|
| 324 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0 };
|
|
| 325 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 326 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0 };
|
|
| 327 |
|
|
| 328 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
| 329 |
factory.createNewFaceTransform(VERTICES_OCTA,VERT_INDEXES_OCTA); |
|
| 330 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_OCTA, VERT_INDEXES_OCTA, |
|
| 331 |
bands, bandIndexes, |
|
| 332 |
corners, cornerIndexes, |
|
| 333 |
centers, centerIndexes, |
|
| 334 |
getNumCubitFaces(), null ); |
|
| 335 |
} |
|
| 336 |
mesh = mMeshes[0].copy(true); |
|
| 337 |
} |
|
| 338 |
else |
|
| 339 |
{
|
|
| 340 |
if( mMeshes[1]==null ) |
|
| 341 |
{
|
|
| 342 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,6,2,2} };
|
|
| 343 |
int[] bandIndexes = new int[] { 0,0,0,0 };
|
|
| 344 |
float[][] corners = new float[][] { {0.06f,0.15f} };
|
|
| 345 |
int[] cornerIndexes = new int[] { 0,0,0,0 };
|
|
| 346 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} };
|
|
| 347 |
int[] centerIndexes = new int[] { 0,0,0,0 };
|
|
| 348 |
|
|
| 349 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
| 350 |
factory.createNewFaceTransform(VERTICES_TETRA,VERT_INDEXES_TETRA); |
|
| 351 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_TETRA, VERT_INDEXES_TETRA, |
|
| 352 |
bands, bandIndexes, |
|
| 353 |
corners, cornerIndexes, |
|
| 354 |
centers, centerIndexes, |
|
| 355 |
getNumCubitFaces(), null ); |
|
| 356 |
} |
|
| 357 |
mesh = mMeshes[1].copy(true); |
|
| 373 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
| 374 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
| 375 |
factory.createNewFaceTransform(shape); |
|
| 376 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
| 358 | 377 |
} |
| 359 | 378 |
|
| 379 |
MeshBase mesh = mMeshes[variant].copy(true); |
|
| 380 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) ); |
|
| 381 |
mesh.apply(quat,0xffffffff,0); |
|
| 382 |
|
|
| 360 | 383 |
return mesh; |
| 361 | 384 |
} |
| 362 | 385 |
|
Also available in: Unified diff
Convert Pyraminx to the new scheme. Make Pyra4 and Pyra5 meshes much smaller.