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