1 |
e7569064
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2023 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// 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 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.objectlib.objects;
|
11 |
|
|
|
12 |
f925d455
|
Leszek Koltunski
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
|
13 |
|
|
|
14 |
|
|
import org.distorted.library.effect.EffectName;
|
15 |
e7569064
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
16 |
|
|
import org.distorted.library.type.Static4D;
|
17 |
f925d455
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
18 |
|
|
import org.distorted.objectlib.helpers.ObjectShape;
|
19 |
e7569064
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectSignature;
|
20 |
f925d455
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
21 |
e7569064
|
Leszek Koltunski
|
import org.distorted.objectlib.main.InitData;
|
22 |
|
|
import org.distorted.objectlib.main.ObjectType;
|
23 |
|
|
|
24 |
|
|
import java.io.InputStream;
|
25 |
|
|
|
26 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
27 |
|
|
|
28 |
|
|
public class TwistyCamouflage extends TwistyBandagedAbstract
|
29 |
|
|
{
|
30 |
|
|
public static final float[][] CAM_333 = new float[][]
|
31 |
|
|
{
|
32 |
f925d455
|
Leszek Koltunski
|
getCenters( -1.0f, 1.0f, 1.0f, 2, 2, 2),
|
33 |
|
|
|
34 |
|
|
getCenters( 0.5f, 1.0f, 1.0f, 1, 2, 2),
|
35 |
|
|
getCenters( 1.5f, 1.0f, 1.0f, 1, 2, 2),
|
36 |
|
|
getCenters( -1.0f,-0.5f, 1.0f, 2, 1, 2),
|
37 |
|
|
getCenters( -1.0f,-1.5f, 1.0f, 2, 1, 2),
|
38 |
|
|
getCenters( -1.0f, 1.0f,-0.5f, 2, 2, 1),
|
39 |
|
|
getCenters( -1.0f, 1.0f,-1.5f, 2, 2, 1),
|
40 |
|
|
|
41 |
|
|
getCenters( -1.0f,-1.5f,-0.5f, 2, 1, 1),
|
42 |
|
|
getCenters( -1.0f,-1.5f,-1.5f, 2, 1, 1),
|
43 |
|
|
getCenters( -1.0f,-0.5f,-0.5f, 2, 1, 1),
|
44 |
|
|
getCenters( -1.0f,-0.5f,-1.5f, 2, 1, 1),
|
45 |
|
|
getCenters( 0.5f, 1.0f,-1.5f, 1, 2, 1),
|
46 |
|
|
getCenters( 1.5f, 1.0f,-1.5f, 1, 2, 1),
|
47 |
|
|
getCenters( 0.5f, 1.0f,-0.5f, 1, 2, 1),
|
48 |
|
|
getCenters( 1.5f, 1.0f,-0.5f, 1, 2, 1),
|
49 |
|
|
getCenters( 0.5f,-0.5f, 1.0f, 1, 1, 2),
|
50 |
|
|
getCenters( 1.5f,-0.5f, 1.0f, 1, 1, 2),
|
51 |
|
|
getCenters( 0.5f,-1.5f, 1.0f, 1, 1, 2),
|
52 |
|
|
getCenters( 1.5f,-1.5f, 1.0f, 1, 1, 2),
|
53 |
|
|
|
54 |
|
|
getCenters( 0.5f,-0.5f,-1.5f, 1, 1, 1),
|
55 |
|
|
getCenters( 1.5f,-0.5f,-1.5f, 1, 1, 1),
|
56 |
|
|
getCenters( 0.5f,-1.5f,-1.5f, 1, 1, 1),
|
57 |
|
|
getCenters( 1.5f,-1.5f,-1.5f, 1, 1, 1),
|
58 |
|
|
getCenters( 0.5f,-1.5f,-0.5f, 1, 1, 1),
|
59 |
|
|
getCenters( 1.5f,-0.5f,-0.5f, 1, 1, 1),
|
60 |
|
|
getCenters( 1.5f,-1.5f,-0.5f, 1, 1, 1),
|
61 |
|
|
};
|
62 |
|
|
|
63 |
|
|
private static final int[][] DIMS = new int[][]
|
64 |
|
|
{
|
65 |
|
|
{2,2,2},
|
66 |
|
|
{1,2,2},
|
67 |
|
|
{2,1,2},
|
68 |
|
|
{2,2,1},
|
69 |
|
|
{2,1,1},
|
70 |
|
|
{1,2,1},
|
71 |
|
|
{1,1,2},
|
72 |
|
|
{1,1,1},
|
73 |
e7569064
|
Leszek Koltunski
|
};
|
74 |
|
|
|
75 |
f925d455
|
Leszek Koltunski
|
private static final float[][] OFFSETS = new float[][]
|
76 |
|
|
{
|
77 |
|
|
{ 0.0f, 0.0f, 0.0f},
|
78 |
|
|
{ 0.5f, 0.0f, 0.0f},
|
79 |
|
|
{-0.5f, 0.0f, 0.0f},
|
80 |
|
|
{ 0.0f, 0.5f, 0.0f},
|
81 |
|
|
{ 0.0f,-0.5f, 0.0f},
|
82 |
|
|
{ 0.0f, 0.0f, 0.5f},
|
83 |
|
|
{ 0.0f, 0.0f,-0.5f},
|
84 |
|
|
{ 0.0f,-0.5f,-0.5f},
|
85 |
|
|
{ 0.5f, 0.0f,-0.5f},
|
86 |
|
|
{ 0.5f,-0.5f, 0.0f},
|
87 |
|
|
{ 0.5f,-0.5f,-0.5f},
|
88 |
|
|
};
|
89 |
|
|
|
90 |
|
|
private int[] mDimsIndices, mOffsIndices;
|
91 |
|
|
|
92 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
93 |
|
|
|
94 |
|
|
private static float[] getCenters( float x, float y, float z, int xd, int yd, int zd )
|
95 |
|
|
{
|
96 |
|
|
float XS = 0.5f*(1-xd) + x;
|
97 |
|
|
float YS = 0.5f*(1-yd) + y;
|
98 |
|
|
float ZS = 0.5f*(1-zd) + z;
|
99 |
|
|
|
100 |
|
|
int index=0;
|
101 |
|
|
float[] result = new float[3*xd*yd*zd];
|
102 |
|
|
|
103 |
|
|
for(int i=0; i<xd; i++)
|
104 |
|
|
for(int j=0; j<yd; j++)
|
105 |
|
|
for(int k=0; k<zd; k++)
|
106 |
|
|
{
|
107 |
|
|
result[3*index ] = XS+i;
|
108 |
|
|
result[3*index+1] = YS+j;
|
109 |
|
|
result[3*index+2] = ZS+k;
|
110 |
|
|
index++;
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
return result;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
e7569064
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117 |
|
|
|
118 |
|
|
public TwistyCamouflage(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
|
119 |
|
|
{
|
120 |
|
|
super(data, meshState, iconMode, (data.getNumLayers()[0]+data.getNumLayers()[1]+data.getNumLayers()[2])/3.0f, quat, move, scale, stream);
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
|
125 |
f925d455
|
Leszek Koltunski
|
private int getDimsIndex(int variant)
|
126 |
e7569064
|
Leszek Koltunski
|
{
|
127 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
128 |
|
|
|
129 |
|
|
if( mPosition==CAM_333 )
|
130 |
|
|
{
|
131 |
f925d455
|
Leszek Koltunski
|
if( mDimsIndices==null ) mDimsIndices = new int[]
|
132 |
|
|
{ 0,
|
133 |
|
|
1,0,2,0,3,0,
|
134 |
|
|
3,0,4,2,1,0,5,3,6,2,1,0,
|
135 |
|
|
6,2,1,0,5,4,3 };
|
136 |
e7569064
|
Leszek Koltunski
|
}
|
137 |
|
|
|
138 |
f925d455
|
Leszek Koltunski
|
return mDimsIndices[variant];
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142 |
|
|
|
143 |
|
|
private int getOffsetsIndex(int variant)
|
144 |
|
|
{
|
145 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
146 |
|
|
|
147 |
|
|
if( mPosition==CAM_333 )
|
148 |
|
|
{
|
149 |
|
|
if( mOffsIndices==null ) mOffsIndices = new int[]
|
150 |
|
|
{ 0,
|
151 |
|
|
0,1,0,4,0,6,
|
152 |
|
|
4,7,0,6,6,8,0,1,0,1,4,9,
|
153 |
|
|
6,8,7,10,4,1,9 };
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
return mOffsIndices[variant];
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
160 |
|
|
|
161 |
|
|
private float[][] getVertices(int variant)
|
162 |
|
|
{
|
163 |
|
|
int indexD = getDimsIndex(variant);
|
164 |
|
|
|
165 |
|
|
int X=DIMS[indexD][0];
|
166 |
|
|
int Y=DIMS[indexD][1];
|
167 |
|
|
int Z=DIMS[indexD][2];
|
168 |
|
|
|
169 |
|
|
int indexO = getOffsetsIndex(variant);
|
170 |
|
|
|
171 |
|
|
float XF = OFFSETS[indexO][0];
|
172 |
|
|
float YF = OFFSETS[indexO][1];
|
173 |
|
|
float ZF = OFFSETS[indexO][2];
|
174 |
|
|
|
175 |
|
|
return new float[][]
|
176 |
|
|
{
|
177 |
|
|
{ 0.5f*X +XF, 0.5f*Y +YF, 0.5f*Z +ZF},
|
178 |
|
|
{ 0.5f*X +XF, 0.5f*Y +YF,-0.5f*Z +ZF},
|
179 |
|
|
{ 0.5f*X +XF,-0.5f*Y +YF, 0.5f*Z +ZF},
|
180 |
|
|
{ 0.5f*X +XF,-0.5f*Y +YF,-0.5f*Z +ZF},
|
181 |
|
|
{-0.5f*X +XF, 0.5f*Y +YF, 0.5f*Z +ZF},
|
182 |
|
|
{-0.5f*X +XF, 0.5f*Y +YF,-0.5f*Z +ZF},
|
183 |
|
|
{-0.5f*X +XF,-0.5f*Y +YF, 0.5f*Z +ZF},
|
184 |
|
|
{-0.5f*X +XF,-0.5f*Y +YF,-0.5f*Z +ZF}
|
185 |
|
|
};
|
186 |
e7569064
|
Leszek Koltunski
|
}
|
187 |
|
|
|
188 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
189 |
|
|
// PUBLIC API
|
190 |
|
|
|
191 |
f925d455
|
Leszek Koltunski
|
public int getTouchControlType()
|
192 |
|
|
{
|
193 |
|
|
return TC_CHANGING_SHAPEMOD;
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
197 |
|
|
|
198 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
199 |
|
|
{
|
200 |
|
|
return mObjectQuats[0];
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
204 |
|
|
|
205 |
|
|
public ObjectShape getObjectShape(int variant)
|
206 |
|
|
{
|
207 |
|
|
int[][] indices =
|
208 |
|
|
{
|
209 |
|
|
{2,3,1,0},
|
210 |
|
|
{7,6,4,5},
|
211 |
|
|
{4,0,1,5},
|
212 |
|
|
{7,3,2,6},
|
213 |
|
|
{6,2,0,4},
|
214 |
|
|
{3,7,5,1},
|
215 |
|
|
};
|
216 |
|
|
|
217 |
|
|
return new ObjectShape( getVertices(variant), indices);
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
221 |
|
|
|
222 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
223 |
|
|
{
|
224 |
|
|
int index = getDimsIndex(variant);
|
225 |
|
|
|
226 |
|
|
int X = DIMS[index][0];
|
227 |
|
|
int Y = DIMS[index][1];
|
228 |
|
|
int Z = DIMS[index][2];
|
229 |
|
|
|
230 |
|
|
float height = isInIconMode() ? 0.001f : 0.03f;
|
231 |
|
|
int[] bandIndices= { 0,0,1,1,2,2 };
|
232 |
|
|
|
233 |
|
|
int maxXY = Math.max(X,Y);
|
234 |
|
|
int maxXZ = Math.max(X,Z);
|
235 |
|
|
int maxYZ = Math.max(Y,Z);
|
236 |
|
|
|
237 |
|
|
int angle = 45;
|
238 |
|
|
float R = 0.10f;
|
239 |
|
|
float S = 0.25f;
|
240 |
|
|
float N = 4;
|
241 |
|
|
|
242 |
|
|
float[][] bands =
|
243 |
|
|
{
|
244 |
|
|
{height/maxYZ,angle,R,S,N,0,0},
|
245 |
|
|
{height/maxXZ,angle,R,S,N,0,0},
|
246 |
|
|
{height/maxXY,angle,R,S,N,0,0}
|
247 |
|
|
};
|
248 |
|
|
|
249 |
|
|
return new ObjectFaceShape(bands,bandIndices,null);
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
253 |
|
|
|
254 |
|
|
public ObjectVertexEffects getVertexEffects(int variant)
|
255 |
|
|
{
|
256 |
|
|
boolean round = false;
|
257 |
|
|
float[][] vertices = getVertices(variant);
|
258 |
|
|
float A = -0.03f;
|
259 |
|
|
|
260 |
|
|
float[][] variables =
|
261 |
|
|
{
|
262 |
|
|
{ 0, A, A, A, 1 },
|
263 |
|
|
{ 0, A, A,-A, 1 },
|
264 |
|
|
{ 0, A,-A, A, 1 },
|
265 |
|
|
{ 0, A,-A,-A, 1 },
|
266 |
|
|
{ 0,-A, A, A, 1 },
|
267 |
|
|
{ 0,-A, A,-A, 1 },
|
268 |
|
|
{ 0,-A,-A, A, 1 },
|
269 |
|
|
{ 0,-A,-A,-A, 1 },
|
270 |
|
|
};
|
271 |
|
|
|
272 |
|
|
String name = EffectName.DEFORM.name();
|
273 |
|
|
float[] reg = {0,0,0,0.10f};
|
274 |
|
|
|
275 |
|
|
String[] names = {name,name,name,name,name,name,name,name};
|
276 |
|
|
float[][] regions = {reg,reg,reg,reg,reg,reg,reg,reg};
|
277 |
|
|
boolean[] uses = {round,round,round,round,round,round,round,round};
|
278 |
|
|
|
279 |
|
|
return new ObjectVertexEffects(names,variables,vertices,regions,uses);
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
283 |
|
|
|
284 |
|
|
public int getCubitVariant(int cubit, int[] numLayers)
|
285 |
|
|
{
|
286 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
287 |
|
|
|
288 |
|
|
if( mPosition==CAM_333 )
|
289 |
|
|
{
|
290 |
|
|
return cubit;
|
291 |
|
|
}
|
292 |
|
|
|
293 |
|
|
return 0;
|
294 |
|
|
}
|
295 |
|
|
|
296 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
297 |
|
|
|
298 |
|
|
public int getNumCubitVariants(int[] numLayers)
|
299 |
|
|
{
|
300 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
301 |
|
|
|
302 |
|
|
if( mPosition==CAM_333 ) return 26;
|
303 |
|
|
|
304 |
|
|
return 0;
|
305 |
|
|
}
|
306 |
|
|
|
307 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
308 |
|
|
|
309 |
|
|
public float getStickerRadius()
|
310 |
|
|
{
|
311 |
|
|
return 0.18f;
|
312 |
|
|
}
|
313 |
|
|
|
314 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
315 |
|
|
|
316 |
|
|
public float getStickerStroke()
|
317 |
|
|
{
|
318 |
|
|
return isInIconMode() ? 0.25f : 0.15f;
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
322 |
|
|
|
323 |
e7569064
|
Leszek Koltunski
|
public String getShortName()
|
324 |
|
|
{
|
325 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
326 |
|
|
|
327 |
|
|
if( mPosition==CAM_333 ) return ObjectType.CA_333.name();
|
328 |
|
|
|
329 |
|
|
return null;
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
333 |
|
|
|
334 |
|
|
public ObjectSignature getSignature()
|
335 |
|
|
{
|
336 |
|
|
if( mSignature==null )
|
337 |
|
|
{
|
338 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
339 |
|
|
if( mPosition==CAM_333 ) mSignature = new ObjectSignature(ObjectType.CA_333);
|
340 |
|
|
}
|
341 |
|
|
return mSignature;
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
345 |
|
|
|
346 |
|
|
public String getObjectName()
|
347 |
|
|
{
|
348 |
|
|
int[] nL = getNumLayers();
|
349 |
|
|
return "Camouflage "+nL[0]+"x"+nL[1]+"x"+nL[2];
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
353 |
|
|
|
354 |
|
|
public String getInventor()
|
355 |
|
|
{
|
356 |
|
|
return "Guan Yang";
|
357 |
|
|
}
|
358 |
|
|
|
359 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
360 |
|
|
|
361 |
|
|
public int getYearOfInvention()
|
362 |
|
|
{
|
363 |
|
|
return 2013;
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
367 |
|
|
|
368 |
|
|
public int getComplexity()
|
369 |
|
|
{
|
370 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
371 |
|
|
|
372 |
|
|
if( mPosition==CAM_333 ) return 3;
|
373 |
|
|
|
374 |
|
|
return 0;
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
378 |
|
|
|
379 |
|
|
public String[][] getTutorials()
|
380 |
|
|
{
|
381 |
|
|
if( mPosition==null ) mPosition = getInitData().getPos();
|
382 |
|
|
|
383 |
|
|
if( mPosition==CAM_333 )
|
384 |
|
|
{
|
385 |
|
|
return new String[][]{
|
386 |
|
|
{"gb","f9zmpCfg25k","3x3x3 Camouflage Part 1","Superantoniovivaldi"},
|
387 |
|
|
{"gb","O8pGyi5Juxk","3x3x3 Camouflage Part 2","Superantoniovivaldi"},
|
388 |
|
|
{"es","V1RPBIzEwp4","Tutorial 3x3 Camouflage","Manu rubiks"},
|
389 |
|
|
{"ru","DRGNOSw5pPc","Как собрать 3х3х3 camouflage","Илья Топор-Гилка"},
|
390 |
|
|
{"fr","9BfI1Fcbcl8","Résolution du Camouflage Cube","Skieur Cubb"},
|
391 |
|
|
{"pl","uEVvR2jDdI0","Camouflage 3x3x3 Tutorial","MrUK"},
|
392 |
|
|
};
|
393 |
|
|
}
|
394 |
|
|
|
395 |
|
|
return null;
|
396 |
|
|
}
|
397 |
|
|
}
|