1 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
6133be67
|
Leszek Koltunski
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.objectlib.objects;
|
11 |
|
|
|
12 |
c9c71c3f
|
Leszek Koltunski
|
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.COS54;
|
13 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.SIN54;
|
14 |
29b82486
|
Leszek Koltunski
|
|
15 |
ecf3d6e3
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
16 |
29b82486
|
Leszek Koltunski
|
import org.distorted.library.type.Static4D;
|
17 |
a706f8e0
|
Leszek Koltunski
|
import org.distorted.library.main.QuatHelper;
|
18 |
29b82486
|
Leszek Koltunski
|
|
19 |
84a17011
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
20 |
3ee1d662
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
21 |
1d581993
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
22 |
84a17011
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
23 |
cf93ea4e
|
Leszek Koltunski
|
import org.distorted.objectlib.main.InitAssets;
|
24 |
a8295031
|
Leszek Koltunski
|
import org.distorted.objectlib.main.InitData;
|
25 |
2dffaf22
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectSignatures;
|
26 |
8005e762
|
Leszek Koltunski
|
import org.distorted.objectlib.main.ObjectType;
|
27 |
198c5bf0
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectShape;
|
28 |
29b82486
|
Leszek Koltunski
|
|
29 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30 |
|
|
|
31 |
9ba7f3f6
|
Leszek Koltunski
|
public class TwistyMegaminx extends TwistyDodecahedron
|
32 |
29b82486
|
Leszek Koltunski
|
{
|
33 |
|
|
static final float MEGA_D = 0.04f;
|
34 |
|
|
private int[] mQuatCenterIndices;
|
35 |
|
|
|
36 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
|
38 |
cf93ea4e
|
Leszek Koltunski
|
public TwistyMegaminx(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
39 |
29b82486
|
Leszek Koltunski
|
{
|
40 |
cf93ea4e
|
Leszek Koltunski
|
super(meshState, iconMode, quat, move, scale, data, asset);
|
41 |
29b82486
|
Leszek Koltunski
|
}
|
42 |
|
|
|
43 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44 |
|
|
|
45 |
|
|
private void initializeCenterIndices()
|
46 |
|
|
{
|
47 |
a4af26c1
|
Leszek Koltunski
|
mQuatCenterIndices = new int[] { 0, 35, 55, 38, 48, 41, 42, 58, 57, 46, 29, 59 };
|
48 |
29b82486
|
Leszek Koltunski
|
}
|
49 |
|
|
|
50 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51 |
|
|
|
52 |
|
|
private int numCubitsPerCorner(int numLayers)
|
53 |
|
|
{
|
54 |
|
|
return 3*((numLayers-1)/2)*((numLayers-3)/2) + 1;
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58 |
|
|
|
59 |
|
|
private int numCubitsPerEdge(int numLayers)
|
60 |
|
|
{
|
61 |
|
|
return numLayers-2;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65 |
|
|
|
66 |
7bbfc84f
|
Leszek Koltunski
|
public float[][] getCuts(int[] numLayers)
|
67 |
29b82486
|
Leszek Koltunski
|
{
|
68 |
a57e6870
|
Leszek Koltunski
|
return genericGetCuts(numLayers[0],0.5f-MEGA_D);
|
69 |
29b82486
|
Leszek Koltunski
|
}
|
70 |
|
|
|
71 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72 |
|
|
|
73 |
|
|
private float[] computeCenter(int center, int numLayers)
|
74 |
|
|
{
|
75 |
|
|
if( mCenterCoords==null ) initializeCenterCoords();
|
76 |
|
|
float[] coords = mCenterCoords[center];
|
77 |
0351740a
|
Leszek Koltunski
|
float A = (float)numLayers/3;
|
78 |
29b82486
|
Leszek Koltunski
|
|
79 |
|
|
return new float[] { A*coords[0], A*coords[1], A*coords[2] };
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83 |
|
|
// Fill out mCurrCorner{X,Y,Z} by applying appropriate Quat to mBasicCorner{X,Y,Z}
|
84 |
|
|
// Appropriate one: QUATS[QUAT_INDICES[corner]].
|
85 |
|
|
|
86 |
|
|
private void computeBasicCornerVectors(int corner)
|
87 |
|
|
{
|
88 |
|
|
if( mQuatCornerIndices==null ) initializeQuatIndices();
|
89 |
|
|
if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
|
90 |
|
|
|
91 |
89a00832
|
Leszek Koltunski
|
Static4D quat = mObjectQuats[mQuatCornerIndices[corner]];
|
92 |
29b82486
|
Leszek Koltunski
|
|
93 |
|
|
mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat);
|
94 |
|
|
mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat);
|
95 |
|
|
mCurrCornerV[2] = QuatHelper.rotateVectorByQuat(mBasicCornerV[2],quat);
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99 |
|
|
|
100 |
|
|
private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part)
|
101 |
|
|
{
|
102 |
|
|
if( mCorners==null ) initializeCorners();
|
103 |
|
|
if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
|
104 |
|
|
|
105 |
|
|
float D = numLayers/3.0f;
|
106 |
|
|
float[] corn = mCorners[corner];
|
107 |
|
|
|
108 |
|
|
if( part==0 )
|
109 |
|
|
{
|
110 |
|
|
return new float[] { corn[0]*D, corn[1]*D, corn[2]*D };
|
111 |
|
|
}
|
112 |
|
|
else
|
113 |
|
|
{
|
114 |
|
|
float E = 2.0f*D*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
|
115 |
|
|
int N = (numCubitsPerCorner-1)/3;
|
116 |
|
|
int block = (part-1) % N;
|
117 |
|
|
int index = (part-1) / N;
|
118 |
|
|
Static4D pri = mCurrCornerV[index];
|
119 |
|
|
Static4D sec = mCurrCornerV[(index+2)%3];
|
120 |
|
|
|
121 |
|
|
int layers= (numLayers-3)/2;
|
122 |
|
|
int multP = (block % layers) + 1;
|
123 |
|
|
int multS = (block / layers);
|
124 |
|
|
|
125 |
|
|
return new float[] {
|
126 |
|
|
corn[0]*D + (pri.get0()*multP + sec.get0()*multS)*E,
|
127 |
|
|
corn[1]*D + (pri.get1()*multP + sec.get1()*multS)*E,
|
128 |
|
|
corn[2]*D + (pri.get2()*multP + sec.get2()*multS)*E
|
129 |
|
|
};
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134 |
|
|
|
135 |
|
|
private int computeEdgeType(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
|
136 |
|
|
{
|
137 |
|
|
int part = (cubit - NUM_CORNERS*numCubitsPerCorner) % numCubitsPerEdge;
|
138 |
|
|
return (part+1)/2;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
|
|
|
143 |
|
|
private float[] computeEdge(int numLayers, int edge, int part)
|
144 |
|
|
{
|
145 |
|
|
if( mCenterCoords==null ) initializeCenterCoords();
|
146 |
|
|
if( mCorners==null ) initializeCorners();
|
147 |
|
|
if( mEdgeMap==null ) initializeEdgeMap();
|
148 |
|
|
|
149 |
|
|
float D = numLayers/3.0f;
|
150 |
|
|
float[] c1 = mCorners[ mEdgeMap[edge][0] ];
|
151 |
|
|
float[] c2 = mCorners[ mEdgeMap[edge][1] ];
|
152 |
|
|
float x = D * (c1[0]+c2[0]) / 2;
|
153 |
|
|
float y = D * (c1[1]+c2[1]) / 2;
|
154 |
|
|
float z = D * (c1[2]+c2[2]) / 2;
|
155 |
|
|
|
156 |
|
|
if( part==0 )
|
157 |
|
|
{
|
158 |
|
|
return new float[] { x, y, z };
|
159 |
|
|
}
|
160 |
|
|
else
|
161 |
|
|
{
|
162 |
|
|
int mult = (part+1)/2;
|
163 |
|
|
int dir = (part+1)%2;
|
164 |
|
|
float[] center = mCenterCoords[ mEdgeMap[edge][dir+2] ];
|
165 |
|
|
|
166 |
|
|
float vX = D*center[0] - x;
|
167 |
|
|
float vY = D*center[1] - y;
|
168 |
|
|
float vZ = D*center[2] - z;
|
169 |
|
|
|
170 |
|
|
float A = 3*mult*D*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f);
|
171 |
|
|
A /= (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
|
172 |
|
|
|
173 |
|
|
return new float[] { x+A*vX, y+A*vY, z+A*vZ };
|
174 |
|
|
}
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
178 |
|
|
|
179 |
7b832206
|
Leszek Koltunski
|
public float[][] getCubitPositions(int[] numLayers)
|
180 |
29b82486
|
Leszek Koltunski
|
{
|
181 |
a57e6870
|
Leszek Koltunski
|
int numL = numLayers[0];
|
182 |
|
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
183 |
|
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
184 |
29b82486
|
Leszek Koltunski
|
int numCubits = NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge + NUM_CENTERS;
|
185 |
|
|
int index=0;
|
186 |
|
|
|
187 |
|
|
final float[][] CENTERS = new float[numCubits][];
|
188 |
|
|
|
189 |
|
|
for(int corner=0; corner<NUM_CORNERS; corner++)
|
190 |
|
|
{
|
191 |
|
|
computeBasicCornerVectors(corner);
|
192 |
|
|
|
193 |
|
|
for(int part=0; part<numCubitsPerCorner; part++, index++)
|
194 |
|
|
{
|
195 |
a57e6870
|
Leszek Koltunski
|
CENTERS[index] = computeCorner(numCubitsPerCorner,numL,corner,part);
|
196 |
29b82486
|
Leszek Koltunski
|
}
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
for(int edge=0; edge<NUM_EDGES; edge++)
|
200 |
|
|
{
|
201 |
|
|
for(int part=0; part<numCubitsPerEdge; part++, index++)
|
202 |
|
|
{
|
203 |
a57e6870
|
Leszek Koltunski
|
CENTERS[index] = computeEdge(numL, edge, part );
|
204 |
29b82486
|
Leszek Koltunski
|
}
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
for(int center=0; center<NUM_CENTERS; center++, index++)
|
208 |
|
|
{
|
209 |
a57e6870
|
Leszek Koltunski
|
CENTERS[index] = computeCenter(center, numL);
|
210 |
29b82486
|
Leszek Koltunski
|
}
|
211 |
|
|
|
212 |
|
|
return CENTERS;
|
213 |
|
|
}
|
214 |
|
|
|
215 |
d0e6cf7f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
216 |
|
|
|
217 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
218 |
|
|
{
|
219 |
|
|
int numL = numLayers[0];
|
220 |
|
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
221 |
|
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
222 |
|
|
|
223 |
89a00832
|
Leszek Koltunski
|
return mObjectQuats[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
|
224 |
d0e6cf7f
|
Leszek Koltunski
|
}
|
225 |
|
|
|
226 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
227 |
|
|
|
228 |
|
|
private int getQuat(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
|
229 |
|
|
{
|
230 |
|
|
if( mQuatCornerIndices==null || mQuatEdgeIndices==null ) initializeQuatIndices();
|
231 |
|
|
if( mQuatCenterIndices==null ) initializeCenterIndices();
|
232 |
|
|
|
233 |
|
|
if( cubit < NUM_CORNERS*numCubitsPerCorner )
|
234 |
|
|
{
|
235 |
|
|
int corner = cubit/numCubitsPerCorner;
|
236 |
|
|
return mQuatCornerIndices[corner];
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
if( cubit < NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
|
240 |
|
|
{
|
241 |
|
|
int edge = (cubit-NUM_CORNERS*numCubitsPerCorner)/numCubitsPerEdge;
|
242 |
|
|
return mQuatEdgeIndices[edge];
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
int center = cubit - NUM_CORNERS*numCubitsPerCorner - NUM_EDGES*numCubitsPerEdge;
|
246 |
|
|
return mQuatCenterIndices[center];
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
250 |
|
|
|
251 |
84a17011
|
Leszek Koltunski
|
private float[][] getVertices(int variant)
|
252 |
29b82486
|
Leszek Koltunski
|
{
|
253 |
e30c522a
|
Leszek Koltunski
|
int[] numLayers = getNumLayers();
|
254 |
29b82486
|
Leszek Koltunski
|
int numVariants = getNumCubitVariants(numLayers);
|
255 |
e30c522a
|
Leszek Koltunski
|
int numL = numLayers[0];
|
256 |
29b82486
|
Leszek Koltunski
|
|
257 |
|
|
if( variant==0 )
|
258 |
|
|
{
|
259 |
a57e6870
|
Leszek Koltunski
|
float width = numL*(0.5f-MEGA_D)/(0.5f*(numL-1));
|
260 |
57ef6378
|
Leszek Koltunski
|
float X = width*COS18*SIN_HALFD;
|
261 |
|
|
float Y = width*SIN18;
|
262 |
|
|
float Z = width*COS18*COS_HALFD;
|
263 |
29b82486
|
Leszek Koltunski
|
|
264 |
84a17011
|
Leszek Koltunski
|
return new float[][]
|
265 |
29b82486
|
Leszek Koltunski
|
{
|
266 |
57ef6378
|
Leszek Koltunski
|
{ 0, 0 , 0 },
|
267 |
29b82486
|
Leszek Koltunski
|
{ X, Y , -Z },
|
268 |
57ef6378
|
Leszek Koltunski
|
{ 0, 2*Y ,-2*Z },
|
269 |
29b82486
|
Leszek Koltunski
|
{ -X, Y , -Z },
|
270 |
57ef6378
|
Leszek Koltunski
|
{ 0, 0-width, 0 },
|
271 |
29b82486
|
Leszek Koltunski
|
{ X, Y-width, -Z },
|
272 |
57ef6378
|
Leszek Koltunski
|
{ 0, 2*Y-width,-2*Z },
|
273 |
29b82486
|
Leszek Koltunski
|
{ -X, Y-width, -Z },
|
274 |
|
|
};
|
275 |
|
|
}
|
276 |
84a17011
|
Leszek Koltunski
|
else if( variant<numVariants-1 )
|
277 |
29b82486
|
Leszek Koltunski
|
{
|
278 |
e30c522a
|
Leszek Koltunski
|
int type = variant-1;
|
279 |
a57e6870
|
Leszek Koltunski
|
float height= numL*(0.5f-MEGA_D)*COS18/((numL-1)*0.5f);
|
280 |
|
|
float width = numL*2*MEGA_D + 2*type*height*SIN18/COS18;
|
281 |
29b82486
|
Leszek Koltunski
|
|
282 |
57ef6378
|
Leszek Koltunski
|
float W = width/2;
|
283 |
|
|
float X = height*SIN_HALFD;
|
284 |
|
|
float Y = height*SIN18/COS18;
|
285 |
|
|
float Z = height*COS_HALFD;
|
286 |
29b82486
|
Leszek Koltunski
|
|
287 |
84a17011
|
Leszek Koltunski
|
return new float[][]
|
288 |
29b82486
|
Leszek Koltunski
|
{
|
289 |
57ef6378
|
Leszek Koltunski
|
{ 0, W , 0 },
|
290 |
29b82486
|
Leszek Koltunski
|
{ X, W+Y , -Z },
|
291 |
57ef6378
|
Leszek Koltunski
|
{ 0, W+2*Y ,-2*Z },
|
292 |
29b82486
|
Leszek Koltunski
|
{ -X, W+Y , -Z },
|
293 |
57ef6378
|
Leszek Koltunski
|
{ 0, -W , 0 },
|
294 |
29b82486
|
Leszek Koltunski
|
{ X,-W-Y , -Z },
|
295 |
57ef6378
|
Leszek Koltunski
|
{ 0,-W-2*Y ,-2*Z },
|
296 |
29b82486
|
Leszek Koltunski
|
{ -X,-W-Y , -Z },
|
297 |
|
|
};
|
298 |
|
|
}
|
299 |
|
|
else
|
300 |
|
|
{
|
301 |
a57e6870
|
Leszek Koltunski
|
float width = 2*numL*(MEGA_D+(0.5f-MEGA_D)*SIN18);
|
302 |
0351740a
|
Leszek Koltunski
|
final double ANGLE = 0.825f*Math.PI;
|
303 |
57ef6378
|
Leszek Koltunski
|
final float cosA = (float)Math.cos(ANGLE);
|
304 |
|
|
final float sinA = (float)Math.sin(ANGLE);
|
305 |
29b82486
|
Leszek Koltunski
|
|
306 |
|
|
float R = 0.5f*width/COS54;
|
307 |
|
|
float X1 = R*COS54;
|
308 |
|
|
float Y1 = R*SIN54;
|
309 |
|
|
float X2 = R*COS18;
|
310 |
|
|
float Y2 = R*SIN18;
|
311 |
|
|
|
312 |
84a17011
|
Leszek Koltunski
|
return new float[][]
|
313 |
29b82486
|
Leszek Koltunski
|
{
|
314 |
84a17011
|
Leszek Koltunski
|
{-X1, Y1*sinA, Y1*cosA},
|
315 |
29b82486
|
Leszek Koltunski
|
{-X2,-Y2*sinA,-Y2*cosA},
|
316 |
c3a033e9
|
Leszek Koltunski
|
{ 0 ,-R*sinA ,-R*cosA },
|
317 |
29b82486
|
Leszek Koltunski
|
{+X2,-Y2*sinA,-Y2*cosA},
|
318 |
84a17011
|
Leszek Koltunski
|
{+X1, Y1*sinA, Y1*cosA},
|
319 |
c3a033e9
|
Leszek Koltunski
|
{ 0 , R*cosA ,-R*sinA }
|
320 |
29b82486
|
Leszek Koltunski
|
};
|
321 |
84a17011
|
Leszek Koltunski
|
}
|
322 |
|
|
}
|
323 |
29b82486
|
Leszek Koltunski
|
|
324 |
84a17011
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
325 |
|
|
|
326 |
|
|
public ObjectShape getObjectShape(int variant)
|
327 |
|
|
{
|
328 |
|
|
int[] numLayers = getNumLayers();
|
329 |
|
|
int numVariants = getNumCubitVariants(numLayers);
|
330 |
|
|
|
331 |
|
|
if( variant==0 )
|
332 |
|
|
{
|
333 |
|
|
int[][] indices =
|
334 |
|
|
{
|
335 |
|
|
{4,5,1,0},
|
336 |
|
|
{7,4,0,3},
|
337 |
|
|
{0,1,2,3},
|
338 |
|
|
{7,6,5,4},
|
339 |
|
|
{2,1,5,6},
|
340 |
|
|
{3,2,6,7}
|
341 |
|
|
};
|
342 |
|
|
|
343 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
344 |
|
|
}
|
345 |
|
|
if( variant<numVariants-1 )
|
346 |
|
|
{
|
347 |
|
|
int[][] indices =
|
348 |
|
|
{
|
349 |
|
|
{4,5,1,0},
|
350 |
|
|
{7,4,0,3},
|
351 |
|
|
{3,2,6,7},
|
352 |
|
|
{2,1,5,6},
|
353 |
|
|
{0,1,2,3},
|
354 |
|
|
{7,6,5,4}
|
355 |
|
|
};
|
356 |
|
|
|
357 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
358 |
|
|
}
|
359 |
|
|
else
|
360 |
|
|
{
|
361 |
4e9f2df5
|
Leszek Koltunski
|
int[][] indices =
|
362 |
29b82486
|
Leszek Koltunski
|
{
|
363 |
|
|
{0,1,2,3,4},
|
364 |
846b69f3
|
Leszek Koltunski
|
{5,1,0},
|
365 |
|
|
{5,2,1},
|
366 |
|
|
{5,3,2},
|
367 |
|
|
{5,4,3},
|
368 |
|
|
{5,0,4}
|
369 |
29b82486
|
Leszek Koltunski
|
};
|
370 |
|
|
|
371 |
84a17011
|
Leszek Koltunski
|
return new ObjectShape(getVertices(variant), indices);
|
372 |
3ee1d662
|
Leszek Koltunski
|
}
|
373 |
|
|
}
|
374 |
|
|
|
375 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
376 |
|
|
|
377 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
378 |
|
|
{
|
379 |
|
|
int[] numLayers = getNumLayers();
|
380 |
|
|
int numVariants = getNumCubitVariants(numLayers);
|
381 |
|
|
int numL = numLayers[0];
|
382 |
|
|
boolean small = numL<=3;
|
383 |
|
|
|
384 |
|
|
if( variant==0 )
|
385 |
|
|
{
|
386 |
3bf19410
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
387 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { {h1,34,0.3f,0.2f,3,0,0}, {0.001f,10,0.0f,0.0f,2,0,0} };
|
388 |
|
|
int[] indices = { 0,0,0,1,1,1};
|
389 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
390 |
3ee1d662
|
Leszek Koltunski
|
}
|
391 |
|
|
if( variant<numVariants-1 )
|
392 |
|
|
{
|
393 |
|
|
int N = small ? 5 : 3;
|
394 |
3bf19410
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
395 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { {h1,34,0.2f,0.2f,N,0,0},{0.001f,34,0.3f,0.2f,2,0,0} };
|
396 |
|
|
int[] indices = { 0,0,1,1,1,1};
|
397 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
398 |
3ee1d662
|
Leszek Koltunski
|
}
|
399 |
|
|
else
|
400 |
|
|
{
|
401 |
|
|
float width = 2*numL*(MEGA_D+(0.5f-MEGA_D)*SIN18);
|
402 |
|
|
float R = 0.5f*width/COS54;
|
403 |
66de0d91
|
Leszek Koltunski
|
int N = small ? 4 : 3;
|
404 |
3bf19410
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : (small ? 0.04f : 0.015f);
|
405 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { { h1,45, R/3,0.2f,N,0,0},{0.001f,45, R/3,0.2f,2,0,0} };
|
406 |
|
|
int[] indices = { 0,1,1,1,1,1 };
|
407 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
408 |
|
|
}
|
409 |
|
|
}
|
410 |
29b82486
|
Leszek Koltunski
|
|
411 |
84a17011
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
412 |
29b82486
|
Leszek Koltunski
|
|
413 |
ba8dbe0e
|
Leszek Koltunski
|
|
414 |
|
|
|
415 |
84a17011
|
Leszek Koltunski
|
public ObjectVertexEffects getVertexEffects(int variant)
|
416 |
|
|
{
|
417 |
|
|
if( variant==0 )
|
418 |
|
|
{
|
419 |
ba8dbe0e
|
Leszek Koltunski
|
int[] numLayers = getNumLayers();
|
420 |
|
|
int numL = numLayers[0];
|
421 |
|
|
float width = numL*(0.5f-MEGA_D)/(0.5f*(numL-1));
|
422 |
|
|
float Y = width*SIN18;
|
423 |
|
|
float Z = width*COS18*COS_HALFD;
|
424 |
|
|
|
425 |
|
|
float[][] corners = { {0.03f,0.15f}, {0.02f,0.10f} };
|
426 |
|
|
int[] cornerIndices = { 0,1,1,1,-1,-1,-1,-1 };
|
427 |
|
|
float[][] centers = { { 0.0f, 2*Y-width,-2*Z } };
|
428 |
|
|
int[] centerIndices = { 0,0,0,0,-1,-1,-1,-1 };
|
429 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
430 |
84a17011
|
Leszek Koltunski
|
}
|
431 |
|
|
else
|
432 |
|
|
{
|
433 |
ba8dbe0e
|
Leszek Koltunski
|
return null;
|
434 |
29b82486
|
Leszek Koltunski
|
}
|
435 |
|
|
}
|
436 |
|
|
|
437 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
438 |
|
|
|
439 |
e30c522a
|
Leszek Koltunski
|
public int getNumCubitVariants(int[] numLayers)
|
440 |
29b82486
|
Leszek Koltunski
|
{
|
441 |
ec42a6fe
|
Leszek Koltunski
|
return 2 + numLayers[0]/2;
|
442 |
29b82486
|
Leszek Koltunski
|
}
|
443 |
|
|
|
444 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
445 |
|
|
|
446 |
e30c522a
|
Leszek Koltunski
|
public int getCubitVariant(int cubit, int[] numLayers)
|
447 |
29b82486
|
Leszek Koltunski
|
{
|
448 |
a57e6870
|
Leszek Koltunski
|
int numL = numLayers[0];
|
449 |
|
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
450 |
29b82486
|
Leszek Koltunski
|
|
451 |
|
|
if( cubit<NUM_CORNERS*numCubitsPerCorner ) return 0;
|
452 |
|
|
|
453 |
a57e6870
|
Leszek Koltunski
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
454 |
29b82486
|
Leszek Koltunski
|
|
455 |
|
|
if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
|
456 |
|
|
{
|
457 |
|
|
int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
|
458 |
|
|
return type+1;
|
459 |
|
|
}
|
460 |
|
|
|
461 |
61aa85e4
|
Leszek Koltunski
|
return getNumCubitVariants(numLayers)-1;
|
462 |
29b82486
|
Leszek Koltunski
|
}
|
463 |
|
|
|
464 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
465 |
|
|
|
466 |
d53fb890
|
Leszek Koltunski
|
public float getStickerRadius()
|
467 |
29b82486
|
Leszek Koltunski
|
{
|
468 |
b0720f49
|
Leszek Koltunski
|
return 0.13f;
|
469 |
|
|
}
|
470 |
29b82486
|
Leszek Koltunski
|
|
471 |
b0720f49
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
472 |
29b82486
|
Leszek Koltunski
|
|
473 |
d53fb890
|
Leszek Koltunski
|
public float getStickerStroke()
|
474 |
b0720f49
|
Leszek Koltunski
|
{
|
475 |
|
|
float stroke = 0.18f;
|
476 |
43a4ccff
|
Leszek Koltunski
|
|
477 |
3bf19410
|
Leszek Koltunski
|
if( isInIconMode() )
|
478 |
b0720f49
|
Leszek Koltunski
|
{
|
479 |
|
|
int[] numLayers = getNumLayers();
|
480 |
|
|
stroke*= ( numLayers[0]==3 ? 1.5f : 2.2f );
|
481 |
|
|
}
|
482 |
7af68038
|
Leszek Koltunski
|
|
483 |
b0720f49
|
Leszek Koltunski
|
return stroke;
|
484 |
|
|
}
|
485 |
8592461c
|
Leszek Koltunski
|
|
486 |
00f4980d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
487 |
|
|
|
488 |
d53fb890
|
Leszek Koltunski
|
public float[][] getStickerAngles()
|
489 |
00f4980d
|
Leszek Koltunski
|
{
|
490 |
|
|
return null;
|
491 |
|
|
}
|
492 |
|
|
|
493 |
61aa85e4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
494 |
|
|
|
495 |
5f54927b
|
Leszek Koltunski
|
public String getShortName()
|
496 |
61aa85e4
|
Leszek Koltunski
|
{
|
497 |
5f54927b
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
498 |
61aa85e4
|
Leszek Koltunski
|
{
|
499 |
5f54927b
|
Leszek Koltunski
|
case 3: return ObjectType.MEGA_3.name();
|
500 |
|
|
case 5: return ObjectType.MEGA_5.name();
|
501 |
61aa85e4
|
Leszek Koltunski
|
}
|
502 |
5f54927b
|
Leszek Koltunski
|
|
503 |
|
|
return ObjectType.MEGA_3.name();
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
507 |
|
|
|
508 |
1d581993
|
Leszek Koltunski
|
public ObjectSignature getSignature()
|
509 |
5f54927b
|
Leszek Koltunski
|
{
|
510 |
|
|
switch(getNumLayers()[0])
|
511 |
|
|
{
|
512 |
2dffaf22
|
Leszek Koltunski
|
case 3: return new ObjectSignature(ObjectSignatures.MEGA_3);
|
513 |
|
|
case 5: return new ObjectSignature(ObjectSignatures.MEGA_5);
|
514 |
5f54927b
|
Leszek Koltunski
|
}
|
515 |
|
|
|
516 |
1d581993
|
Leszek Koltunski
|
return null;
|
517 |
61aa85e4
|
Leszek Koltunski
|
}
|
518 |
|
|
|
519 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
520 |
|
|
|
521 |
e26eb4e7
|
Leszek Koltunski
|
public String getObjectName()
|
522 |
29b82486
|
Leszek Koltunski
|
{
|
523 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
524 |
|
|
{
|
525 |
|
|
case 3: return "Megaminx";
|
526 |
|
|
case 5: return "Gigaminx";
|
527 |
|
|
}
|
528 |
|
|
return "Megaminx";
|
529 |
29b82486
|
Leszek Koltunski
|
}
|
530 |
|
|
|
531 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
532 |
|
|
|
533 |
e26eb4e7
|
Leszek Koltunski
|
public String getInventor()
|
534 |
29b82486
|
Leszek Koltunski
|
{
|
535 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
536 |
|
|
{
|
537 |
|
|
case 3: return "Ferenc Szlivka";
|
538 |
|
|
case 5: return "Tyler Fox";
|
539 |
|
|
}
|
540 |
|
|
return "Ferenc Szlivka";
|
541 |
29b82486
|
Leszek Koltunski
|
}
|
542 |
|
|
|
543 |
59c20632
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
544 |
|
|
|
545 |
e26eb4e7
|
Leszek Koltunski
|
public int getYearOfInvention()
|
546 |
59c20632
|
Leszek Koltunski
|
{
|
547 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
548 |
59c20632
|
Leszek Koltunski
|
{
|
549 |
|
|
case 3: return 1982;
|
550 |
|
|
case 5: return 2006;
|
551 |
|
|
}
|
552 |
e26eb4e7
|
Leszek Koltunski
|
return 2006;
|
553 |
59c20632
|
Leszek Koltunski
|
}
|
554 |
|
|
|
555 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
556 |
|
|
|
557 |
e26eb4e7
|
Leszek Koltunski
|
public int getComplexity()
|
558 |
29b82486
|
Leszek Koltunski
|
{
|
559 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
560 |
|
|
{
|
561 |
b4223a92
|
Leszek Koltunski
|
case 3: return 3;
|
562 |
|
|
case 5: return 4;
|
563 |
e26eb4e7
|
Leszek Koltunski
|
}
|
564 |
a57e6870
|
Leszek Koltunski
|
return 9;
|
565 |
29b82486
|
Leszek Koltunski
|
}
|
566 |
052e0362
|
Leszek Koltunski
|
|
567 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
568 |
|
|
|
569 |
|
|
public String[][] getTutorials()
|
570 |
|
|
{
|
571 |
|
|
int[] numLayers = getNumLayers();
|
572 |
|
|
|
573 |
|
|
switch(numLayers[0])
|
574 |
|
|
{
|
575 |
|
|
case 3: return new String[][] {
|
576 |
|
|
{"gb","j4x61L5Onzk","How to Solve the Megaminx","Z3"},
|
577 |
|
|
{"es","xuKbT6Il0Ko","Resolver Megaminx","Cuby"},
|
578 |
|
|
{"ru","WgoguOY3tKI","Как собрать Мегаминкс","Алексей Ярыгин"},
|
579 |
|
|
{"fr","Ln1vl85puKo","Résoudre le Megaminx","Victor Colin"},
|
580 |
|
|
{"de","d-GQD6CBdB8","Megaminx lösen","Pezcraft"},
|
581 |
|
|
{"pl","BZTW6ApeRZE","Jak ułożyć: Megaminx","DżoDżo"},
|
582 |
|
|
{"br","0BTzkDZW078","Como resolver o Megaminx 1/2","Pedro Filho"},
|
583 |
|
|
{"br","VVHzZI73BN0","Como resolver o Megaminx 2/2","Pedro Filho"},
|
584 |
|
|
{"kr","2NUsMclrD-0","메가밍크스 예시솔빙","iamzoone"},
|
585 |
a399e91b
|
Leszek Koltunski
|
{"vn","wRN3t91vD8w","Tutorial N.9 - Megaminx","Duy Thích Rubik"},
|
586 |
052e0362
|
Leszek Koltunski
|
};
|
587 |
|
|
case 5: return new String[][] {
|
588 |
|
|
{"gb","MNBMm8BnHtQ","Solve the Gigaminx Part 1","BeardedCubing"},
|
589 |
|
|
{"gb","QrrP4GwqVMw","Solve the Gigaminx Part 2","BeardedCubing"},
|
590 |
|
|
{"es","ex5EQMBxV1U","Tutorial Gigaminx","RubikArt"},
|
591 |
|
|
{"ru","UJYK3SHjSGg","Как собрать Гигаминкс ч.1","Артем Мартиросов"},
|
592 |
|
|
{"ru","-iBCpr4Gwsw","Как собрать Гигаминкс ч.2","Артем Мартиросов"},
|
593 |
|
|
{"ru","4-dI7NCW8n8","Как собрать Гигаминкс ч.3","Артем Мартиросов"},
|
594 |
|
|
{"fr","e485fh0V1dg","Résolution du Gigaminx","Asthalis"},
|
595 |
|
|
{"de","APSAj4UtOAg","Megaminx 5x5 lösen","JamesKnopf"},
|
596 |
|
|
{"pl","qbKLMCX1wKg","Jak ułożyć Gigaminxa cz.1","chomik19751"},
|
597 |
|
|
{"pl","JQOXD3qleH4","Jak ułożyć Gigaminxa cz.2","chomik19751"},
|
598 |
|
|
{"pl","WF2katJ22FA","Jak ułożyć Gigaminxa cz.3","chomik19751"},
|
599 |
|
|
{"pl","jlyRrJjH4qQ","Jak ułożyć Gigaminxa cz.4","chomik19751"},
|
600 |
|
|
{"kr","HfPFrWuz6z4","기가밍크스 gigaminx","큐브놀이터"},
|
601 |
a399e91b
|
Leszek Koltunski
|
{"vn","yJzejHqZscY","Tutorial N.49 - Gigaminx","Duy Thích Rubik"},
|
602 |
052e0362
|
Leszek Koltunski
|
};
|
603 |
|
|
}
|
604 |
|
|
return null;
|
605 |
|
|
}
|
606 |
29b82486
|
Leszek Koltunski
|
}
|