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.TouchControl.TC_HEXAHEDRON;
|
13 |
|
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
|
14 |
29b82486
|
Leszek Koltunski
|
|
15 |
|
|
import org.distorted.library.type.Static3D;
|
16 |
|
|
import org.distorted.library.type.Static4D;
|
17 |
|
|
|
18 |
84a17011
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
19 |
3ee1d662
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
20 |
198c5bf0
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectShape;
|
21 |
84a17011
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
22 |
cf93ea4e
|
Leszek Koltunski
|
import org.distorted.objectlib.main.InitAssets;
|
23 |
ae9d9227
|
leszek
|
import org.distorted.objectlib.metadata.Metadata;
|
24 |
b31249d6
|
Leszek Koltunski
|
import org.distorted.objectlib.shape.ShapeHexahedron;
|
25 |
4c9ca251
|
Leszek Koltunski
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
26 |
29b82486
|
Leszek Koltunski
|
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
386af988
|
Leszek Koltunski
|
abstract class TwistyDino extends ShapeHexahedron
|
30 |
29b82486
|
Leszek Koltunski
|
{
|
31 |
3e5ec1a4
|
leszek
|
public static final Static3D[] ROT_AXIS = new Static3D[]
|
32 |
29b82486
|
Leszek Koltunski
|
{
|
33 |
84a17011
|
Leszek Koltunski
|
new Static3D( SQ3/3, SQ3/3, SQ3/3),
|
34 |
37310d4f
|
Leszek Koltunski
|
new Static3D(-SQ3/3,-SQ3/3, SQ3/3),
|
35 |
|
|
new Static3D(-SQ3/3, SQ3/3,-SQ3/3),
|
36 |
|
|
new Static3D( SQ3/3,-SQ3/3,-SQ3/3),
|
37 |
29b82486
|
Leszek Koltunski
|
};
|
38 |
|
|
|
39 |
beee90ab
|
Leszek Koltunski
|
private int[][] mBasicAngle;
|
40 |
29b82486
|
Leszek Koltunski
|
private float[][] mCuts;
|
41 |
|
|
private float[][] mCenters;
|
42 |
802fe251
|
Leszek Koltunski
|
private int[] mQuatIndex;
|
43 |
9ba7f3f6
|
Leszek Koltunski
|
int[][] mEdges;
|
44 |
29b82486
|
Leszek Koltunski
|
|
45 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46 |
|
|
|
47 |
ae9d9227
|
leszek
|
TwistyDino(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
48 |
29b82486
|
Leszek Koltunski
|
{
|
49 |
ae9d9227
|
leszek
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
50 |
29b82486
|
Leszek Koltunski
|
}
|
51 |
|
|
|
52 |
a70b1e96
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
|
|
@Override
|
55 |
|
|
public float[][] returnRotationFactor()
|
56 |
|
|
{
|
57 |
|
|
float C = 1.5f;
|
58 |
|
|
float[] f = new float[] { C,C,C };
|
59 |
|
|
return new float[][] { f,f,f,f };
|
60 |
|
|
}
|
61 |
|
|
|
62 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63 |
|
|
|
64 |
7bbfc84f
|
Leszek Koltunski
|
public float[][] getCuts(int[] numLayers)
|
65 |
29b82486
|
Leszek Koltunski
|
{
|
66 |
|
|
if( mCuts==null )
|
67 |
|
|
{
|
68 |
84a17011
|
Leszek Koltunski
|
float[] cut = new float[] { -SQ3/3, SQ3/3 };
|
69 |
29b82486
|
Leszek Koltunski
|
mCuts = new float[][] { cut,cut,cut,cut };
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
return mCuts;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76 |
|
|
|
77 |
59c20632
|
Leszek Koltunski
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
78 |
29b82486
|
Leszek Koltunski
|
{
|
79 |
59c20632
|
Leszek Koltunski
|
int numAxis = ROT_AXIS.length;
|
80 |
|
|
boolean[] tmp = new boolean[] {true,false,true};
|
81 |
|
|
boolean[][] layerRotatable = new boolean[numAxis][];
|
82 |
|
|
for(int i=0; i<numAxis; i++) layerRotatable[i] = tmp;
|
83 |
|
|
|
84 |
|
|
return layerRotatable;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88 |
|
|
|
89 |
11fa413d
|
Leszek Koltunski
|
public int getTouchControlType()
|
90 |
59c20632
|
Leszek Koltunski
|
{
|
91 |
c9c71c3f
|
Leszek Koltunski
|
return TC_HEXAHEDRON;
|
92 |
59c20632
|
Leszek Koltunski
|
}
|
93 |
|
|
|
94 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95 |
|
|
|
96 |
11fa413d
|
Leszek Koltunski
|
public int getTouchControlSplit()
|
97 |
59c20632
|
Leszek Koltunski
|
{
|
98 |
|
|
return TYPE_SPLIT_CORNER;
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102 |
|
|
|
103 |
|
|
public int[][][] getEnabled()
|
104 |
|
|
{
|
105 |
|
|
return new int[][][]
|
106 |
29b82486
|
Leszek Koltunski
|
{
|
107 |
59c20632
|
Leszek Koltunski
|
{{0,1},{3,1},{2,3},{0,2}},
|
108 |
|
|
{{2,3},{3,1},{0,1},{0,2}},
|
109 |
|
|
{{1,2},{0,1},{0,3},{2,3}},
|
110 |
|
|
{{1,2},{2,3},{0,3},{0,1}},
|
111 |
|
|
{{0,3},{0,2},{1,2},{1,3}},
|
112 |
|
|
{{1,2},{0,2},{0,3},{1,3}},
|
113 |
|
|
};
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117 |
|
|
|
118 |
|
|
public float[] getDist3D(int[] numLayers)
|
119 |
|
|
{
|
120 |
4c9ca251
|
Leszek Koltunski
|
return TouchControlHexahedron.D3D;
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
|
125 |
|
|
public Static3D[] getFaceAxis()
|
126 |
|
|
{
|
127 |
|
|
return TouchControlHexahedron.FACE_AXIS;
|
128 |
29b82486
|
Leszek Koltunski
|
}
|
129 |
|
|
|
130 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
131 |
|
|
|
132 |
7b832206
|
Leszek Koltunski
|
public float[][] getCubitPositions(int[] numLayers)
|
133 |
29b82486
|
Leszek Koltunski
|
{
|
134 |
|
|
if( mCenters ==null )
|
135 |
|
|
{
|
136 |
|
|
mCenters = new float[][]
|
137 |
|
|
{
|
138 |
|
|
{ 0.0f, 1.5f, 1.5f },
|
139 |
|
|
{ 1.5f, 0.0f, 1.5f },
|
140 |
|
|
{ 0.0f,-1.5f, 1.5f },
|
141 |
|
|
{-1.5f, 0.0f, 1.5f },
|
142 |
|
|
{ 1.5f, 1.5f, 0.0f },
|
143 |
|
|
{ 1.5f,-1.5f, 0.0f },
|
144 |
|
|
{-1.5f,-1.5f, 0.0f },
|
145 |
|
|
{-1.5f, 1.5f, 0.0f },
|
146 |
|
|
{ 0.0f, 1.5f,-1.5f },
|
147 |
|
|
{ 1.5f, 0.0f,-1.5f },
|
148 |
|
|
{ 0.0f,-1.5f,-1.5f },
|
149 |
|
|
{-1.5f, 0.0f,-1.5f }
|
150 |
|
|
};
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
return mCenters;
|
154 |
|
|
}
|
155 |
|
|
|
156 |
d0e6cf7f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
157 |
|
|
|
158 |
|
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
159 |
|
|
{
|
160 |
37310d4f
|
Leszek Koltunski
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,10,8,1,3,5,7,11,6,9,4 };
|
161 |
802fe251
|
Leszek Koltunski
|
return mObjectQuats[mQuatIndex[cubit]];
|
162 |
d0e6cf7f
|
Leszek Koltunski
|
}
|
163 |
|
|
|
164 |
84a17011
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
|
|
|
166 |
|
|
private float[][] getVertices(int variant)
|
167 |
|
|
{
|
168 |
|
|
return new float[][] { {-1.5f, 0.0f, 0.0f},{ 1.5f, 0.0f, 0.0f},{ 0.0f,-1.5f, 0.0f},{ 0.0f, 0.0f,-1.5f} };
|
169 |
|
|
}
|
170 |
|
|
|
171 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
172 |
|
|
|
173 |
e30c522a
|
Leszek Koltunski
|
public ObjectShape getObjectShape(int variant)
|
174 |
29b82486
|
Leszek Koltunski
|
{
|
175 |
8bb3e677
|
Leszek Koltunski
|
int[][] indices = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
|
176 |
84a17011
|
Leszek Koltunski
|
return new ObjectShape(getVertices(variant), indices);
|
177 |
3ee1d662
|
Leszek Koltunski
|
}
|
178 |
|
|
|
179 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180 |
|
|
|
181 |
|
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
182 |
|
|
{
|
183 |
3bf19410
|
Leszek Koltunski
|
float h1 = isInIconMode() ? 0.001f : 0.035f;
|
184 |
|
|
float h2 = isInIconMode() ? 0.001f : 0.010f;
|
185 |
3542b8f3
|
leszek
|
float[][] bands = { {h1,30,0.16f,0.8f,6,1,2}, {h2,30,0.16f,0.8f,6,1,2} };
|
186 |
84a17011
|
Leszek Koltunski
|
int[] bandIndices= { 0,0,1,1 };
|
187 |
|
|
return new ObjectFaceShape(bands,bandIndices,null);
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191 |
|
|
|
192 |
|
|
public ObjectVertexEffects getVertexEffects(int variant)
|
193 |
|
|
{
|
194 |
4e9f2df5
|
Leszek Koltunski
|
float[][] corners = { {0.07f,0.40f}, {0.05f,0.30f} };
|
195 |
3542b8f3
|
leszek
|
int[] cornerIndices = { 0,0,1,1,/*-1*/ };
|
196 |
4e9f2df5
|
Leszek Koltunski
|
float[][] centers = { {0.0f, -0.75f, -0.75f} };
|
197 |
3542b8f3
|
leszek
|
int[] centerIndices = { 0,0,0,0,/*-1*/ };
|
198 |
84a17011
|
Leszek Koltunski
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
199 |
29b82486
|
Leszek Koltunski
|
}
|
200 |
|
|
|
201 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
202 |
|
|
|
203 |
e30c522a
|
Leszek Koltunski
|
public int getNumCubitVariants(int[] numLayers)
|
204 |
29b82486
|
Leszek Koltunski
|
{
|
205 |
|
|
return 1;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
209 |
|
|
|
210 |
e30c522a
|
Leszek Koltunski
|
public int getCubitVariant(int cubit, int[] numLayers)
|
211 |
29b82486
|
Leszek Koltunski
|
{
|
212 |
|
|
return 0;
|
213 |
|
|
}
|
214 |
|
|
|
215 |
3d766df3
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
216 |
|
|
|
217 |
d53fb890
|
Leszek Koltunski
|
public float getStickerRadius()
|
218 |
3d766df3
|
Leszek Koltunski
|
{
|
219 |
00f4980d
|
Leszek Koltunski
|
return 0.09f;
|
220 |
3d766df3
|
Leszek Koltunski
|
}
|
221 |
|
|
|
222 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
223 |
|
|
|
224 |
d53fb890
|
Leszek Koltunski
|
public float getStickerStroke()
|
225 |
3d766df3
|
Leszek Koltunski
|
{
|
226 |
3bf19410
|
Leszek Koltunski
|
return isInIconMode() ? 0.22f : 0.15f;
|
227 |
3d766df3
|
Leszek Koltunski
|
}
|
228 |
|
|
|
229 |
00f4980d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
230 |
|
|
|
231 |
ebe8c08e
|
leszek
|
public float[][][] getStickerAngles()
|
232 |
00f4980d
|
Leszek Koltunski
|
{
|
233 |
|
|
return null;
|
234 |
|
|
}
|
235 |
|
|
|
236 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
237 |
|
|
// PUBLIC API
|
238 |
|
|
|
239 |
|
|
public Static3D[] getRotationAxis()
|
240 |
|
|
{
|
241 |
|
|
return ROT_AXIS;
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
245 |
|
|
|
246 |
beee90ab
|
Leszek Koltunski
|
public int[][] getBasicAngles()
|
247 |
29b82486
|
Leszek Koltunski
|
{
|
248 |
beee90ab
|
Leszek Koltunski
|
if( mBasicAngle==null )
|
249 |
|
|
{
|
250 |
76de8309
|
Leszek Koltunski
|
int[] tmp = {3,3,3};
|
251 |
beee90ab
|
Leszek Koltunski
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
252 |
|
|
}
|
253 |
|
|
|
254 |
29b82486
|
Leszek Koltunski
|
return mBasicAngle;
|
255 |
|
|
}
|
256 |
|
|
}
|