Revision a64e07d0
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/main/RubikSurfaceView.java | ||
---|---|---|
80 | 80 |
private int mFirstIndex, mLastIndex; |
81 | 81 |
private int mDensity; |
82 | 82 |
|
83 |
private static Static4D mQuat= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
|
84 |
private static Static4D mTemp= new Static4D(0,0,0,1); |
|
83 |
private static final Static4D mQuat= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
|
|
84 |
private static final Static4D mTemp= new Static4D(0,0,0,1);
|
|
85 | 85 |
|
86 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | 87 |
|
src/main/java/org/distorted/objects/FactoryCubit.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.type.Static3D; |
32 | 32 |
import org.distorted.library.type.Static4D; |
33 | 33 |
|
34 |
import static org.distorted.objects.TwistyMegaminx.MEGA_D; |
|
35 |
|
|
34 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 37 |
|
36 | 38 |
class FactoryCubit |
... | ... | |
48 | 50 |
static final float SIN54 = (SQ5+1)/4; // sin(54 deg) |
49 | 51 |
static final float COS54 = (float)(Math.sqrt(10-2*SQ5)/4); // cos(54 deg) |
50 | 52 |
|
51 |
static final float MINX_C0 = (SQ5-1)/4; |
|
52 |
static final float MINX_C4 = (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
|
|
53 |
static final float MINX_C5 = (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
|
|
54 |
static final float MINX_SC = 0.5f; |
|
53 |
static final float MINX_C0 = (SQ5-1)/4;
|
|
54 |
static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
|
|
55 |
static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
|
|
56 |
static final float MINX_SC = 0.5f;
|
|
55 | 57 |
|
56 | 58 |
private static final int IVY_N = 8; |
57 | 59 |
|
... | ... | |
686 | 688 |
|
687 | 689 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
688 | 690 |
|
689 |
MeshBase createFacesMinxCorner()
|
|
691 |
MeshBase createFacesKilominxCorner()
|
|
690 | 692 |
{ |
691 | 693 |
MeshBase[] meshes = new MeshPolygon[6]; |
692 | 694 |
|
... | ... | |
694 | 696 |
float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4); |
695 | 697 |
float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8); |
696 | 698 |
float H = 0.5f* SIN54 /COS54 ; |
697 |
float X2= MINX_SC*H*MINX_C5;
|
|
698 |
float Y3= MINX_SC*H/(2*MINX_C4);
|
|
699 |
float Y4= MINX_SC*H*(1/(2*MINX_C4) - MINX_C4);
|
|
699 |
float X2= MINX_SC*H* SIN_HALFD;
|
|
700 |
float Y3= MINX_SC*H/(2*COS_HALFD);
|
|
701 |
float Y4= MINX_SC*H*(1/(2*COS_HALFD) - COS_HALFD);
|
|
700 | 702 |
|
701 | 703 |
float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 }; |
702 | 704 |
float[] bands0 = computeBands(0.04f,17,0.3f,0.2f,5); |
... | ... | |
719 | 721 |
return new MeshJoined(meshes); |
720 | 722 |
} |
721 | 723 |
|
724 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
725 |
|
|
726 |
MeshBase createFacesMegaminxCorner() |
|
727 |
{ |
|
728 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
729 |
|
|
730 |
float Y = COS54/(2*SIN54); |
|
731 |
|
|
732 |
float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y }; |
|
733 |
float[] bands0 = computeBands(0.04f,34,0.3f,0.2f,5); |
|
734 |
float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2); |
|
735 |
|
|
736 |
meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1); |
|
737 |
meshes[0].setEffectAssociation(0, 1,0); |
|
738 |
meshes[1] = meshes[0].copy(true); |
|
739 |
meshes[1].setEffectAssociation(0, 2,0); |
|
740 |
meshes[2] = meshes[0].copy(true); |
|
741 |
meshes[2].setEffectAssociation(0, 4,0); |
|
742 |
meshes[3] = new MeshPolygon(vertices0, bands1, 1, 4); |
|
743 |
meshes[3].setEffectAssociation(0, 8,0); |
|
744 |
meshes[4] = meshes[3].copy(true); |
|
745 |
meshes[4].setEffectAssociation(0,16,0); |
|
746 |
meshes[5] = meshes[3].copy(true); |
|
747 |
meshes[5].setEffectAssociation(0,32,0); |
|
748 |
|
|
749 |
return new MeshJoined(meshes); |
|
750 |
} |
|
751 |
|
|
722 | 752 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
723 | 753 |
// EFFECTS |
724 | 754 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1218 | 1248 |
|
1219 | 1249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1220 | 1250 |
|
1221 |
VertexEffect[] createVertexEffectsMinxCorner()
|
|
1251 |
VertexEffect[] createVertexEffectsKilominxCorner()
|
|
1222 | 1252 |
{ |
1223 | 1253 |
VertexEffect[] effect = new VertexEffect[10]; |
1224 | 1254 |
|
1225 | 1255 |
float H = 0.5f*(SIN54 /COS54 ); |
1226 | 1256 |
float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4); |
1227 |
float Y2= H/(2*MINX_C4);
|
|
1257 |
float Y2= H/(2*COS_HALFD);
|
|
1228 | 1258 |
float A = (float)(Math.acos(-SQ5/5)*180/Math.PI); // dihedral angle of a dedecahedron in degrees |
1229 | 1259 |
float sin18 = MINX_C0; |
1230 | 1260 |
float cos18 = (float)(Math.sqrt(1-MINX_C0*MINX_C0)); |
1231 |
float LEN = (float)Math.sqrt(H*H/(MINX_C4*MINX_C4) + 0.25f);
|
|
1261 |
float LEN = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
|
|
1232 | 1262 |
|
1233 | 1263 |
Static3D axisZ = new Static3D(0.0f , 0.0f , 1.0f); |
1234 | 1264 |
Static3D axisY = new Static3D(0.0f , 1.0f , 0.0f); |
1235 | 1265 |
Static3D axisA = new Static3D(-sin18, cos18, 0.0f); |
1236 |
Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*MINX_C5/(MINX_C4*LEN));
|
|
1266 |
Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN));
|
|
1237 | 1267 |
|
1238 | 1268 |
Static3D move1 = new Static3D(0,-Y1,0); |
1239 | 1269 |
Static3D move2 = new Static3D(0,-Y2,0); |
... | ... | |
1271 | 1301 |
return effect; |
1272 | 1302 |
} |
1273 | 1303 |
|
1304 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1305 |
|
|
1306 |
VertexEffect[] createVertexEffectsMegaminxCorner(int numLayers) |
|
1307 |
{ |
|
1308 |
VertexEffect[] effect = new VertexEffect[9]; |
|
1309 |
|
|
1310 |
float Y = COS54/(2*SIN54); |
|
1311 |
float A = (float)(Math.acos(-SQ5/5)*180/Math.PI); // dihedral angle of a dedecahedron in degrees |
|
1312 |
|
|
1313 |
float sinA = (2*SIN54*SIN54-1)/COS54; |
|
1314 |
float cosA = (float)Math.sqrt(1-sinA*sinA); |
|
1315 |
float LEN = 0.5f/SIN54; |
|
1316 |
float scale= 2*SIN54*(0.5f-MEGA_D)/(0.5f*(numLayers-1)); |
|
1317 |
|
|
1318 |
Static3D axisA = new Static3D( SIN54, COS54, 0.0f); |
|
1319 |
Static3D axisB = new Static3D(-SIN54, COS54, 0.0f); |
|
1320 |
Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f); |
|
1321 |
|
|
1322 |
Static3D centerU = new Static3D( 0.0f, Y, 0.0f); |
|
1323 |
Static3D centerD = new Static3D( 0.0f,-Y, 0.0f); |
|
1324 |
|
|
1325 |
Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN ); |
|
1326 |
Static3D move2= new Static3D(0.0f, Y , 0.0f ); |
|
1327 |
|
|
1328 |
Static1D angleD = new Static1D(A); |
|
1329 |
Static1D angleE = new Static1D(360-A); |
|
1330 |
Static1D angleF = new Static1D( (float)((180/Math.PI)*Math.asin(sinA) - 90) ); |
|
1331 |
|
|
1332 |
effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) ); |
|
1333 |
effect[1] = new VertexEffectRotate(angleE, axisA, centerU); |
|
1334 |
effect[2] = new VertexEffectRotate(angleD, axisB, centerU); |
|
1335 |
effect[3] = new VertexEffectMove(move1); |
|
1336 |
effect[4] = new VertexEffectRotate(angleE, axisA, centerD); |
|
1337 |
effect[5] = new VertexEffectRotate(angleD, axisB, centerD); |
|
1338 |
effect[6] = new VertexEffectRotate(angleF, axisX, centerD); |
|
1339 |
effect[7] = new VertexEffectMove(move2); |
|
1340 |
effect[8] = new VertexEffectScale(scale); |
|
1341 |
|
|
1342 |
effect[0].setMeshAssociation( 3,-1); // meshes 0,1 |
|
1343 |
effect[1].setMeshAssociation( 16,-1); // mesh 4 |
|
1344 |
effect[2].setMeshAssociation( 32,-1); // mesh 5 |
|
1345 |
effect[3].setMeshAssociation( 56,-1); // meshes 3,4,5 |
|
1346 |
effect[4].setMeshAssociation( 1,-1); // mesh 0 |
|
1347 |
effect[5].setMeshAssociation( 2,-1); // mesh 1 |
|
1348 |
|
|
1349 |
return effect; |
|
1350 |
} |
|
1351 |
|
|
1274 | 1352 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1275 | 1353 |
// OBJECTS |
1276 | 1354 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1626 | 1704 |
|
1627 | 1705 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1628 | 1706 |
|
1629 |
MeshBase createMinxCornerMesh()
|
|
1707 |
MeshBase createKilominxCornerMesh()
|
|
1630 | 1708 |
{ |
1631 |
MeshBase mesh = createFacesMinxCorner();
|
|
1632 |
VertexEffect[] effects = createVertexEffectsMinxCorner();
|
|
1709 |
MeshBase mesh = createFacesKilominxCorner();
|
|
1710 |
VertexEffect[] effects = createVertexEffectsKilominxCorner();
|
|
1633 | 1711 |
for( VertexEffect effect : effects ) mesh.apply(effect); |
1634 | 1712 |
|
1635 | 1713 |
float A = (2*SQ3/3)* SIN54; |
1636 | 1714 |
float B = 0.4f; |
1637 |
float X = MINX_C5* SIN54 *COS54 ;
|
|
1715 |
float X = SIN_HALFD * SIN54 *COS54 ;
|
|
1638 | 1716 |
float Y = SIN54 * SIN54 - 0.5f; |
1639 |
float Z = MINX_C4* SIN54 *COS54 ;
|
|
1717 |
float Z = COS_HALFD* SIN54 *COS54 ;
|
|
1640 | 1718 |
|
1641 | 1719 |
Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B); |
1642 | 1720 |
|
... | ... | |
1650 | 1728 |
|
1651 | 1729 |
mesh.mergeEffComponents(); |
1652 | 1730 |
|
1731 |
return mesh; |
|
1732 |
} |
|
1733 |
|
|
1734 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1735 |
|
|
1736 |
MeshBase createMegaminxCornerMesh(int numLayers) |
|
1737 |
{ |
|
1738 |
MeshBase mesh = createFacesMegaminxCorner(); |
|
1739 |
VertexEffect[] effects = createVertexEffectsMegaminxCorner(numLayers); |
|
1740 |
for( VertexEffect effect : effects ) mesh.apply(effect); |
|
1741 |
|
|
1742 |
float A = (2*SQ3/3)* SIN54; |
|
1743 |
float B = 0.4f; |
|
1744 |
float X = SIN_HALFD* SIN54 * COS54; |
|
1745 |
float Y = SIN54 * SIN54 - 0.5f; |
|
1746 |
float Z = COS_HALFD* SIN54 * COS54; |
|
1747 |
float S = 2*SIN54*(0.5f-MEGA_D)/(0.5f*(numLayers-1)); |
|
1748 |
|
|
1749 |
Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B); |
|
1750 |
|
|
1751 |
Static3D[] vertices = new Static3D[4]; |
|
1752 |
vertices[0] = new Static3D( 0.0f, 0.0f , 0.0f); |
|
1753 |
vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f); |
|
1754 |
vertices[2] = new Static3D(-X*S , Y*S ,-Z*S ); |
|
1755 |
vertices[3] = new Static3D(+X*S , Y*S ,-Z*S ); |
|
1756 |
|
|
1757 |
roundCorners(mesh,center,vertices,0.04f,0.10f); |
|
1758 |
|
|
1759 |
mesh.mergeEffComponents(); |
|
1760 |
|
|
1653 | 1761 |
return mesh; |
1654 | 1762 |
} |
1655 | 1763 |
} |
src/main/java/org/distorted/objects/MovementKilominx.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
import org.distorted.library.type.Static3D; |
|
23 |
import static org.distorted.objects.TwistyKilominx.C1; |
|
24 |
import static org.distorted.objects.TwistyKilominx.C2; |
|
25 |
import static org.distorted.objects.TwistyKilominx.LEN; |
|
26 |
import static org.distorted.objects.FactoryCubit.SIN54; |
|
27 |
import static org.distorted.objects.FactoryCubit.COS54; |
|
28 |
import static org.distorted.objects.TwistyObject.SQ5; |
|
29 |
|
|
30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
|
32 |
class MovementKilominx extends Movement |
|
33 |
{ |
|
34 |
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5)/3; |
|
35 |
static final float DIST2D = (0.5f*SIN54/COS54)/3; |
|
36 |
|
|
37 |
static final Static3D[] FACE_AXIS = new Static3D[] |
|
38 |
{ |
|
39 |
new Static3D( C2/LEN, C1/LEN, 0 ), |
|
40 |
new Static3D( C2/LEN,-C1/LEN, 0 ), |
|
41 |
new Static3D(-C2/LEN, C1/LEN, 0 ), |
|
42 |
new Static3D(-C2/LEN,-C1/LEN, 0 ), |
|
43 |
new Static3D( 0 , C2/LEN, C1/LEN ), |
|
44 |
new Static3D( 0 , C2/LEN,-C1/LEN ), |
|
45 |
new Static3D( 0 ,-C2/LEN, C1/LEN ), |
|
46 |
new Static3D( 0 ,-C2/LEN,-C1/LEN ), |
|
47 |
new Static3D( C1/LEN, 0 , C2/LEN ), |
|
48 |
new Static3D( C1/LEN, 0 ,-C2/LEN ), |
|
49 |
new Static3D(-C1/LEN, 0 , C2/LEN ), |
|
50 |
new Static3D(-C1/LEN, 0 ,-C2/LEN ) |
|
51 |
}; |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
MovementKilominx() |
|
56 |
{ |
|
57 |
super(TwistyKilominx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D); |
|
58 |
} |
|
59 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
int computeRowFromOffset(int face, int size, float offset) |
|
63 |
{ |
|
64 |
return offset<DIST2D ? 0:2; |
|
65 |
} |
|
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
|
|
69 |
public float returnRotationFactor(int size, int row) |
|
70 |
{ |
|
71 |
return 1.0f; |
|
72 |
} |
|
73 |
|
|
74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
75 |
// return angle (in radians) that the line connecting the center C of the pentagonal face and the |
|
76 |
// first vertex of the pentagon makes with a vertical line coming upwards from the center C. |
|
77 |
|
|
78 |
private float returnAngle(int face) |
|
79 |
{ |
|
80 |
switch(face) |
|
81 |
{ |
|
82 |
case 0: |
|
83 |
case 2: |
|
84 |
case 6: |
|
85 |
case 7: return 0.0f; |
|
86 |
case 1: |
|
87 |
case 3: |
|
88 |
case 4: |
|
89 |
case 5: return (float)(36*Math.PI/180); |
|
90 |
case 9: |
|
91 |
case 10: return (float)(54*Math.PI/180); |
|
92 |
case 8: |
|
93 |
case 11: return (float)(18*Math.PI/180); |
|
94 |
} |
|
95 |
|
|
96 |
return 0.0f; |
|
97 |
} |
|
98 |
|
|
99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
100 |
// The pair (distance,angle) defines a point P in R^2 in polar coordinate system. Let V be the vector |
|
101 |
// from the center of the coordinate system to P. |
|
102 |
// Let P' be the point defined by polar (distance,angle+PI/2). Let Lh be the half-line starting at |
|
103 |
// P' and going in the direction of V. |
|
104 |
// Return true iff point 'point' lies on the left of Lh, i.e. when we rotate (using the center of |
|
105 |
// the coordinate system as the center of rotation) 'point' and Lh in such a way that Lh points |
|
106 |
// directly upwards, is 'point' on the left or the right of it? |
|
107 |
|
|
108 |
private boolean isOnTheLeft(float[] point, float distance, float angle) |
|
109 |
{ |
|
110 |
float sin = (float)Math.sin(angle); |
|
111 |
float cos = (float)Math.cos(angle); |
|
112 |
|
|
113 |
float vx = point[0] + sin*distance; |
|
114 |
float vy = point[1] - cos*distance; |
|
115 |
|
|
116 |
return vx*sin < vy*cos; |
|
117 |
} |
|
118 |
|
|
119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
120 |
// Return 1,2,3,4,5 - the vertex of the pentagon to which point 'point' is the closest, if the |
|
121 |
// 'point' is inside the pentagon - or 0 otherwise. |
|
122 |
// The 'first' vertex is the one we meet the first when we rotate clockwise starting from 12:00. |
|
123 |
// This vertex makes angle 'returnAngle()' with the line coming out upwards from the center of the |
|
124 |
// pentagon. |
|
125 |
// Distance from the center to a vertex of the pentagon = 1/(6*COS54) |
|
126 |
|
|
127 |
private int returnPartOfThePentagon(float[] point, int face) |
|
128 |
{ |
|
129 |
float angle = returnAngle(face); |
|
130 |
float A = (float)(Math.PI/5); |
|
131 |
|
|
132 |
for(int i=0; i<5; i++) |
|
133 |
{ |
|
134 |
if( isOnTheLeft(point, DIST2D, (9-2*i)*A-angle) ) return 0; |
|
135 |
} |
|
136 |
|
|
137 |
if( isOnTheLeft(point, 0, 2.5f*A-angle) ) |
|
138 |
{ |
|
139 |
if( isOnTheLeft(point, 0, 3.5f*A-angle) ) |
|
140 |
{ |
|
141 |
return isOnTheLeft(point, 0, 5.5f*A-angle) ? 4 : 5; |
|
142 |
} |
|
143 |
else return 1; |
|
144 |
} |
|
145 |
else |
|
146 |
{ |
|
147 |
if( isOnTheLeft(point, 0, 4.5f*A-angle) ) |
|
148 |
{ |
|
149 |
return 3; |
|
150 |
} |
|
151 |
else |
|
152 |
{ |
|
153 |
return isOnTheLeft(point, 0, 6.5f*A-angle) ? 2 : 1; |
|
154 |
} |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
159 |
|
|
160 |
boolean isInsideFace(int face, float[] p) |
|
161 |
{ |
|
162 |
return returnPartOfThePentagon(p,face) > 0; |
|
163 |
} |
|
164 |
|
|
165 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
166 |
|
|
167 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
|
168 |
{ |
|
169 |
int part = returnPartOfThePentagon(touchPoint,face); |
|
170 |
|
|
171 |
if( part>0 ) |
|
172 |
{ |
|
173 |
enabled[0] = 2; |
|
174 |
|
|
175 |
switch(face) |
|
176 |
{ |
|
177 |
case 0: switch(part) |
|
178 |
{ |
|
179 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
180 |
case 2: enabled[1]=3; enabled[2]=5; break; |
|
181 |
case 3: enabled[1]=5; enabled[2]=1; break; |
|
182 |
case 4: enabled[1]=1; enabled[2]=4; break; |
|
183 |
case 5: enabled[1]=4; enabled[2]=2; break; |
|
184 |
} |
|
185 |
break; |
|
186 |
|
|
187 |
case 1: switch(part) |
|
188 |
{ |
|
189 |
case 1: enabled[1]=0; enabled[2]=5; break; |
|
190 |
case 2: enabled[1]=5; enabled[2]=2; break; |
|
191 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
192 |
case 4: enabled[1]=3; enabled[2]=4; break; |
|
193 |
case 5: enabled[1]=4; enabled[2]=0; break; |
|
194 |
} |
|
195 |
break; |
|
196 |
|
|
197 |
case 2: switch(part) |
|
198 |
{ |
|
199 |
case 1: enabled[1]=3; enabled[2]=2; break; |
|
200 |
case 2: enabled[1]=2; enabled[2]=5; break; |
|
201 |
case 3: enabled[1]=5; enabled[2]=0; break; |
|
202 |
case 4: enabled[1]=0; enabled[2]=4; break; |
|
203 |
case 5: enabled[1]=4; enabled[2]=3; break; |
|
204 |
} |
|
205 |
break; |
|
206 |
|
|
207 |
case 3: switch(part) |
|
208 |
{ |
|
209 |
case 1: enabled[1]=1; enabled[2]=5; break; |
|
210 |
case 2: enabled[1]=5; enabled[2]=3; break; |
|
211 |
case 3: enabled[1]=3; enabled[2]=2; break; |
|
212 |
case 4: enabled[1]=2; enabled[2]=4; break; |
|
213 |
case 5: enabled[1]=4; enabled[2]=1; break; |
|
214 |
} |
|
215 |
break; |
|
216 |
|
|
217 |
case 4: switch(part) |
|
218 |
{ |
|
219 |
case 1: enabled[1]=3; enabled[2]=0; break; |
|
220 |
case 2: enabled[1]=0; enabled[2]=4; break; |
|
221 |
case 3: enabled[1]=4; enabled[2]=5; break; |
|
222 |
case 4: enabled[1]=5; enabled[2]=1; break; |
|
223 |
case 5: enabled[1]=1; enabled[2]=3; break; |
|
224 |
} |
|
225 |
break; |
|
226 |
|
|
227 |
case 5: switch(part) |
|
228 |
{ |
|
229 |
case 1: enabled[1]=2; enabled[2]=1; break; |
|
230 |
case 2: enabled[1]=1; enabled[2]=4; break; |
|
231 |
case 3: enabled[1]=4; enabled[2]=5; break; |
|
232 |
case 4: enabled[1]=5; enabled[2]=0; break; |
|
233 |
case 5: enabled[1]=0; enabled[2]=2; break; |
|
234 |
} |
|
235 |
break; |
|
236 |
|
|
237 |
case 6: switch(part) |
|
238 |
{ |
|
239 |
case 1: enabled[1]=5; enabled[2]=4; break; |
|
240 |
case 2: enabled[1]=4; enabled[2]=1; break; |
|
241 |
case 3: enabled[1]=1; enabled[2]=2; break; |
|
242 |
case 4: enabled[1]=2; enabled[2]=0; break; |
|
243 |
case 5: enabled[1]=0; enabled[2]=5; break; |
|
244 |
} |
|
245 |
break; |
|
246 |
|
|
247 |
case 7: switch(part) |
|
248 |
{ |
|
249 |
case 1: enabled[1]=5; enabled[2]=4; break; |
|
250 |
case 2: enabled[1]=4; enabled[2]=0; break; |
|
251 |
case 3: enabled[1]=0; enabled[2]=3; break; |
|
252 |
case 4: enabled[1]=3; enabled[2]=1; break; |
|
253 |
case 5: enabled[1]=1; enabled[2]=5; break; |
|
254 |
} |
|
255 |
break; |
|
256 |
|
|
257 |
case 8: switch(part) |
|
258 |
{ |
|
259 |
case 1: enabled[1]=2; enabled[2]=0; break; |
|
260 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
261 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
262 |
case 4: enabled[1]=3; enabled[2]=5; break; |
|
263 |
case 5: enabled[1]=5; enabled[2]=2; break; |
|
264 |
} |
|
265 |
break; |
|
266 |
|
|
267 |
case 9: switch(part) |
|
268 |
{ |
|
269 |
case 1: enabled[1]=3; enabled[2]=4; break; |
|
270 |
case 2: enabled[1]=4; enabled[2]=2; break; |
|
271 |
case 3: enabled[1]=2; enabled[2]=1; break; |
|
272 |
case 4: enabled[1]=1; enabled[2]=0; break; |
|
273 |
case 5: enabled[1]=0; enabled[2]=3; break; |
|
274 |
} |
|
275 |
break; |
|
276 |
|
|
277 |
case 10: switch(part) |
|
278 |
{ |
|
279 |
case 1: enabled[1]=2; enabled[2]=4; break; |
|
280 |
case 2: enabled[1]=4; enabled[2]=3; break; |
|
281 |
case 3: enabled[1]=3; enabled[2]=0; break; |
|
282 |
case 4: enabled[1]=0; enabled[2]=1; break; |
|
283 |
case 5: enabled[1]=1; enabled[2]=2; break; |
|
284 |
} |
|
285 |
break; |
|
286 |
|
|
287 |
case 11: switch(part) |
|
288 |
{ |
|
289 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
290 |
case 2: enabled[1]=1; enabled[2]=0; break; |
|
291 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
292 |
case 4: enabled[1]=2; enabled[2]=5; break; |
|
293 |
case 5: enabled[1]=5; enabled[2]=3; break; |
|
294 |
} |
|
295 |
break; |
|
296 |
} |
|
297 |
} |
|
298 |
else |
|
299 |
{ |
|
300 |
enabled[0] = 0; |
|
301 |
} |
|
302 |
} |
|
303 |
} |
src/main/java/org/distorted/objects/MovementMinx.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
import org.distorted.library.type.Static3D; |
|
23 |
import static org.distorted.objects.TwistyKilominx.C1; |
|
24 |
import static org.distorted.objects.TwistyKilominx.C2; |
|
25 |
import static org.distorted.objects.TwistyKilominx.LEN; |
|
26 |
import static org.distorted.objects.FactoryCubit.SIN54; |
|
27 |
import static org.distorted.objects.FactoryCubit.COS54; |
|
28 |
import static org.distorted.objects.TwistyObject.SQ5; |
|
29 |
|
|
30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
|
32 |
class MovementMinx extends Movement |
|
33 |
{ |
|
34 |
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5)/3; |
|
35 |
static final float DIST2D = (0.5f*SIN54/COS54)/3; |
|
36 |
|
|
37 |
static final Static3D[] FACE_AXIS = new Static3D[] |
|
38 |
{ |
|
39 |
new Static3D( C2/LEN, C1/LEN, 0 ), |
|
40 |
new Static3D( C2/LEN,-C1/LEN, 0 ), |
|
41 |
new Static3D(-C2/LEN, C1/LEN, 0 ), |
|
42 |
new Static3D(-C2/LEN,-C1/LEN, 0 ), |
|
43 |
new Static3D( 0 , C2/LEN, C1/LEN ), |
|
44 |
new Static3D( 0 , C2/LEN,-C1/LEN ), |
|
45 |
new Static3D( 0 ,-C2/LEN, C1/LEN ), |
|
46 |
new Static3D( 0 ,-C2/LEN,-C1/LEN ), |
|
47 |
new Static3D( C1/LEN, 0 , C2/LEN ), |
|
48 |
new Static3D( C1/LEN, 0 ,-C2/LEN ), |
|
49 |
new Static3D(-C1/LEN, 0 , C2/LEN ), |
|
50 |
new Static3D(-C1/LEN, 0 ,-C2/LEN ) |
|
51 |
}; |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
MovementMinx() |
|
56 |
{ |
|
57 |
super(TwistyKilominx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D); |
|
58 |
} |
|
59 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
int computeRowFromOffset(int face, int size, float offset) |
|
63 |
{ |
|
64 |
return offset<DIST2D ? 0:2; |
|
65 |
} |
|
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
|
|
69 |
public float returnRotationFactor(int size, int row) |
|
70 |
{ |
|
71 |
return 1.0f; |
|
72 |
} |
|
73 |
|
|
74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
75 |
// return angle (in radians) that the line connecting the center C of the pentagonal face and the |
|
76 |
// first vertex of the pentagon makes with a vertical line coming upwards from the center C. |
|
77 |
|
|
78 |
private float returnAngle(int face) |
|
79 |
{ |
|
80 |
switch(face) |
|
81 |
{ |
|
82 |
case 0: |
|
83 |
case 2: |
|
84 |
case 6: |
|
85 |
case 7: return 0.0f; |
|
86 |
case 1: |
|
87 |
case 3: |
|
88 |
case 4: |
|
89 |
case 5: return (float)(36*Math.PI/180); |
|
90 |
case 9: |
|
91 |
case 10: return (float)(54*Math.PI/180); |
|
92 |
case 8: |
|
93 |
case 11: return (float)(18*Math.PI/180); |
|
94 |
} |
|
95 |
|
|
96 |
return 0.0f; |
|
97 |
} |
|
98 |
|
|
99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
100 |
// The pair (distance,angle) defines a point P in R^2 in polar coordinate system. Let V be the vector |
|
101 |
// from the center of the coordinate system to P. |
|
102 |
// Let P' be the point defined by polar (distance,angle+PI/2). Let Lh be the half-line starting at |
|
103 |
// P' and going in the direction of V. |
|
104 |
// Return true iff point 'point' lies on the left of Lh, i.e. when we rotate (using the center of |
|
105 |
// the coordinate system as the center of rotation) 'point' and Lh in such a way that Lh points |
|
106 |
// directly upwards, is 'point' on the left or the right of it? |
|
107 |
|
|
108 |
private boolean isOnTheLeft(float[] point, float distance, float angle) |
|
109 |
{ |
|
110 |
float sin = (float)Math.sin(angle); |
|
111 |
float cos = (float)Math.cos(angle); |
|
112 |
|
|
113 |
float vx = point[0] + sin*distance; |
|
114 |
float vy = point[1] - cos*distance; |
|
115 |
|
|
116 |
return vx*sin < vy*cos; |
|
117 |
} |
|
118 |
|
|
119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
120 |
// Return 1,2,3,4,5 - the vertex of the pentagon to which point 'point' is the closest, if the |
|
121 |
// 'point' is inside the pentagon - or 0 otherwise. |
|
122 |
// The 'first' vertex is the one we meet the first when we rotate clockwise starting from 12:00. |
|
123 |
// This vertex makes angle 'returnAngle()' with the line coming out upwards from the center of the |
|
124 |
// pentagon. |
|
125 |
// Distance from the center to a vertex of the pentagon = 1/(6*COS54) |
|
126 |
|
|
127 |
private int returnPartOfThePentagon(float[] point, int face) |
|
128 |
{ |
|
129 |
float angle = returnAngle(face); |
|
130 |
float A = (float)(Math.PI/5); |
|
131 |
|
|
132 |
for(int i=0; i<5; i++) |
|
133 |
{ |
|
134 |
if( isOnTheLeft(point, DIST2D, (9-2*i)*A-angle) ) return 0; |
|
135 |
} |
|
136 |
|
|
137 |
if( isOnTheLeft(point, 0, 2.5f*A-angle) ) |
|
138 |
{ |
|
139 |
if( isOnTheLeft(point, 0, 3.5f*A-angle) ) |
|
140 |
{ |
|
141 |
return isOnTheLeft(point, 0, 5.5f*A-angle) ? 4 : 5; |
|
142 |
} |
|
143 |
else return 1; |
|
144 |
} |
|
145 |
else |
|
146 |
{ |
|
147 |
if( isOnTheLeft(point, 0, 4.5f*A-angle) ) |
|
148 |
{ |
|
149 |
return 3; |
|
150 |
} |
|
151 |
else |
|
152 |
{ |
|
153 |
return isOnTheLeft(point, 0, 6.5f*A-angle) ? 2 : 1; |
|
154 |
} |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
159 |
|
|
160 |
boolean isInsideFace(int face, float[] p) |
|
161 |
{ |
|
162 |
return returnPartOfThePentagon(p,face) > 0; |
|
163 |
} |
|
164 |
|
|
165 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
166 |
|
|
167 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
|
168 |
{ |
|
169 |
int part = returnPartOfThePentagon(touchPoint,face); |
|
170 |
|
|
171 |
if( part>0 ) |
|
172 |
{ |
|
173 |
enabled[0] = 2; |
|
174 |
|
|
175 |
switch(face) |
|
176 |
{ |
|
177 |
case 0: switch(part) |
|
178 |
{ |
|
179 |
case 1: enabled[1]=2; enabled[2]=3; break; |
|
180 |
case 2: enabled[1]=3; enabled[2]=5; break; |
|
181 |
case 3: enabled[1]=5; enabled[2]=1; break; |
|
182 |
case 4: enabled[1]=1; enabled[2]=4; break; |
|
183 |
case 5: enabled[1]=4; enabled[2]=2; break; |
|
184 |
} |
|
185 |
break; |
|
186 |
|
|
187 |
case 1: switch(part) |
|
188 |
{ |
|
189 |
case 1: enabled[1]=0; enabled[2]=5; break; |
|
190 |
case 2: enabled[1]=5; enabled[2]=2; break; |
|
191 |
case 3: enabled[1]=2; enabled[2]=3; break; |
|
192 |
case 4: enabled[1]=3; enabled[2]=4; break; |
|
193 |
case 5: enabled[1]=4; enabled[2]=0; break; |
|
194 |
} |
|
195 |
break; |
|
196 |
|
|
197 |
case 2: switch(part) |
|
198 |
{ |
|
199 |
case 1: enabled[1]=3; enabled[2]=2; break; |
|
200 |
case 2: enabled[1]=2; enabled[2]=5; break; |
|
201 |
case 3: enabled[1]=5; enabled[2]=0; break; |
|
202 |
case 4: enabled[1]=0; enabled[2]=4; break; |
|
203 |
case 5: enabled[1]=4; enabled[2]=3; break; |
|
204 |
} |
|
205 |
break; |
|
206 |
|
|
207 |
case 3: switch(part) |
|
208 |
{ |
|
209 |
case 1: enabled[1]=1; enabled[2]=5; break; |
|
210 |
case 2: enabled[1]=5; enabled[2]=3; break; |
|
211 |
case 3: enabled[1]=3; enabled[2]=2; break; |
|
212 |
case 4: enabled[1]=2; enabled[2]=4; break; |
|
213 |
case 5: enabled[1]=4; enabled[2]=1; break; |
|
214 |
} |
|
215 |
break; |
|
216 |
|
|
217 |
case 4: switch(part) |
|
218 |
{ |
|
219 |
case 1: enabled[1]=3; enabled[2]=0; break; |
|
220 |
case 2: enabled[1]=0; enabled[2]=4; break; |
|
221 |
case 3: enabled[1]=4; enabled[2]=5; break; |
|
222 |
case 4: enabled[1]=5; enabled[2]=1; break; |
|
223 |
case 5: enabled[1]=1; enabled[2]=3; break; |
|
224 |
} |
|
225 |
break; |
|
226 |
|
|
227 |
case 5: switch(part) |
|
228 |
{ |
|
229 |
case 1: enabled[1]=2; enabled[2]=1; break; |
|
230 |
case 2: enabled[1]=1; enabled[2]=4; break; |
|
231 |
case 3: enabled[1]=4; enabled[2]=5; break; |
|
232 |
case 4: enabled[1]=5; enabled[2]=0; break; |
|
233 |
case 5: enabled[1]=0; enabled[2]=2; break; |
|
234 |
} |
|
235 |
break; |
|
236 |
|
|
237 |
case 6: switch(part) |
|
238 |
{ |
|
239 |
case 1: enabled[1]=5; enabled[2]=4; break; |
|
240 |
case 2: enabled[1]=4; enabled[2]=1; break; |
|
241 |
case 3: enabled[1]=1; enabled[2]=2; break; |
|
242 |
case 4: enabled[1]=2; enabled[2]=0; break; |
|
243 |
case 5: enabled[1]=0; enabled[2]=5; break; |
|
244 |
} |
|
245 |
break; |
|
246 |
|
|
247 |
case 7: switch(part) |
|
248 |
{ |
|
249 |
case 1: enabled[1]=5; enabled[2]=4; break; |
|
250 |
case 2: enabled[1]=4; enabled[2]=0; break; |
|
251 |
case 3: enabled[1]=0; enabled[2]=3; break; |
|
252 |
case 4: enabled[1]=3; enabled[2]=1; break; |
|
253 |
case 5: enabled[1]=1; enabled[2]=5; break; |
|
254 |
} |
|
255 |
break; |
|
256 |
|
|
257 |
case 8: switch(part) |
|
258 |
{ |
|
259 |
case 1: enabled[1]=2; enabled[2]=0; break; |
|
260 |
case 2: enabled[1]=0; enabled[2]=1; break; |
|
261 |
case 3: enabled[1]=1; enabled[2]=3; break; |
|
262 |
case 4: enabled[1]=3; enabled[2]=5; break; |
|
263 |
case 5: enabled[1]=5; enabled[2]=2; break; |
|
264 |
} |
|
265 |
break; |
|
266 |
|
|
267 |
case 9: switch(part) |
|
268 |
{ |
|
269 |
case 1: enabled[1]=3; enabled[2]=4; break; |
|
270 |
case 2: enabled[1]=4; enabled[2]=2; break; |
|
271 |
case 3: enabled[1]=2; enabled[2]=1; break; |
|
272 |
case 4: enabled[1]=1; enabled[2]=0; break; |
|
273 |
case 5: enabled[1]=0; enabled[2]=3; break; |
|
274 |
} |
|
275 |
break; |
|
276 |
|
|
277 |
case 10: switch(part) |
|
278 |
{ |
|
279 |
case 1: enabled[1]=2; enabled[2]=4; break; |
|
280 |
case 2: enabled[1]=4; enabled[2]=3; break; |
|
281 |
case 3: enabled[1]=3; enabled[2]=0; break; |
|
282 |
case 4: enabled[1]=0; enabled[2]=1; break; |
|
283 |
case 5: enabled[1]=1; enabled[2]=2; break; |
|
284 |
} |
|
285 |
break; |
|
286 |
|
|
287 |
case 11: switch(part) |
|
288 |
{ |
|
289 |
case 1: enabled[1]=3; enabled[2]=1; break; |
|
290 |
case 2: enabled[1]=1; enabled[2]=0; break; |
|
291 |
case 3: enabled[1]=0; enabled[2]=2; break; |
|
292 |
case 4: enabled[1]=2; enabled[2]=5; break; |
|
293 |
case 5: enabled[1]=5; enabled[2]=3; break; |
|
294 |
} |
|
295 |
break; |
|
296 |
} |
|
297 |
} |
|
298 |
else |
|
299 |
{ |
|
300 |
enabled[0] = 0; |
|
301 |
} |
|
302 |
} |
|
303 |
} |
src/main/java/org/distorted/objects/ObjectList.java | ||
---|---|---|
135 | 135 |
{3 , 18, R.raw.kilo3, R.drawable.ui_small_kilo3, R.drawable.ui_medium_kilo3, R.drawable.ui_big_kilo3, R.drawable.ui_huge_kilo3} , |
136 | 136 |
}, |
137 | 137 |
TwistyKilominx.class, |
138 |
new MovementKilominx(), |
|
138 |
new MovementMinx(), |
|
139 |
4 |
|
140 |
), |
|
141 |
|
|
142 |
MEGA ( |
|
143 |
new int[][] { |
|
144 |
{3 , 21, R.raw.kilo3, R.drawable.ui_small_kilo3, R.drawable.ui_medium_kilo3, R.drawable.ui_big_kilo3, R.drawable.ui_huge_kilo3} , |
|
145 |
{5 , 25, R.raw.kilo3, R.drawable.ui_small_kilo3, R.drawable.ui_medium_kilo3, R.drawable.ui_big_kilo3, R.drawable.ui_huge_kilo3} , |
|
146 |
}, |
|
147 |
TwistyMegaminx.class, |
|
148 |
new MovementMinx(), |
|
139 | 149 |
4 |
140 | 150 |
), |
141 | 151 |
; |
... | ... | |
521 | 531 |
case 8: return new TwistyIvy (size, quat, texture, mesh, effects, moves, res, scrWidth); |
522 | 532 |
case 9: return new TwistyRex (size, quat, texture, mesh, effects, moves, res, scrWidth); |
523 | 533 |
case 10: return new TwistyKilominx (size, quat, texture, mesh, effects, moves, res, scrWidth); |
534 |
case 11: return new TwistyMegaminx (size, quat, texture, mesh, effects, moves, res, scrWidth); |
|
524 | 535 |
} |
525 | 536 |
|
526 | 537 |
return null; |
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
104 | 104 |
|
105 | 105 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
106 | 106 |
|
107 |
MeshBase createCubitMesh(int cubit) |
|
107 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
108 | 108 |
{ |
109 | 109 |
if( mMeshes==null ) |
110 | 110 |
{ |
... | ... | |
179 | 179 |
|
180 | 180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
181 | 181 |
|
182 |
float[] getCuts(int size)
|
|
182 |
float[] getCuts(int numLayers)
|
|
183 | 183 |
{ |
184 |
float[] cuts = new float[size-1];
|
|
184 |
float[] cuts = new float[numLayers-1];
|
|
185 | 185 |
|
186 |
for(int i=0; i<size-1; i++)
|
|
186 |
for(int i=0; i<numLayers-1; i++)
|
|
187 | 187 |
{ |
188 |
cuts[i] = (2-size)*0.5f + i;
|
|
188 |
cuts[i] = (2-numLayers)*0.5f + i;
|
|
189 | 189 |
} |
190 | 190 |
|
191 | 191 |
return cuts; |
... | ... | |
193 | 193 |
|
194 | 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
195 | 195 |
|
196 |
int getNumStickerTypes() |
|
196 |
int getNumStickerTypes(int numLayers)
|
|
197 | 197 |
{ |
198 | 198 |
return 1; |
199 | 199 |
} |
... | ... | |
229 | 229 |
|
230 | 230 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
231 | 231 |
|
232 |
float[] getRowChances() |
|
232 |
float[] getRowChances(int numLayers)
|
|
233 | 233 |
{ |
234 |
int numLayers = getNumLayers(); |
|
235 | 234 |
float[] chances = new float[numLayers]; |
236 | 235 |
|
237 | 236 |
for(int i=0; i<numLayers; i++) |
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
160 | 160 |
|
161 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
162 | 162 |
|
163 |
int getNumStickerTypes() |
|
163 |
int getNumStickerTypes(int numLayers)
|
|
164 | 164 |
{ |
165 | 165 |
return 1; |
166 | 166 |
} |
... | ... | |
215 | 215 |
|
216 | 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
217 | 217 |
|
218 |
MeshBase createCubitMesh(int cubit) |
|
218 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
219 | 219 |
{ |
220 | 220 |
MeshBase mesh; |
221 | 221 |
|
... | ... | |
266 | 266 |
|
267 | 267 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
268 | 268 |
|
269 |
float[] getRowChances() |
|
269 |
float[] getRowChances(int numLayers)
|
|
270 | 270 |
{ |
271 | 271 |
float[] chances = new float[2]; |
272 | 272 |
|
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
170 | 170 |
|
171 | 171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
172 | 172 |
|
173 |
int getNumStickerTypes() |
|
173 |
int getNumStickerTypes(int numLayers)
|
|
174 | 174 |
{ |
175 | 175 |
return 1; |
176 | 176 |
} |
... | ... | |
191 | 191 |
|
192 | 192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
193 | 193 |
|
194 |
MeshBase createCubitMesh(int cubit) |
|
194 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
195 | 195 |
{ |
196 | 196 |
if( mMesh==null ) mMesh = FactoryCubit.getInstance().createDinoMesh(); |
197 | 197 |
|
... | ... | |
224 | 224 |
|
225 | 225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
226 | 226 |
|
227 |
float[] getRowChances() |
|
227 |
float[] getRowChances(int numLayers)
|
|
228 | 228 |
{ |
229 | 229 |
float[] chances = new float[3]; |
230 | 230 |
|
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
182 | 182 |
{ 5 , 6,6,6,6,6 }, |
183 | 183 |
}; |
184 | 184 |
|
185 |
private static int[] QUAT_INDICES = |
|
185 |
private static final int[] QUAT_INDICES =
|
|
186 | 186 |
{ 0,13,14,1,12,2,3,7,20,6,13,17,7,23,18,12,22,10,8,16,11,21,19,9,3,15,14,0,5,2,1,4 }; |
187 | 187 |
|
188 | 188 |
private static MeshBase mCornerMesh, mFaceMesh; |
... | ... | |
225 | 225 |
|
226 | 226 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
227 | 227 |
|
228 |
int getNumStickerTypes() |
|
228 |
int getNumStickerTypes(int numLayers)
|
|
229 | 229 |
{ |
230 | 230 |
return 1; |
231 | 231 |
} |
... | ... | |
258 | 258 |
|
259 | 259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
260 | 260 |
|
261 |
MeshBase createCubitMesh(int cubit) |
|
261 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
262 | 262 |
{ |
263 | 263 |
MeshBase mesh; |
264 | 264 |
|
... | ... | |
309 | 309 |
|
310 | 310 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
311 | 311 |
|
312 |
float[] getRowChances() |
|
312 |
float[] getRowChances(int numLayers)
|
|
313 | 313 |
{ |
314 | 314 |
float[] chances = new float[3]; |
315 | 315 |
|
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
132 | 132 |
|
133 | 133 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 134 |
|
135 |
int getNumStickerTypes() |
|
135 |
int getNumStickerTypes(int numLayers)
|
|
136 | 136 |
{ |
137 | 137 |
return 2; |
138 | 138 |
} |
... | ... | |
201 | 201 |
|
202 | 202 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
203 | 203 |
|
204 |
MeshBase createCubitMesh(int cubit) |
|
204 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
205 | 205 |
{ |
206 | 206 |
MeshBase mesh; |
207 | 207 |
|
... | ... | |
257 | 257 |
|
258 | 258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
259 | 259 |
|
260 |
float[] getRowChances() |
|
260 |
float[] getRowChances(int numLayers)
|
|
261 | 261 |
{ |
262 | 262 |
float[] chances = new float[2]; |
263 | 263 |
chances[0] = 0.5f; |
src/main/java/org/distorted/objects/TwistyKilominx.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.type.Static4D; |
33 | 33 |
import org.distorted.main.R; |
34 | 34 |
|
35 |
import java.util.Random; |
|
36 |
|
|
37 |
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS; |
|
38 |
|
|
39 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 36 |
|
41 |
public class TwistyKilominx extends TwistyObject
|
|
37 |
public class TwistyKilominx extends TwistyMinx
|
|
42 | 38 |
{ |
43 |
private static final int FACES_PER_CUBIT =6; |
|
44 |
|
|
45 |
static final float C0 = (SQ5-1)/4; // cos(72 deg) |
|
46 |
static final float C1 = (SQ5+1)/4; // cos(36 deg) |
|
47 |
static final float C2 = (SQ5+3)/4; |
|
48 |
static final float LEN= (float)(Math.sqrt(1.25f+0.5f*SQ5)); |
|
49 |
|
|
50 |
// the six rotation axis of a Kilominx. Must be normalized. |
|
51 |
static final Static3D[] ROT_AXIS = new Static3D[] |
|
52 |
{ |
|
53 |
new Static3D( C2/LEN, C1/LEN, 0 ), |
|
54 |
new Static3D(-C2/LEN, C1/LEN, 0 ), |
|
55 |
new Static3D( 0 , C2/LEN, C1/LEN ), |
|
56 |
new Static3D( 0 ,-C2/LEN, C1/LEN ), |
|
57 |
new Static3D( C1/LEN, 0 , C2/LEN ), |
|
58 |
new Static3D( C1/LEN, 0 ,-C2/LEN ) |
|
59 |
}; |
|
60 |
|
|
61 |
private static final int MINX_LGREEN = 0xff53aa00; |
|
62 |
private static final int MINX_PINK = 0xfffd7ab7; |
|
63 |
private static final int MINX_SANDY = 0xffefd48b; |
|
64 |
private static final int MINX_LBLUE = 0xff00a2d7; |
|
65 |
private static final int MINX_ORANGE = 0xffff6200; |
|
66 |
private static final int MINX_VIOLET = 0xff7d59a4; |
|
67 |
private static final int MINX_DGREEN = 0xff007a47; |
|
68 |
private static final int MINX_DRED = 0xffbd0000; |
|
69 |
private static final int MINX_DBLUE = 0xff1a29b2; |
|
70 |
private static final int MINX_DYELLOW= 0xffffc400; |
|
71 |
private static final int MINX_WHITE = 0xffffffff; |
|
72 |
private static final int MINX_GREY = 0xff727c7b; |
|
73 |
|
|
74 |
private static final int[] FACE_COLORS = new int[] |
|
75 |
{ |
|
76 |
MINX_LGREEN, MINX_PINK , MINX_SANDY , MINX_LBLUE, |
|
77 |
MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED , |
|
78 |
MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY |
|
79 |
}; |
|
80 |
|
|
81 |
// All 60 legal rotation quats of a Kilominx |
|
82 |
private static final Static4D[] QUATS = new Static4D[] |
|
83 |
{ |
|
84 |
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ), |
|
85 |
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ), |
|
86 |
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ), |
|
87 |
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ), |
|
88 |
|
|
89 |
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ), |
|
90 |
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ), |
|
91 |
new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ), |
|
92 |
new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ), |
|
93 |
new Static4D( -0.5f, 0.5f, 0.5f, 0.5f ), |
|
94 |
new Static4D( -0.5f, 0.5f, -0.5f, 0.5f ), |
|
95 |
new Static4D( -0.5f, -0.5f, 0.5f, 0.5f ), |
|
96 |
new Static4D( -0.5f, -0.5f, -0.5f, 0.5f ), |
|
97 |
|
|
98 |
new Static4D( 0.5f, C1, C0, 0.0f ), |
|
99 |
new Static4D( 0.5f, C1, -C0, 0.0f ), |
|
100 |
new Static4D( 0.5f, -C1, C0, 0.0f ), |
|
101 |
new Static4D( 0.5f, -C1, -C0, 0.0f ), |
|
102 |
new Static4D( C0, 0.5f, C1, 0.0f ), |
|
103 |
new Static4D( C0, 0.5f, -C1, 0.0f ), |
|
104 |
new Static4D( -C0, 0.5f, C1, 0.0f ), |
|
105 |
new Static4D( -C0, 0.5f, -C1, 0.0f ), |
|
106 |
new Static4D( C1, C0, 0.5f, 0.0f ), |
|
107 |
new Static4D( C1, -C0, 0.5f, 0.0f ), |
|
108 |
new Static4D( -C1, C0, 0.5f, 0.0f ), |
|
109 |
new Static4D( -C1, -C0, 0.5f, 0.0f ), |
|
110 |
|
|
111 |
new Static4D( 0.0f, C0, C1, 0.5f ), |
|
112 |
new Static4D( 0.0f, C0, -C1, 0.5f ), |
|
113 |
new Static4D( 0.0f, -C0, C1, 0.5f ), |
|
114 |
new Static4D( 0.0f, -C0, -C1, 0.5f ), |
|
115 |
new Static4D( C0, C1, 0.0f, 0.5f ), |
|
116 |
new Static4D( C0, -C1, 0.0f, 0.5f ), |
|
117 |
new Static4D( -C0, C1, 0.0f, 0.5f ), |
|
118 |
new Static4D( -C0, -C1, 0.0f, 0.5f ), |
|
119 |
new Static4D( C1, 0.0f, C0, 0.5f ), |
|
120 |
new Static4D( C1, 0.0f, -C0, 0.5f ), |
|
121 |
new Static4D( -C1, 0.0f, C0, 0.5f ), |
|
122 |
new Static4D( -C1, 0.0f, -C0, 0.5f ), |
|
123 |
|
|
124 |
new Static4D( 0.0f, C1, 0.5f, C0 ), |
|
125 |
new Static4D( 0.0f, C1, -0.5f, C0 ), |
|
126 |
new Static4D( 0.0f, -C1, 0.5f, C0 ), |
|
127 |
new Static4D( 0.0f, -C1, -0.5f, C0 ), |
|
128 |
new Static4D( 0.5f, 0.0f, C1, C0 ), |
|
129 |
new Static4D( 0.5f, 0.0f, -C1, C0 ), |
|
130 |
new Static4D( -0.5f, 0.0f, C1, C0 ), |
|
131 |
new Static4D( -0.5f, 0.0f, -C1, C0 ), |
|
132 |
new Static4D( C1, 0.5f, 0.0f, C0 ), |
|
133 |
new Static4D( C1, -0.5f, 0.0f, C0 ), |
|
134 |
new Static4D( -C1, 0.5f, 0.0f, C0 ), |
|
135 |
new Static4D( -C1, -0.5f, 0.0f, C0 ), |
|
136 |
|
|
137 |
new Static4D( 0.0f, 0.5f, C0, C1 ), |
|
138 |
new Static4D( 0.0f, 0.5f, -C0, C1 ), |
|
139 |
new Static4D( 0.0f, -0.5f, C0, C1 ), |
|
140 |
new Static4D( 0.0f, -0.5f, -C0, C1 ), |
|
141 |
new Static4D( 0.5f, C0, 0.0f, C1 ), |
|
142 |
new Static4D( 0.5f, -C0, 0.0f, C1 ), |
|
143 |
new Static4D( -0.5f, C0, 0.0f, C1 ), |
|
144 |
new Static4D( -0.5f, -C0, 0.0f, C1 ), |
|
145 |
new Static4D( C0, 0.0f, 0.5f, C1 ), |
|
146 |
new Static4D( C0, 0.0f, -0.5f, C1 ), |
|
147 |
new Static4D( -C0, 0.0f, 0.5f, C1 ), |
|
148 |
new Static4D( -C0, 0.0f, -0.5f, C1 ), |
|
149 |
}; |
|
150 |
|
|
151 |
private static final int[][] mFaceMap = |
|
152 |
{ |
|
153 |
{ 0, 1, 8, 12,12,12 }, |
|
154 |
{ 6, 5,10, 12,12,12 }, |
|
155 |
{ 1, 0,11, 12,12,12 }, |
|
156 |
{ 5, 6, 3, 12,12,12 }, |
|
157 |
{ 0, 9, 4, 12,12,12 }, |
|
158 |
{ 5, 4, 9, 12,12,12 }, |
|
159 |
{ 7, 1, 2, 12,12,12 }, |
|
160 |
{ 2, 6, 7, 12,12,12 }, |
|
161 |
{ 10, 9, 8, 12,12,12 }, |
|
162 |
{ 4, 3,11, 12,12,12 }, |
|
163 |
{ 7,10, 8, 12,12,12 }, |
|
164 |
{ 3, 2,11, 12,12,12 }, |
|
165 |
{ 0, 8, 9, 12,12,12 }, |
|
166 |
{ 9,10, 5, 12,12,12 }, |
|
167 |
{ 0, 4,11, 12,12,12 }, |
|
168 |
{ 4, 5, 3, 12,12,12 }, |
|
169 |
{ 1, 7, 8, 12,12,12 }, |
|
170 |
{ 7, 6,10, 12,12,12 }, |
|
171 |
{ 2, 1,11, 12,12,12 }, |
|
172 |
{ 6, 2, 3, 12,12,12 }, |
|
173 |
}; |
|
174 |
|
|
175 | 39 |
private static MeshBase mMesh; |
176 | 40 |
|
177 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
178 | 42 |
|
179 |
TwistyKilominx(int size, Static4D quat, DistortedTexture texture, |
|
180 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
|
181 |
{ |
|
182 |
super(size, size, 30, quat, texture, mesh, effects, moves, ObjectList.KILO, res, scrWidth); |
|
183 |
} |
|
184 |
|
|
185 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
186 |
|
|
187 |
float getScreenRatio() |
|
188 |
{ |
|
189 |
return 0.9f; |
|
190 |
} |
|
191 |
|
|
192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
193 |
|
|
194 |
Static4D[] getQuats() |
|
195 |
{ |
|
196 |
return QUATS; |
|
197 |
} |
|
198 |
|
|
199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
200 |
|
|
201 |
int getNumFaces() |
|
202 |
{ |
|
203 |
return FACE_COLORS.length; |
|
204 |
} |
|
205 |
|
|
206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
207 |
|
|
208 |
boolean shouldResetTextureMaps() |
|
43 |
TwistyKilominx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh, |
|
44 |
DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
|
209 | 45 |
{ |
210 |
return false;
|
|
46 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.KILO, res, scrWidth);
|
|
211 | 47 |
} |
212 | 48 |
|
213 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
214 | 50 |
|
215 |
int getNumStickerTypes() |
|
51 |
int getNumStickerTypes(int numLayers)
|
|
216 | 52 |
{ |
217 | 53 |
return 1; |
218 | 54 |
} |
... | ... | |
224 | 60 |
return new float[] { -0.5f , 0.5f }; |
225 | 61 |
} |
226 | 62 |
|
227 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
228 |
|
|
229 |
int getNumCubitFaces() |
|
230 |
{ |
|
231 |
return FACES_PER_CUBIT; |
|
232 |
} |
|
233 |
|
|
234 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
235 | 64 |
|
236 | 65 |
Static3D[] getCubitPositions(int numLayers) |
237 | 66 |
{ |
238 |
final Static3D[] CENTERS = new Static3D[20]; |
|
239 |
|
|
240 |
CENTERS[ 0] = new Static3D( 0.0f, 0.5f, C2); |
|
241 |
CENTERS[ 1] = new Static3D( 0.0f, 0.5f, -C2); |
|
242 |
CENTERS[ 2] = new Static3D( 0.0f,-0.5f, C2); |
|
243 |
CENTERS[ 3] = new Static3D( 0.0f,-0.5f, -C2); |
|
244 |
CENTERS[ 4] = new Static3D( C2, 0.0f, 0.5f); |
|
245 |
CENTERS[ 5] = new Static3D( C2, 0.0f,-0.5f); |
|
246 |
CENTERS[ 6] = new Static3D( -C2, 0.0f, 0.5f); |
|
247 |
CENTERS[ 7] = new Static3D( -C2, 0.0f,-0.5f); |
|
248 |
CENTERS[ 8] = new Static3D( 0.5f, C2, 0.0f); |
|
249 |
CENTERS[ 9] = new Static3D( 0.5f, -C2, 0.0f); |
|
250 |
CENTERS[10] = new Static3D(-0.5f, C2, 0.0f); |
|
251 |
CENTERS[11] = new Static3D(-0.5f, -C2, 0.0f); |
|
252 |
CENTERS[12] = new Static3D( C1, C1, C1); |
|
253 |
CENTERS[13] = new Static3D( C1, C1, -C1); |
|
254 |
CENTERS[14] = new Static3D( C1, -C1, C1); |
|
255 |
CENTERS[15] = new Static3D( C1, -C1, -C1); |
|
256 |
CENTERS[16] = new Static3D( -C1, C1, C1); |
|
257 |
CENTERS[17] = new Static3D( -C1, C1, -C1); |
|
258 |
CENTERS[18] = new Static3D( -C1, -C1, C1); |
|
259 |
CENTERS[19] = new Static3D( -C1, -C1, -C1); |
|
260 |
|
|
261 |
return CENTERS; |
|
67 |
return CORNERS; |
|
262 | 68 |
} |
263 | 69 |
|
264 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
265 | 71 |
|
266 | 72 |
private int getQuat(int cubit) |
267 | 73 |
{ |
268 |
switch(cubit) |
|
269 |
{ |
|
270 |
case 0: return 0; |
|
271 |
case 1: return 2; |
|
272 |
case 2: return 3; |
|
273 |
case 3: return 1; |
|
274 |
case 4: return 40; |
|
275 |
case 5: return 31; |
|
276 |
case 6: return 41; |
|
277 |
case 7: return 30; |
|
278 |
case 8: return 39; |
|
279 |
case 9: return 35; |
|
280 |
case 10: return 36; |
|
281 |
case 11: return 34; |
|
282 |
case 12: return 56; |
|
283 |
case 13: return 32; |
|
284 |
case 14: return 43; |
|
285 |
case 15: return 21; |
|
286 |
case 16: return 48; |
|
287 |
case 17: return 28; |
|
288 |
case 18: return 42; |
|
289 |
case 19: return 23; |
|
290 |
} |
|
291 |
|
|
292 |
return 0; |
|
74 |
return ( cubit>=0 && cubit<20 ) ? QUAT_INDICES[cubit] : 0; |
|
293 | 75 |
} |
294 | 76 |
|
295 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
296 | 78 |
|
297 |
MeshBase createCubitMesh(int cubit) |
|
79 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
298 | 80 |
{ |
299 |
if( mMesh==null ) mMesh = FactoryCubit.getInstance().createMinxCornerMesh();
|
|
81 |
if( mMesh==null ) mMesh = FactoryCubit.getInstance().createKilominxCornerMesh();
|
|
300 | 82 |
MeshBase mesh = mMesh.copy(true); |
301 | 83 |
|
302 | 84 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[getQuat(cubit)], new Static3D(0,0,0) ); |
... | ... | |
309 | 91 |
|
310 | 92 |
int getFaceColor(int cubit, int cubitface, int numLayers) |
311 | 93 |
{ |
312 |
return mFaceMap[cubit][cubitface];
|
|
94 |
return cubitface>=0 && cubitface<3 ? mCornerFaceMap[cubit][cubitface] : NUM_TEXTURES*NUM_FACES;
|
|
313 | 95 |
} |
314 | 96 |
|
315 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
335 | 117 |
canvas.drawLine(left+MID-WID,top+HEI,left+MID+WID,top+HEI,paint); |
336 | 118 |
} |
337 | 119 |
|
338 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
339 |
|
|
340 |
float returnMultiplier() |
|
341 |
{ |
|
342 |
return 2.0f; |
|
343 |
} |
|
344 |
|
|
345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
346 |
|
|
347 |
float[] getRowChances() |
|
348 |
{ |
|
349 |
return new float[] { 0.5f, 0.5f, 1.0f }; |
|
350 |
} |
|
351 |
|
|
352 | 120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
353 | 121 |
// PUBLIC API |
354 |
|
|
355 |
public Static3D[] getRotationAxis() |
|
356 |
{ |
|
357 |
return ROT_AXIS; |
|
358 |
} |
|
359 |
|
|
360 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
361 |
|
|
362 |
public int getBasicAngle() |
|
363 |
{ |
|
364 |
return 5; |
|
365 |
} |
|
366 |
|
|
367 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
368 |
|
|
369 |
public int randomizeNewRotAxis(Random rnd, int oldRotAxis) |
|
370 |
{ |
|
371 |
int numAxis = ROTATION_AXIS.length; |
|
372 |
|
|
373 |
if( oldRotAxis == START_AXIS ) |
|
374 |
{ |
|
375 |
return rnd.nextInt(numAxis); |
|
376 |
} |
|
377 |
else |
|
378 |
{ |
|
379 |
int newVector = rnd.nextInt(numAxis-1); |
|
380 |
return (newVector>=oldRotAxis ? newVector+1 : newVector); |
|
381 |
} |
|
382 |
} |
|
383 |
|
|
384 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
385 |
|
|
386 |
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis) |
|
387 |
{ |
|
388 |
float rowFloat = rnd.nextFloat(); |
|
389 |
|
|
390 |
for(int row=0; row<mRowChances.length; row++) |
|
391 |
{ |
|
392 |
if( rowFloat<=mRowChances[row] ) return row; |
|
393 |
} |
|
394 |
|
|
395 |
return 0; |
|
396 |
} |
|
397 |
|
|
398 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
399 | 122 |
// The Kilominx is solved if and only if: |
400 | 123 |
// |
401 |
// all cubits are rotated with the same quat.
|
|
124 |
// All cubits are rotated with the same quat.
|
|
402 | 125 |
|
403 | 126 |
public boolean isSolved() |
404 | 127 |
{ |
... | ... | |
412 | 135 |
return true; |
413 | 136 |
} |
414 | 137 |
|
415 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
416 |
// only needed for solvers - there are no Kilominx solvers ATM) |
|
417 |
|
|
418 |
public String retObjectString() |
|
419 |
{ |
|
420 |
return ""; |
|
421 |
} |
|
422 |
|
|
423 | 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
424 | 139 |
|
425 | 140 |
public int getObjectName(int numLayers) |
src/main/java/org/distorted/objects/TwistyMegaminx.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.objects; |
|
21 |
|
|
22 |
import android.content.res.Resources; |
|
23 |
import android.graphics.Canvas; |
|
24 |
import android.graphics.Paint; |
|
25 |
|
|
26 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
27 |
import org.distorted.library.main.DistortedEffects; |
|
28 |
import org.distorted.library.main.DistortedTexture; |
|
29 |
import org.distorted.library.mesh.MeshBase; |
|
30 |
import org.distorted.library.mesh.MeshSquare; |
|
31 |
import org.distorted.library.type.Static3D; |
|
32 |
import org.distorted.library.type.Static4D; |
|
33 |
import org.distorted.main.R; |
|
34 |
import org.distorted.main.RubikSurfaceView; |
|
35 |
|
|
36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
37 |
|
Also available in: Unified diff
Beginnings of Megaminx & Gigaminx