Revision 3e605536
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyJing.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 |
import org.distorted.helpers.FactoryCubit; |
|
25 | 24 |
import org.distorted.helpers.ObjectShape; |
26 | 25 |
import org.distorted.helpers.ObjectSticker; |
27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
28 | 26 |
import org.distorted.library.main.DistortedEffects; |
29 | 27 |
import org.distorted.library.main.DistortedTexture; |
30 |
import org.distorted.library.mesh.MeshBase; |
|
31 | 28 |
import org.distorted.library.mesh.MeshSquare; |
32 | 29 |
import org.distorted.library.type.Static3D; |
33 | 30 |
import org.distorted.library.type.Static4D; |
... | ... | |
331 | 328 |
|
332 | 329 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
333 | 330 |
|
334 |
private Static4D getQuat(int cubit, int numLayers)
|
|
331 |
Static4D getQuat(int cubit, int numLayers) |
|
335 | 332 |
{ |
336 | 333 |
return QUATS[ROT_QUAT[cubit]]; |
337 | 334 |
} |
338 | 335 |
|
339 | 336 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
340 | 337 |
|
341 |
private int getNumCubitVariants(int numLayers)
|
|
338 |
int getNumCubitVariants(int numLayers) |
|
342 | 339 |
{ |
343 | 340 |
return 3; |
344 | 341 |
} |
... | ... | |
350 | 347 |
return cubit<4 ? 0 : (cubit<10?1:2); |
351 | 348 |
} |
352 | 349 |
|
353 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
354 |
|
|
355 |
MeshBase createCubitMesh(int cubit, int numLayers) |
|
356 |
{ |
|
357 |
int variant = getCubitVariant(cubit,numLayers); |
|
358 |
|
|
359 |
if( mMeshes==null ) |
|
360 |
{ |
|
361 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
362 |
factory.clear(); |
|
363 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)]; |
|
364 |
} |
|
365 |
|
|
366 |
if( mMeshes[variant]==null ) |
|
367 |
{ |
|
368 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
369 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
370 |
factory.createNewFaceTransform(shape); |
|
371 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
372 |
} |
|
373 |
|
|
374 |
MeshBase mesh = mMeshes[variant].copy(true); |
|
375 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) ); |
|
376 |
mesh.apply(quat,0xffffffff,0); |
|
377 |
|
|
378 |
return mesh; |
|
379 |
} |
|
380 |
|
|
381 | 350 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
382 | 351 |
|
383 | 352 |
int getColor(int face) |
Also available in: Unified diff
Finally remove cubit creation from the implementation classes and move it to the TwistyObject.