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 TwistyKilominx extends TwistyDodecahedron
|
32 |
29b82486
|
Leszek Koltunski
|
{
|
33 |
cf93ea4e
|
Leszek Koltunski
|
public TwistyKilominx(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
|
34 |
29b82486
|
Leszek Koltunski
|
{
|
35 |
cf93ea4e
|
Leszek Koltunski
|
super(meshState, iconMode, quat, move, scale, data, asset);
|
36 |
29b82486
|
Leszek Koltunski
|
}
|
37 |
|
|
|
38 |
ed0988c0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
// make the 'center' sticker artificially smaller, so that we paint over the area in the center of the face.
|
40 |
|
|
|
41 |
|
|
@Override
|
42 |
|
|
public void adjustStickerCoords()
|
43 |
|
|
{
|
44 |
|
|
int[] numLayers = getNumLayers();
|
45 |
169762ac
|
Leszek Koltunski
|
int index = numLayers[0]==3 ? 0:3;
|
46 |
ed0988c0
|
Leszek Koltunski
|
float CENTER_CORR = 0.87f;
|
47 |
|
|
|
48 |
|
|
mStickerCoords[index][2] *= CENTER_CORR;
|
49 |
|
|
mStickerCoords[index][3] *= CENTER_CORR;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
|
|
private int numCubitsPerCorner(int numLayers)
|
55 |
|
|
{
|
56 |
|
|
return 3*((numLayers-3)/2)*((numLayers-5)/2) + (numLayers<5 ? 0:1);
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60 |
|
|
|
61 |
|
|
private int numCubitsPerEdge(int numLayers)
|
62 |
|
|
{
|
63 |
|
|
return numLayers<5 ? 0 : 2*(numLayers-4);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67 |
|
|
|
68 |
7bbfc84f
|
Leszek Koltunski
|
public float[][] getCuts(int[] numLayers)
|
69 |
29b82486
|
Leszek Koltunski
|
{
|
70 |
a57e6870
|
Leszek Koltunski
|
return genericGetCuts(numLayers[0],0.5f);
|
71 |
29b82486
|
Leszek Koltunski
|
}
|
72 |
|
|
|
73 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74 |
|
|
// Fill out mCurrCorner{X,Y,Z} by applying appropriate Quat to mBasicCorner{X,Y,Z}
|
75 |
|
|
// Appropriate one: QUATS[QUAT_INDICES[corner]].
|
76 |
|
|
|
77 |
|
|
private void computeBasicCornerVectors(int corner)
|
78 |
|
|
{
|
79 |
|
|
if( mQuatCornerIndices==null ) initializeQuatIndices();
|
80 |
|
|
if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
|
81 |
|
|
|
82 |
89a00832
|
Leszek Koltunski
|
Static4D quat = mObjectQuats[mQuatCornerIndices[corner]];
|
83 |
29b82486
|
Leszek Koltunski
|
|
84 |
|
|
mCurrCornerV[0] = QuatHelper.rotateVectorByQuat(mBasicCornerV[0],quat);
|
85 |
|
|
mCurrCornerV[1] = QuatHelper.rotateVectorByQuat(mBasicCornerV[1],quat);
|
86 |
|
|
mCurrCornerV[2] = QuatHelper.rotateVectorByQuat(mBasicCornerV[2],quat);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90 |
|
|
|
91 |
|
|
private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part)
|
92 |
|
|
{
|
93 |
|
|
if( mCorners==null ) initializeCorners();
|
94 |
|
|
if( mCurrCornerV==null || mBasicCornerV==null ) initializeCornerV();
|
95 |
|
|
|
96 |
|
|
float D = numLayers/3.0f;
|
97 |
|
|
float[] corn = mCorners[corner];
|
98 |
|
|
|
99 |
|
|
if( part==0 )
|
100 |
|
|
{
|
101 |
|
|
return new float[] { corn[0]*D, corn[1]*D, corn[2]*D };
|
102 |
|
|
}
|
103 |
|
|
else
|
104 |
|
|
{
|
105 |
|
|
float E = D/(0.5f*(numLayers-1)); // ?? maybe 0.5*
|
106 |
|
|
int N = (numCubitsPerCorner-1)/3;
|
107 |
|
|
int block = (part-1) % N;
|
108 |
|
|
int index = (part-1) / N;
|
109 |
|
|
Static4D pri = mCurrCornerV[index];
|
110 |
|
|
Static4D sec = mCurrCornerV[(index+2)%3];
|
111 |
|
|
|
112 |
|
|
int layers= (numLayers-5)/2;
|
113 |
|
|
int multP = (block % layers) + 1;
|
114 |
|
|
int multS = (block / layers);
|
115 |
|
|
|
116 |
|
|
return new float[] {
|
117 |
|
|
corn[0]*D + (pri.get0()*multP + sec.get0()*multS)*E,
|
118 |
|
|
corn[1]*D + (pri.get1()*multP + sec.get1()*multS)*E,
|
119 |
|
|
corn[2]*D + (pri.get2()*multP + sec.get2()*multS)*E
|
120 |
|
|
};
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125 |
|
|
|
126 |
|
|
private float[] computeCenter(int numLayers, int center, int part)
|
127 |
|
|
{
|
128 |
|
|
if( mCenterCoords==null ) initializeCenterCoords();
|
129 |
|
|
if( mCorners ==null ) initializeCorners();
|
130 |
|
|
if( mCenterMap ==null ) initializeCenterMap();
|
131 |
|
|
|
132 |
|
|
int corner = mCenterMap[center][part];
|
133 |
|
|
float[] cent = mCenterCoords[center];
|
134 |
|
|
float[] corn = mCorners[corner];
|
135 |
|
|
float D = numLayers/3.0f;
|
136 |
|
|
float F = 1.0f - (2.0f*numLayers-6.0f)/(numLayers-1)*COS54*COS54;
|
137 |
|
|
|
138 |
|
|
return new float[]
|
139 |
|
|
{
|
140 |
|
|
D * ( cent[0] + (corn[0]-cent[0])*F),
|
141 |
|
|
D * ( cent[1] + (corn[1]-cent[1])*F),
|
142 |
|
|
D * ( cent[2] + (corn[2]-cent[2])*F)
|
143 |
|
|
};
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147 |
|
|
|
148 |
|
|
private int computeEdgeType(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
|
149 |
|
|
{
|
150 |
|
|
int part = (cubit - NUM_CORNERS*numCubitsPerCorner) % numCubitsPerEdge;
|
151 |
|
|
return part - 2*(part/4);
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155 |
|
|
|
156 |
|
|
private float[] computeEdge(int numLayers, int edge, int part)
|
157 |
|
|
{
|
158 |
|
|
if( mCenterCoords==null ) initializeCenterCoords();
|
159 |
|
|
if( mCorners==null ) initializeCorners();
|
160 |
|
|
if( mEdgeMap==null ) initializeEdgeMap();
|
161 |
|
|
|
162 |
|
|
float D = numLayers/3.0f;
|
163 |
|
|
float[] c1 = mCorners[ mEdgeMap[edge][0] ];
|
164 |
|
|
float[] c2 = mCorners[ mEdgeMap[edge][1] ];
|
165 |
|
|
|
166 |
|
|
int leftRight = 2*(part%2) -1;
|
167 |
|
|
part /= 2;
|
168 |
|
|
|
169 |
|
|
if( part==0 )
|
170 |
|
|
{
|
171 |
|
|
float T = 0.5f + leftRight/(numLayers-1.0f);
|
172 |
|
|
float x = D * (T*c1[0]+(1.0f-T)*c2[0]);
|
173 |
|
|
float y = D * (T*c1[1]+(1.0f-T)*c2[1]);
|
174 |
|
|
float z = D * (T*c1[2]+(1.0f-T)*c2[2]);
|
175 |
|
|
|
176 |
|
|
return new float[] { x, y, z };
|
177 |
|
|
}
|
178 |
|
|
else
|
179 |
|
|
{
|
180 |
|
|
int mult = (part+1)/2;
|
181 |
|
|
int dir = (part+1)%2;
|
182 |
|
|
float[] center = mCenterCoords[ mEdgeMap[edge][dir+2] ];
|
183 |
|
|
float x = 0.5f * D * (c1[0]+c2[0]);
|
184 |
|
|
float y = 0.5f * D * (c1[1]+c2[1]);
|
185 |
|
|
float z = 0.5f * D * (c1[2]+c2[2]);
|
186 |
|
|
|
187 |
|
|
float vX = D*center[0] - x;
|
188 |
|
|
float vY = D*center[1] - y;
|
189 |
|
|
float vZ = D*center[2] - z;
|
190 |
|
|
|
191 |
|
|
float T = 0.5f + leftRight*(mult*SIN18 + 1.0f)/(numLayers-1);
|
192 |
|
|
|
193 |
|
|
x = D * (T*c1[0]+(1.0f-T)*c2[0]);
|
194 |
|
|
y = D * (T*c1[1]+(1.0f-T)*c2[1]);
|
195 |
|
|
z = D * (T*c1[2]+(1.0f-T)*c2[2]);
|
196 |
|
|
|
197 |
|
|
float H = mult*D*COS18/(numLayers-1);
|
198 |
|
|
H /= (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
|
199 |
|
|
|
200 |
|
|
return new float[] { x + H*vX, y + H*vY, z + H*vZ };
|
201 |
|
|
}
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
205 |
|
|
|
206 |
7b832206
|
Leszek Koltunski
|
public float[][] getCubitPositions(int[] numLayers)
|
207 |
29b82486
|
Leszek Koltunski
|
{
|
208 |
|
|
if( mCorners==null ) initializeCorners();
|
209 |
|
|
|
210 |
a57e6870
|
Leszek Koltunski
|
int numL = numLayers[0];
|
211 |
|
|
if( numL<5 ) return mCorners;
|
212 |
|
|
|
213 |
|
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
214 |
|
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
215 |
29b82486
|
Leszek Koltunski
|
int numCubitsPerCenter = 5;
|
216 |
|
|
int numCubits = NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge + NUM_CENTERS*numCubitsPerCenter;
|
217 |
|
|
int index=0;
|
218 |
|
|
|
219 |
|
|
final float[][] CENTERS = new float[numCubits][];
|
220 |
|
|
|
221 |
|
|
for(int corner=0; corner<NUM_CORNERS; corner++)
|
222 |
|
|
{
|
223 |
|
|
computeBasicCornerVectors(corner);
|
224 |
|
|
|
225 |
|
|
for(int part=0; part<numCubitsPerCorner; part++, index++)
|
226 |
|
|
{
|
227 |
a57e6870
|
Leszek Koltunski
|
CENTERS[index] = computeCorner(numCubitsPerCorner,numL,corner,part);
|
228 |
29b82486
|
Leszek Koltunski
|
}
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
for(int edge=0; edge<NUM_EDGES; edge++)
|
232 |
|
|
{
|
233 |
|
|
for(int part=0; part<numCubitsPerEdge; part++, index++)
|
234 |
|
|
{
|
235 |
a57e6870
|
Leszek Koltunski
|
CENTERS[index] = computeEdge(numL, edge, part );
|
236 |
29b82486
|
Leszek Koltunski
|
}
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
for(int center=0; center<NUM_CENTERS; center++)
|
240 |
|
|
{
|
241 |
|
|
for(int part=0; part<numCubitsPerCenter; part++, index++)
|
242 |
|
|
{
|
243 |
a57e6870
|
Leszek Koltunski
|
CENTERS[index] = computeCenter(numL,center, part);
|
244 |
29b82486
|
Leszek Koltunski
|
}
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
return CENTERS;
|
248 |
|
|
}
|
249 |
|
|
|
250 |
d0e6cf7f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
251 |
|
|
|
252 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
253 |
|
|
{
|
254 |
|
|
int numL = numLayers[0];
|
255 |
|
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
256 |
|
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
257 |
89a00832
|
Leszek Koltunski
|
int q = getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge);
|
258 |
|
|
return mObjectQuats[q];
|
259 |
d0e6cf7f
|
Leszek Koltunski
|
}
|
260 |
|
|
|
261 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
262 |
|
|
|
263 |
|
|
private int getQuat(int cubit, int numCubitsPerCorner, int numCubitsPerEdge)
|
264 |
|
|
{
|
265 |
|
|
if( mQuatCornerIndices==null || mQuatEdgeIndices==null ) initializeQuatIndices();
|
266 |
|
|
if( mCenterMap==null ) initializeCenterMap();
|
267 |
|
|
|
268 |
|
|
if( cubit < NUM_CORNERS*numCubitsPerCorner )
|
269 |
|
|
{
|
270 |
|
|
int corner = cubit/numCubitsPerCorner;
|
271 |
|
|
return mQuatCornerIndices[corner];
|
272 |
|
|
}
|
273 |
|
|
|
274 |
|
|
if( cubit < NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
|
275 |
|
|
{
|
276 |
|
|
int edge = (cubit-NUM_CORNERS*numCubitsPerCorner)/numCubitsPerEdge;
|
277 |
|
|
return mQuatEdgeIndices[edge];
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
if( numCubitsPerCorner==0 )
|
281 |
|
|
{
|
282 |
|
|
return mQuatCornerIndices[cubit];
|
283 |
|
|
}
|
284 |
|
|
else
|
285 |
|
|
{
|
286 |
|
|
cubit -= (NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge);
|
287 |
|
|
int numCubitsPerCenter = 5;
|
288 |
|
|
int face = cubit/numCubitsPerCenter;
|
289 |
|
|
int index= cubit%numCubitsPerCenter;
|
290 |
|
|
int center=mCenterMap[face][index];
|
291 |
|
|
return mQuatCornerIndices[center];
|
292 |
|
|
}
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
296 |
|
|
|
297 |
84a17011
|
Leszek Koltunski
|
private float[][] getVertices(int variant)
|
298 |
29b82486
|
Leszek Koltunski
|
{
|
299 |
e30c522a
|
Leszek Koltunski
|
int[] numLayers = getNumLayers();
|
300 |
29b82486
|
Leszek Koltunski
|
int numVariants = getNumCubitVariants(numLayers);
|
301 |
e30c522a
|
Leszek Koltunski
|
int numL = numLayers[0];
|
302 |
66de0d91
|
Leszek Koltunski
|
boolean small = numL<=3;
|
303 |
29b82486
|
Leszek Koltunski
|
|
304 |
66de0d91
|
Leszek Koltunski
|
if( variant==0 && !small )
|
305 |
29b82486
|
Leszek Koltunski
|
{
|
306 |
a57e6870
|
Leszek Koltunski
|
float width = numL/(numL-1.0f);
|
307 |
57ef6378
|
Leszek Koltunski
|
float X = width*COS18*SIN_HALFD;
|
308 |
|
|
float Y = width*SIN18;
|
309 |
|
|
float Z = width*COS18*COS_HALFD;
|
310 |
29b82486
|
Leszek Koltunski
|
|
311 |
84a17011
|
Leszek Koltunski
|
return new float[][]
|
312 |
29b82486
|
Leszek Koltunski
|
{
|
313 |
57ef6378
|
Leszek Koltunski
|
{ 0, 0 , 0 },
|
314 |
29b82486
|
Leszek Koltunski
|
{ X, Y , -Z },
|
315 |
57ef6378
|
Leszek Koltunski
|
{ 0, 2*Y ,-2*Z },
|
316 |
29b82486
|
Leszek Koltunski
|
{ -X, Y , -Z },
|
317 |
57ef6378
|
Leszek Koltunski
|
{ 0, 0-width, 0 },
|
318 |
29b82486
|
Leszek Koltunski
|
{ X, Y-width, -Z },
|
319 |
57ef6378
|
Leszek Koltunski
|
{ 0, 2*Y-width,-2*Z },
|
320 |
29b82486
|
Leszek Koltunski
|
{ -X, Y-width, -Z },
|
321 |
|
|
};
|
322 |
|
|
}
|
323 |
84a17011
|
Leszek Koltunski
|
else if( variant<numVariants-1 )
|
324 |
29b82486
|
Leszek Koltunski
|
{
|
325 |
e30c522a
|
Leszek Koltunski
|
int type = variant-1;
|
326 |
a57e6870
|
Leszek Koltunski
|
float tmpVal= numL/(numL-1.0f);
|
327 |
29b82486
|
Leszek Koltunski
|
float height= tmpVal*COS18;
|
328 |
|
|
float width = tmpVal + (type/2)*tmpVal*SIN18;
|
329 |
|
|
boolean left = (type%2)==0;
|
330 |
|
|
|
331 |
57ef6378
|
Leszek Koltunski
|
float X = height*SIN_HALFD;
|
332 |
|
|
float Y = height*SIN18/COS18;
|
333 |
|
|
float Z = height*COS_HALFD;
|
334 |
29b82486
|
Leszek Koltunski
|
|
335 |
4e9f2df5
|
Leszek Koltunski
|
float[][] vertices =
|
336 |
29b82486
|
Leszek Koltunski
|
{
|
337 |
57ef6378
|
Leszek Koltunski
|
{ 0, 0 , 0 },
|
338 |
29b82486
|
Leszek Koltunski
|
{ X, Y , -Z },
|
339 |
57ef6378
|
Leszek Koltunski
|
{ 0, 2*Y ,-2*Z },
|
340 |
29b82486
|
Leszek Koltunski
|
{ -X, Y , -Z },
|
341 |
57ef6378
|
Leszek Koltunski
|
{ 0, -width, 0 },
|
342 |
29b82486
|
Leszek Koltunski
|
{ X, -width, -Z },
|
343 |
57ef6378
|
Leszek Koltunski
|
{ 0, -width,-2*Z },
|
344 |
29b82486
|
Leszek Koltunski
|
{ -X, -width, -Z },
|
345 |
|
|
};
|
346 |
|
|
|
347 |
|
|
if( !left )
|
348 |
|
|
{
|
349 |
84a17011
|
Leszek Koltunski
|
int len = vertices.length;
|
350 |
29b82486
|
Leszek Koltunski
|
for(int i=0; i<len; i++) vertices[i][1] = -vertices[i][1];
|
351 |
|
|
}
|
352 |
84a17011
|
Leszek Koltunski
|
return vertices;
|
353 |
29b82486
|
Leszek Koltunski
|
}
|
354 |
|
|
else
|
355 |
|
|
{
|
356 |
a57e6870
|
Leszek Koltunski
|
float width = (1+0.5f*(numL-3)*SIN18)*numL/(numL-1);
|
357 |
57ef6378
|
Leszek Koltunski
|
float X = width*COS18*SIN_HALFD;
|
358 |
|
|
float Y = width*SIN18;
|
359 |
|
|
float Z = width*COS18*COS_HALFD;
|
360 |
|
|
float H = width*(SIN54/COS54);
|
361 |
|
|
float H3= H/COS_HALFD;
|
362 |
|
|
float X3= H*SIN_HALFD;
|
363 |
|
|
float Z3= H*COS_HALFD;
|
364 |
|
|
float C = 1/(COS54*(float)Math.sqrt(2-2*SIN18));
|
365 |
29b82486
|
Leszek Koltunski
|
|
366 |
84a17011
|
Leszek Koltunski
|
return new float[][]
|
367 |
29b82486
|
Leszek Koltunski
|
{
|
368 |
57ef6378
|
Leszek Koltunski
|
{ 0, 0 , 0 },
|
369 |
29b82486
|
Leszek Koltunski
|
{ X, Y , -Z },
|
370 |
57ef6378
|
Leszek Koltunski
|
{ 0,C*2*Y ,-2*C*Z },
|
371 |
29b82486
|
Leszek Koltunski
|
{ -X, Y , -Z },
|
372 |
57ef6378
|
Leszek Koltunski
|
{ 0,-width, 0 },
|
373 |
29b82486
|
Leszek Koltunski
|
{ X3,-width, -Z3 },
|
374 |
57ef6378
|
Leszek Koltunski
|
{ 0,-width, -H3 },
|
375 |
29b82486
|
Leszek Koltunski
|
{ -X3,-width, -Z3 }
|
376 |
|
|
};
|
377 |
84a17011
|
Leszek Koltunski
|
}
|
378 |
|
|
}
|
379 |
|
|
|
380 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
381 |
|
|
|
382 |
|
|
public ObjectShape getObjectShape(int variant)
|
383 |
|
|
{
|
384 |
|
|
int[] numLayers = getNumLayers();
|
385 |
|
|
int numVariants = getNumCubitVariants(numLayers);
|
386 |
|
|
int numL = numLayers[0];
|
387 |
|
|
boolean small = numL<=3;
|
388 |
|
|
|
389 |
|
|
if( variant==0 && !small )
|
390 |
|
|
{
|
391 |
|
|
int[][] indices =
|
392 |
|
|
{
|
393 |
|
|
{4,5,1,0},
|
394 |
|
|
{7,4,0,3},
|
395 |
|
|
{0,1,2,3},
|
396 |
|
|
{7,6,5,4},
|
397 |
|
|
{2,1,5,6},
|
398 |
|
|
{3,2,6,7}
|
399 |
|
|
};
|
400 |
|
|
|
401 |
|
|
return new ObjectShape(getVertices(variant), indices);
|
402 |
|
|
}
|
403 |
|
|
if( variant<numVariants-1 )
|
404 |
|
|
{
|
405 |
|
|
boolean left = (variant%2)==1;
|
406 |
|
|
|
407 |
|
|
int[][] indices =
|
408 |
|
|
{
|
409 |
|
|
{4,5,1,0},
|
410 |
|
|
{7,4,0,3},
|
411 |
|
|
{3,2,6,7},
|
412 |
|
|
{2,1,5,6},
|
413 |
|
|
{0,1,2,3},
|
414 |
|
|
{7,6,5,4}
|
415 |
|
|
};
|
416 |
|
|
|
417 |
|
|
if( !left )
|
418 |
|
|
{
|
419 |
|
|
int tmp, len = indices.length;
|
420 |
|
|
|
421 |
|
|
for(int i=0; i<len; i++)
|
422 |
|
|
{
|
423 |
|
|
tmp = indices[i][0];
|
424 |
|
|
indices[i][0] = indices[i][3];
|
425 |
|
|
indices[i][3] = tmp;
|
426 |
|
|
tmp = indices[i][1];
|
427 |
|
|
indices[i][1] = indices[i][2];
|
428 |
|
|
indices[i][2] = tmp;
|
429 |
|
|
}
|
430 |
|
|
}
|
431 |
29b82486
|
Leszek Koltunski
|
|
432 |
84a17011
|
Leszek Koltunski
|
return new ObjectShape(getVertices(variant), indices);
|
433 |
|
|
}
|
434 |
|
|
else
|
435 |
|
|
{
|
436 |
4e9f2df5
|
Leszek Koltunski
|
int[][] indices =
|
437 |
29b82486
|
Leszek Koltunski
|
{
|
438 |
|
|
{4,5,1,0},
|
439 |
|
|
{7,4,0,3},
|
440 |
|
|
{0,1,2,3},
|
441 |
846b69f3
|
Leszek Koltunski
|
{3,2,6,7},
|
442 |
|
|
{2,1,5,6},
|
443 |
|
|
{7,6,5,4}
|
444 |
29b82486
|
Leszek Koltunski
|
};
|
445 |
|
|
|
446 |
84a17011
|
Leszek Koltunski
|
return new ObjectShape(getVertices(variant), indices);
|
447 |
3ee1d662
|
Leszek Koltunski
|
}
|
448 |
|
|
}
|
449 |
|
|
|
450 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
451 |
|
|
|
452 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
453 |
|
|
{
|
454 |
|
|
int[] numLayers = getNumLayers();
|
455 |
|
|
int numVariants = getNumCubitVariants(numLayers);
|
456 |
|
|
int numL = numLayers[0];
|
457 |
|
|
boolean small = numL<=3;
|
458 |
|
|
|
459 |
|
|
if( variant==0 && !small )
|
460 |
|
|
{
|
461 |
3bf19410
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
462 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { {h1,34,0.3f,0.2f, 3, 0, 0}, {0.001f,34,0.0f,0.0f, 2, 0, 0} };
|
463 |
|
|
int[] indices = { 0,0,0,1,1,1};
|
464 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
465 |
3ee1d662
|
Leszek Koltunski
|
}
|
466 |
|
|
if( variant<numVariants-1 )
|
467 |
|
|
{
|
468 |
|
|
int E = small ? 1 : 0;
|
469 |
|
|
int N0 = small ? 4 : 3;
|
470 |
|
|
int N1 = small ? 3 : 2;
|
471 |
3bf19410
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
472 |
29b82486
|
Leszek Koltunski
|
|
473 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { {h1,34,0.2f,0.2f,N0,E,E}, {0.001f,34,0.0f,0.0f,N1,0,0} };
|
474 |
|
|
int[] indices = { 0,0,1,1,1,1};
|
475 |
3ee1d662
|
Leszek Koltunski
|
|
476 |
84a17011
|
Leszek Koltunski
|
return new ObjectFaceShape(bands,indices,null);
|
477 |
3ee1d662
|
Leszek Koltunski
|
}
|
478 |
|
|
else
|
479 |
|
|
{
|
480 |
|
|
int N = small ? 4 : 3;
|
481 |
|
|
int E = small ? 1 : 0;
|
482 |
3bf19410
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
483 |
|
|
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
484 |
29b82486
|
Leszek Koltunski
|
|
485 |
84a17011
|
Leszek Koltunski
|
float[][] bands = { {h1,17,0.3f,0.2f,N,E,E},{h2,17,0.3f,0.2f,N,E,E} };
|
486 |
|
|
int[] indices = { 0,0,0,1,1,1};
|
487 |
|
|
|
488 |
|
|
return new ObjectFaceShape(bands,indices,null);
|
489 |
|
|
}
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
493 |
|
|
|
494 |
|
|
public ObjectVertexEffects getVertexEffects(int variant)
|
495 |
|
|
{
|
496 |
|
|
int[] numLayers = getNumLayers();
|
497 |
|
|
int numVariants = getNumCubitVariants(numLayers);
|
498 |
|
|
int numL = numLayers[0];
|
499 |
|
|
boolean small = numL<=3;
|
500 |
29b82486
|
Leszek Koltunski
|
|
501 |
84a17011
|
Leszek Koltunski
|
if( variant==0 && !small )
|
502 |
|
|
{
|
503 |
|
|
float A = (2*SQ3/3)*SIN54;
|
504 |
|
|
float B = 0.4f;
|
505 |
ba8dbe0e
|
Leszek Koltunski
|
float[][] corners = { {0.06f,0.15f} };
|
506 |
84a17011
|
Leszek Koltunski
|
int[] indices = { 0,-1,-1,-1,-1,-1,-1,-1 };
|
507 |
|
|
float[][] centers = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
|
508 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
509 |
|
|
}
|
510 |
|
|
if( variant<numVariants-1 )
|
511 |
|
|
{
|
512 |
|
|
int type = variant-1;
|
513 |
|
|
float tmpVal= numL/(numL-1.0f);
|
514 |
|
|
float height= tmpVal*COS18;
|
515 |
|
|
float width = tmpVal + (type/2)*tmpVal*SIN18;
|
516 |
|
|
float Z = height*COS_HALFD;
|
517 |
ba8dbe0e
|
Leszek Koltunski
|
float[][] corners = { {0.02f,0.15f} };
|
518 |
84a17011
|
Leszek Koltunski
|
int[] indices = { 0,-1,-1,-1, 0,-1,-1,-1 };
|
519 |
|
|
float[][] centers = { {0.0f, -width/2, -2*Z} };
|
520 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
521 |
|
|
}
|
522 |
|
|
else
|
523 |
|
|
{
|
524 |
|
|
float A = (2*SQ3/3)*SIN54;
|
525 |
|
|
float B = 0.4f;
|
526 |
ba8dbe0e
|
Leszek Koltunski
|
float[][] corners = { {0.10f,0.30f},{0.05f,0.15f} };
|
527 |
|
|
int[] cornerIndices = { 0, 1,-1, 1, 1,-1,-1,-1 };
|
528 |
84a17011
|
Leszek Koltunski
|
float[][] centers = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
|
529 |
ba8dbe0e
|
Leszek Koltunski
|
int[] centerIndices = { 0, 0,-1, 0, 0,-1,-1,-1 };
|
530 |
|
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
531 |
29b82486
|
Leszek Koltunski
|
}
|
532 |
|
|
}
|
533 |
|
|
|
534 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
535 |
|
|
|
536 |
e30c522a
|
Leszek Koltunski
|
public int getNumCubitVariants(int[] numLayers)
|
537 |
29b82486
|
Leszek Koltunski
|
{
|
538 |
a57e6870
|
Leszek Koltunski
|
switch(numLayers[0])
|
539 |
61aa85e4
|
Leszek Koltunski
|
{
|
540 |
|
|
case 3: return 1;
|
541 |
|
|
case 5: return 4;
|
542 |
|
|
}
|
543 |
29b82486
|
Leszek Koltunski
|
|
544 |
61aa85e4
|
Leszek Koltunski
|
return 1;
|
545 |
29b82486
|
Leszek Koltunski
|
}
|
546 |
|
|
|
547 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
548 |
|
|
|
549 |
e30c522a
|
Leszek Koltunski
|
public int getCubitVariant(int cubit, int[] numLayers)
|
550 |
29b82486
|
Leszek Koltunski
|
{
|
551 |
a57e6870
|
Leszek Koltunski
|
int numL = numLayers[0];
|
552 |
|
|
int numCubitsPerCorner = numCubitsPerCorner(numL);
|
553 |
29b82486
|
Leszek Koltunski
|
|
554 |
|
|
if( cubit<NUM_CORNERS*numCubitsPerCorner ) return 0;
|
555 |
|
|
|
556 |
a57e6870
|
Leszek Koltunski
|
int numCubitsPerEdge = numCubitsPerEdge(numL);
|
557 |
29b82486
|
Leszek Koltunski
|
|
558 |
|
|
if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
|
559 |
|
|
{
|
560 |
|
|
int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
|
561 |
|
|
return type+1;
|
562 |
|
|
}
|
563 |
|
|
|
564 |
61aa85e4
|
Leszek Koltunski
|
return getNumCubitVariants(numLayers)-1;
|
565 |
29b82486
|
Leszek Koltunski
|
}
|
566 |
|
|
|
567 |
3d766df3
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
568 |
|
|
|
569 |
d53fb890
|
Leszek Koltunski
|
public float getStickerRadius()
|
570 |
3d766df3
|
Leszek Koltunski
|
{
|
571 |
ec42a6fe
|
Leszek Koltunski
|
return 0.18f;
|
572 |
3d766df3
|
Leszek Koltunski
|
}
|
573 |
|
|
|
574 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
575 |
a75ae1ee
|
Leszek Koltunski
|
|
576 |
d53fb890
|
Leszek Koltunski
|
public float getStickerStroke()
|
577 |
3d766df3
|
Leszek Koltunski
|
{
|
578 |
|
|
float stroke = 0.25f;
|
579 |
|
|
|
580 |
3bf19410
|
Leszek Koltunski
|
if( isInIconMode() )
|
581 |
a75ae1ee
|
Leszek Koltunski
|
{
|
582 |
3d766df3
|
Leszek Koltunski
|
int[] numLayers = getNumLayers();
|
583 |
|
|
if( numLayers[0]>3 ) stroke*=1.5f;
|
584 |
29b82486
|
Leszek Koltunski
|
}
|
585 |
3d766df3
|
Leszek Koltunski
|
|
586 |
|
|
return stroke;
|
587 |
29b82486
|
Leszek Koltunski
|
}
|
588 |
|
|
|
589 |
00f4980d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
590 |
|
|
|
591 |
d53fb890
|
Leszek Koltunski
|
public float[][] getStickerAngles()
|
592 |
00f4980d
|
Leszek Koltunski
|
{
|
593 |
|
|
return null;
|
594 |
|
|
}
|
595 |
|
|
|
596 |
61aa85e4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
597 |
|
|
|
598 |
5f54927b
|
Leszek Koltunski
|
public String getShortName()
|
599 |
61aa85e4
|
Leszek Koltunski
|
{
|
600 |
5f54927b
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
601 |
|
|
{
|
602 |
|
|
case 3: return ObjectType.KILO_3.name();
|
603 |
|
|
case 5: return ObjectType.KILO_5.name();
|
604 |
|
|
}
|
605 |
|
|
|
606 |
|
|
return ObjectType.KILO_3.name();
|
607 |
|
|
}
|
608 |
|
|
|
609 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
610 |
|
|
|
611 |
1d581993
|
Leszek Koltunski
|
public ObjectSignature getSignature()
|
612 |
5f54927b
|
Leszek Koltunski
|
{
|
613 |
|
|
switch(getNumLayers()[0])
|
614 |
61aa85e4
|
Leszek Koltunski
|
{
|
615 |
2dffaf22
|
Leszek Koltunski
|
case 3: return new ObjectSignature(ObjectSignatures.KILO_3);
|
616 |
|
|
case 5: return new ObjectSignature(ObjectSignatures.KILO_5);
|
617 |
61aa85e4
|
Leszek Koltunski
|
}
|
618 |
|
|
|
619 |
1d581993
|
Leszek Koltunski
|
return null;
|
620 |
61aa85e4
|
Leszek Koltunski
|
}
|
621 |
|
|
|
622 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
623 |
|
|
|
624 |
e26eb4e7
|
Leszek Koltunski
|
public String getObjectName()
|
625 |
29b82486
|
Leszek Koltunski
|
{
|
626 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
627 |
|
|
{
|
628 |
|
|
case 3: return "Kilominx";
|
629 |
|
|
case 5: return "Master Kilominx";
|
630 |
|
|
}
|
631 |
1d581993
|
Leszek Koltunski
|
return null;
|
632 |
29b82486
|
Leszek Koltunski
|
}
|
633 |
|
|
|
634 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
635 |
|
|
|
636 |
e26eb4e7
|
Leszek Koltunski
|
public String getInventor()
|
637 |
29b82486
|
Leszek Koltunski
|
{
|
638 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
639 |
|
|
{
|
640 |
|
|
case 3: return "Thomas de Bruin";
|
641 |
|
|
case 5: return "David Gugl";
|
642 |
|
|
}
|
643 |
|
|
return "Thomas de Bruin";
|
644 |
29b82486
|
Leszek Koltunski
|
}
|
645 |
|
|
|
646 |
59c20632
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
647 |
|
|
|
648 |
e26eb4e7
|
Leszek Koltunski
|
public int getYearOfInvention()
|
649 |
59c20632
|
Leszek Koltunski
|
{
|
650 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
651 |
59c20632
|
Leszek Koltunski
|
{
|
652 |
|
|
case 3: return 2008;
|
653 |
|
|
case 5: return 2010;
|
654 |
|
|
}
|
655 |
|
|
return 2008;
|
656 |
|
|
}
|
657 |
|
|
|
658 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
659 |
|
|
|
660 |
e26eb4e7
|
Leszek Koltunski
|
public int getComplexity()
|
661 |
29b82486
|
Leszek Koltunski
|
{
|
662 |
e26eb4e7
|
Leszek Koltunski
|
switch(getNumLayers()[0])
|
663 |
|
|
{
|
664 |
b4223a92
|
Leszek Koltunski
|
case 3: return 2;
|
665 |
|
|
case 5: return 3;
|
666 |
e26eb4e7
|
Leszek Koltunski
|
}
|
667 |
a57e6870
|
Leszek Koltunski
|
return 8;
|
668 |
29b82486
|
Leszek Koltunski
|
}
|
669 |
052e0362
|
Leszek Koltunski
|
|
670 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
671 |
|
|
|
672 |
|
|
public String[][] getTutorials()
|
673 |
|
|
{
|
674 |
|
|
int[] numLayers = getNumLayers();
|
675 |
|
|
|
676 |
|
|
switch(numLayers[0])
|
677 |
|
|
{
|
678 |
|
|
case 3: return new String[][] {
|
679 |
|
|
{"gb","grgGgUSxiQg","How to Solve the Kilominx","Z3"},
|
680 |
|
|
{"es","g6WMYjkCLok","Resolver Kilominx","Cuby"},
|
681 |
|
|
{"ru","gjaknjuZXPs","Киломинкс как собрать","CUBES WORLD"},
|
682 |
|
|
{"fr","F7z6LztN-7A","Résoudre le Kilominx","Twins Cuber"},
|
683 |
|
|
{"de","fcmJdpLfZwk","Megaminx 2x2 lösen","JamesKnopf"},
|
684 |
|
|
{"pl","tdWh8f8qpq4","Kilominx TUTORIAL PL","MrUK"},
|
685 |
|
|
{"kr","8-X4GhQnE5I","2X2 킬로밍크스 TUTORIAL","큐브놀이터"},
|
686 |
a399e91b
|
Leszek Koltunski
|
{"vn","eW7RLayPPmA","Tutorial N.11 - Kilominx","Duy Thích Rubik"},
|
687 |
052e0362
|
Leszek Koltunski
|
};
|
688 |
|
|
case 5: return new String[][] {
|
689 |
|
|
{"gb","VAnzC2SYVc4","How To Solve A Master Kilominx","Grizz Media"},
|
690 |
|
|
{"es","ozINTg-61Fs","Tutorial Master Kilominx","RubikArt"},
|
691 |
|
|
{"ru","0aemQayCZRc","Как собрать Мастер Киломинкс ч.1","Артем Мартиросов"},
|
692 |
|
|
{"ru","ohOUFTx-oQI","Как собрать Мастер Киломинкс ч.2","Артем Мартиросов"},
|
693 |
|
|
{"ru","YRXRdT2jCn8","Как собрать Мастер Киломинкс ч.3","Артем Мартиросов"},
|
694 |
|
|
{"fr","usMiWt44aqo","Résolution du Master Kilominx","Asthalis"},
|
695 |
|
|
{"pl","rdln0IG86_s","Master Kilominx TUTORIAL PL","MrUK"},
|
696 |
|
|
{"br","0nmaZf2-44M","Como resolver o Master Kilominx 1/3","Rafael Cinoto"},
|
697 |
|
|
{"br","SkR6RybAKHc","Como resolver o Master Kilominx 2/3","Rafael Cinoto"},
|
698 |
|
|
{"br","5C7J7Cb4a7Q","Como resolver o Master Kilominx 3/3","Rafael Cinoto"},
|
699 |
|
|
{"kr","dvy-GxCjm5c","마스터 킬로밍크스 배우기 1","vincentcube"},
|
700 |
|
|
{"kr","Jm0B12vNxsE","마스터 킬로밍크스 배우기 2","vincentcube"},
|
701 |
|
|
{"kr","H1I18FVpr6g","마스터 킬로밍크스 배우기 3","vincentcube"},
|
702 |
|
|
};
|
703 |
|
|
}
|
704 |
|
|
return null;
|
705 |
|
|
}
|
706 |
29b82486
|
Leszek Koltunski
|
}
|