Revision 18a5f95f
Added by Leszek Koltunski about 5 years ago
| src/main/java/org/distorted/objects/FactoryCubit.java | ||
|---|---|---|
| 39 | 39 |
private static final float SQ3 = (float)Math.sqrt(3); |
| 40 | 40 |
private static final float SQ6 = (float)Math.sqrt(6); |
| 41 | 41 |
|
| 42 |
private static final float IVY_D = 0.05f;
|
|
| 42 |
private static final float IVY_D = 0.10f;
|
|
| 43 | 43 |
private static final int IVY_N = 8; |
| 44 | 44 |
|
| 45 | 45 |
private static final Static1D RADIUS = new Static1D(1); |
| ... | ... | |
| 502 | 502 |
|
| 503 | 503 |
MeshBase createFacesIvyCorner() |
| 504 | 504 |
{
|
| 505 |
MeshBase mesh = createFacesSkewbCorner(); |
|
| 506 |
mesh.addEmptyTexComponent(); |
|
| 507 |
return mesh; |
|
| 505 |
return createFacesSkewbCorner(); |
|
| 508 | 506 |
} |
| 509 | 507 |
|
| 510 | 508 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 514 | 512 |
MeshBase[] meshes = new MeshBase[2]; |
| 515 | 513 |
|
| 516 | 514 |
final float angle = (float)Math.PI/(2*IVY_N); |
| 515 |
final float CORR = 1.0f - IVY_D*SQ2; |
|
| 517 | 516 |
float[] vertices = new float[4*IVY_N]; |
| 518 | 517 |
|
| 519 | 518 |
for(int i=0; i<IVY_N; i++) |
| ... | ... | |
| 521 | 520 |
float sin = (float)Math.sin(i*angle); |
| 522 | 521 |
float cos = (float)Math.cos(i*angle); |
| 523 | 522 |
|
| 524 |
vertices[2*i ] = 0.5f-cos;
|
|
| 525 |
vertices[2*i+1 ] = 0.5f-sin;
|
|
| 526 |
vertices[2*i +2*IVY_N] = cos-0.5f;
|
|
| 527 |
vertices[2*i+1+2*IVY_N] = sin-0.5f;
|
|
| 523 |
vertices[2*i ] = CORR*(0.5f-cos);
|
|
| 524 |
vertices[2*i+1 ] = CORR*(0.5f-sin);
|
|
| 525 |
vertices[2*i +2*IVY_N] = CORR*(cos-0.5f);
|
|
| 526 |
vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
|
|
| 528 | 527 |
} |
| 529 | 528 |
|
| 530 |
float[] bands0 = computeBands(+0.08f,35,0.5f,0.7f,6);
|
|
| 529 |
float[] bands0 = computeBands(+0.05f,35,0.5f,0.5f,5);
|
|
| 531 | 530 |
float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2); |
| 532 | 531 |
|
| 533 |
meshes[0] = new MeshPolygon(vertices,bands0,1,1);
|
|
| 532 |
meshes[0] = new MeshPolygon(vertices,bands0,0,0);
|
|
| 534 | 533 |
meshes[0].setEffectAssociation(0,1,0); |
| 535 | 534 |
meshes[1] = new MeshPolygon(vertices,bands1,0,0); |
| 536 | 535 |
meshes[1].setEffectAssociation(0,2,0); |
| ... | ... | |
| 1226 | 1225 |
{
|
| 1227 | 1226 |
MeshBase mesh = createFacesIvyFace(); |
| 1228 | 1227 |
|
| 1229 |
Static3D center = new Static3D(0.0f,0.0f,-0.5f); |
|
| 1228 |
float DIST = SQ2*(0.5f-IVY_D); |
|
| 1229 |
Static3D center = new Static3D(0.0f,0.0f,-0.0f); |
|
| 1230 | 1230 |
Static3D[] vertices = new Static3D[2]; |
| 1231 |
vertices[0] = new Static3D(+SQ2/2 -IVY_D,-SQ2/2 +IVY_D,+0.0f);
|
|
| 1232 |
vertices[1] = new Static3D(-SQ2/2 +IVY_D,+SQ2/2 -IVY_D,+0.0f);
|
|
| 1231 |
vertices[0] = new Static3D(+DIST,-DIST,+0.0f);
|
|
| 1232 |
vertices[1] = new Static3D(-DIST,+DIST,+0.0f);
|
|
| 1233 | 1233 |
|
| 1234 |
roundCorners(mesh,center,vertices,0.06f,0.12f);
|
|
| 1234 |
roundCorners(mesh,center,vertices,0.10f,0.30f);
|
|
| 1235 | 1235 |
|
| 1236 | 1236 |
mesh.mergeEffComponents(); |
| 1237 | 1237 |
mesh.addEmptyTexComponent(); |
| 1238 | 1238 |
mesh.addEmptyTexComponent(); |
| 1239 | 1239 |
mesh.addEmptyTexComponent(); |
| 1240 | 1240 |
mesh.addEmptyTexComponent(); |
| 1241 |
mesh.addEmptyTexComponent(); |
|
| 1242 | 1241 |
|
| 1243 | 1242 |
return mesh; |
| 1244 | 1243 |
} |
| src/main/java/org/distorted/objects/TwistyIvy.java | ||
|---|---|---|
| 40 | 40 |
|
| 41 | 41 |
public class TwistyIvy extends TwistyObject |
| 42 | 42 |
{
|
| 43 |
private static final int FACES_PER_CUBIT =7;
|
|
| 43 |
private static final int FACES_PER_CUBIT =6;
|
|
| 44 | 44 |
|
| 45 | 45 |
// the four rotation axis of a RubikIvy. Must be normalized. |
| 46 | 46 |
static final Static3D[] ROT_AXIS = new Static3D[] |
| ... | ... | |
| 76 | 76 |
new Static4D( 0.5f, -0.5f, -0.5f, -0.5f ) |
| 77 | 77 |
}; |
| 78 | 78 |
|
| 79 |
private static final int[][] mCornerMap =
|
|
| 79 |
private static final int[][] mFaceMap =
|
|
| 80 | 80 |
{
|
| 81 |
{ 4, 2, 0, 12,12,12,12 },
|
|
| 82 |
{ 5, 2, 1, 12,12,12,12 },
|
|
| 83 |
{ 4, 3, 1, 12,12,12,12 },
|
|
| 84 |
{ 5, 3, 0, 12,12,12,12 },
|
|
| 85 |
}; |
|
| 86 |
|
|
| 87 |
private static final int[][] mCenterMap = |
|
| 88 |
{
|
|
| 89 |
{ 6, 12,12,12,12,12,12 },
|
|
| 90 |
{ 7, 12,12,12,12,12,12 },
|
|
| 91 |
{ 8, 12,12,12,12,12,12 },
|
|
| 92 |
{ 9, 12,12,12,12,12,12 },
|
|
| 93 |
{ 10, 12,12,12,12,12,12 },
|
|
| 94 |
{ 11, 12,12,12,12,12,12 },
|
|
| 81 |
{ 4, 2, 0, 12,12,12 },
|
|
| 82 |
{ 5, 2, 1, 12,12,12 },
|
|
| 83 |
{ 4, 3, 1, 12,12,12 },
|
|
| 84 |
{ 5, 3, 0, 12,12,12 },
|
|
| 85 |
|
|
| 86 |
{ 6, 12,12,12,12,12 },
|
|
| 87 |
{ 7, 12,12,12,12,12 },
|
|
| 88 |
{ 8, 12,12,12,12,12 },
|
|
| 89 |
{ 9, 12,12,12,12,12 },
|
|
| 90 |
{ 10, 12,12,12,12,12 },
|
|
| 91 |
{ 11, 12,12,12,12,12 },
|
|
| 95 | 92 |
}; |
| 96 | 93 |
|
| 97 | 94 |
private static MeshBase mCornerMesh, mFaceMesh; |
| ... | ... | |
| 228 | 225 |
|
| 229 | 226 |
int getFaceColor(int cubit, int cubitface, int numLayers) |
| 230 | 227 |
{
|
| 231 |
if( cubit<4 ) |
|
| 232 |
{
|
|
| 233 |
return mCornerMap[cubit][cubitface]; |
|
| 234 |
} |
|
| 235 |
else |
|
| 236 |
{
|
|
| 237 |
return mCenterMap[cubit-4][cubitface]; |
|
| 238 |
} |
|
| 228 |
return mFaceMap[cubit][cubitface]; |
|
| 239 | 229 |
} |
| 240 | 230 |
|
| 241 | 231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Progress with the Ivy