|
1 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
2 |
// Copyright 2022 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.objectlib.objects;
|
|
21 |
|
|
22 |
import org.distorted.library.type.Static3D;
|
|
23 |
import org.distorted.library.type.Static4D;
|
|
24 |
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
|
25 |
import org.distorted.objectlib.helpers.ObjectShape;
|
|
26 |
import org.distorted.objectlib.main.ObjectType;
|
|
27 |
|
|
28 |
import java.io.InputStream;
|
|
29 |
|
|
30 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
31 |
|
|
32 |
public class TwistyStarminx extends TwistyMinx
|
|
33 |
{
|
|
34 |
private static final float A = (SQ5+5)/10;
|
|
35 |
|
|
36 |
private float[][] mCuts;
|
|
37 |
private float[][] mPosition;
|
|
38 |
private int[] mQuatIndex;
|
|
39 |
|
|
40 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
41 |
|
|
42 |
public TwistyStarminx(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
|
43 |
{
|
|
44 |
super(numL, meshState, iconMode, quat, move, scale, stream);
|
|
45 |
}
|
|
46 |
|
|
47 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
48 |
|
|
49 |
public float[][] getCubitPositions(int[] numLayers)
|
|
50 |
{
|
|
51 |
if( mPosition==null )
|
|
52 |
{
|
|
53 |
if( mEdgeMap==null ) initializeEdgeMap();
|
|
54 |
if( mCenterCoords==null ) initializeCenterCoords();
|
|
55 |
|
|
56 |
mPosition = new float[NUM_EDGES][3];
|
|
57 |
|
|
58 |
for(int edge=0; edge<NUM_EDGES; edge++)
|
|
59 |
{
|
|
60 |
float[] c1 = mCorners[ mEdgeMap[edge][0] ];
|
|
61 |
float[] c2 = mCorners[ mEdgeMap[edge][1] ];
|
|
62 |
|
|
63 |
mPosition[edge][0] = (c1[0]+c2[0])/2;
|
|
64 |
mPosition[edge][1] = (c1[1]+c2[1])/2;
|
|
65 |
mPosition[edge][2] = (c1[2]+c2[2])/2;
|
|
66 |
}
|
|
67 |
}
|
|
68 |
|
|
69 |
return mPosition;
|
|
70 |
}
|
|
71 |
|
|
72 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
73 |
|
|
74 |
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
|
75 |
{
|
|
76 |
if( mQuatIndex==null ) mQuatIndex = new int[] { //35,55,38,48,41,42,58,57, 0,46,29,59,
|
|
77 |
|
|
78 |
17,12,13,20, 0, 4,25, 5,24,16,
|
|
79 |
9,21, 1,34, 8,11,30,43,26,14,
|
|
80 |
15,45,33,28,10, 2,29, 6, 7, 3,
|
|
81 |
|
|
82 |
//0, 2,20,42,13,41,16,33, 8,51,
|
|
83 |
//1,25,12,27, 4, 3,21,28, 5, 6
|
|
84 |
};
|
|
85 |
return mObjectQuats[mQuatIndex[cubit]];
|
|
86 |
}
|
|
87 |
|
|
88 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
89 |
|
|
90 |
public ObjectShape getObjectShape(int variant)
|
|
91 |
{
|
|
92 |
if( variant==0 ) // edge
|
|
93 |
{
|
|
94 |
float B = mCenterCoords[0][2]-mCorners[0][2];
|
|
95 |
float C = A*mCorners[0][1]+(1.0f-A)*mCorners[2][1];
|
|
96 |
float D = mCenterCoords[0][0];
|
|
97 |
|
|
98 |
float[][] vertices =
|
|
99 |
{
|
|
100 |
{ 0.0f, C, 0,0f },
|
|
101 |
{ 0.0f,-C, 0,0f },
|
|
102 |
{ -D,0.0f, B },
|
|
103 |
{ +D,0.0f, B },
|
|
104 |
};
|
|
105 |
int[][] indices =
|
|
106 |
{
|
|
107 |
{1,0,2},
|
|
108 |
{0,1,3},
|
|
109 |
{2,3,1},
|
|
110 |
{3,2,0}
|
|
111 |
};
|
|
112 |
|
|
113 |
return new ObjectShape(vertices, indices);
|
|
114 |
}
|
|
115 |
|
|
116 |
return null;
|
|
117 |
}
|
|
118 |
|
|
119 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
120 |
|
|
121 |
public ObjectFaceShape getObjectFaceShape(int variant)
|
|
122 |
{
|
|
123 |
if( variant==0 )
|
|
124 |
{
|
|
125 |
float h1 = isInIconMode() ? 0.001f : 0.03f;
|
|
126 |
float h2 = isInIconMode() ? 0.001f : 0.01f;
|
|
127 |
float[][] bands = { {h1,17,0.5f,0.2f,5,1,0}, {h2, 1,0.5f,0.2f,5,1,0} };
|
|
128 |
int[] bandIndices = { 0,0,1,1 };
|
|
129 |
float[][] corners = { { 0.015f, 0.20f } };
|
|
130 |
int[] cornerIndices = { 0,0,0,0 };
|
|
131 |
float[][] centers = { { 0.0f,0.0f,-mCorners[0][2] } };
|
|
132 |
int[] centerIndices = { 0,0,0,0 };
|
|
133 |
return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
|
|
134 |
}
|
|
135 |
|
|
136 |
return null;
|
|
137 |
}
|
|
138 |
|
|
139 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
140 |
|
|
141 |
public int getNumCubitVariants(int[] numLayers)
|
|
142 |
{
|
|
143 |
return 3;
|
|
144 |
}
|
|
145 |
|
|
146 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
147 |
|
|
148 |
public int getCubitVariant(int cubit, int[] numLayers)
|
|
149 |
{
|
|
150 |
return cubit<NUM_EDGES ? 0: (cubit<NUM_CENTERS+NUM_EDGES ? 1:2);
|
|
151 |
}
|
|
152 |
|
|
153 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
154 |
|
|
155 |
public float[][] getCuts(int[] numLayers)
|
|
156 |
{
|
|
157 |
if( mCuts==null )
|
|
158 |
{
|
|
159 |
float CUT = 1.0f; // TODO
|
|
160 |
float[] cut = new float[] { -CUT,+CUT };
|
|
161 |
mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
|
|
162 |
}
|
|
163 |
|
|
164 |
return mCuts;
|
|
165 |
}
|
|
166 |
|
|
167 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
168 |
|
|
169 |
public float getStickerRadius()
|
|
170 |
{
|
|
171 |
return 0.18f;
|
|
172 |
}
|
|
173 |
|
|
174 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
175 |
|
|
176 |
public float getStickerStroke()
|
|
177 |
{
|
|
178 |
return isInIconMode() ? 0.22f : 0.15f;
|
|
179 |
}
|
|
180 |
|
|
181 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
182 |
|
|
183 |
public float[][] getStickerAngles()
|
|
184 |
{
|
|
185 |
return null;
|
|
186 |
}
|
|
187 |
|
|
188 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
189 |
// PUBLIC API
|
|
190 |
|
|
191 |
public String getShortName()
|
|
192 |
{
|
|
193 |
return ObjectType.STAR_3.name();
|
|
194 |
}
|
|
195 |
|
|
196 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
197 |
|
|
198 |
public long getSignature()
|
|
199 |
{
|
|
200 |
return ObjectType.STAR_3.ordinal();
|
|
201 |
}
|
|
202 |
|
|
203 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
204 |
|
|
205 |
public String getObjectName()
|
|
206 |
{
|
|
207 |
return "Starminx I";
|
|
208 |
}
|
|
209 |
|
|
210 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
211 |
|
|
212 |
public String getInventor()
|
|
213 |
{
|
|
214 |
return "Aleh Hladzilin";
|
|
215 |
}
|
|
216 |
|
|
217 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
218 |
|
|
219 |
public int getYearOfInvention()
|
|
220 |
{
|
|
221 |
return 2009;
|
|
222 |
}
|
|
223 |
|
|
224 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
225 |
|
|
226 |
public int getComplexity()
|
|
227 |
{
|
|
228 |
return 3;
|
|
229 |
}
|
|
230 |
|
|
231 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
232 |
|
|
233 |
public String[][] getTutorials()
|
|
234 |
{
|
|
235 |
return new String[][]{
|
|
236 |
{"gb","NqYFonhf2rw","Face Turning Starminx Tutorial","twistypuzzling"},
|
|
237 |
{"pl","7LotUfg90HI","Starminx Cube TUTORIAL PL 1/2","MrUK"},
|
|
238 |
{"pl","nH2doGM1Das","Starminx Cube TUTORIAL PL 2/2","MrUK"},
|
|
239 |
{"kr","8bIQVCKWBvw","스타밍크스 해법 1/2","듀나메스 큐브 해법연구소"},
|
|
240 |
{"kr","4WU5iJyM7jI","스타밍크스 해법 2/2","듀나메스 큐브 해법연구소"},
|
|
241 |
{"vn","QhSaboIX3Fs","Tutorial N.183 - Starminx","Duy Thích Rubik"},
|
|
242 |
};
|
|
243 |
}
|
|
244 |
}
|
Starminx I: beginnings