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.metadata.Metadata;
|
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
|
public 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 iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
48
|
{
|
49
|
super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
|
50
|
}
|
51
|
|
52
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
public float[][] getCuts(int[] numLayers)
|
65
|
{
|
66
|
if( mCuts==null )
|
67
|
{
|
68
|
float[] cut = new float[] { -SQ3/3, SQ3/3 };
|
69
|
mCuts = new float[][] { cut,cut,cut,cut };
|
70
|
}
|
71
|
|
72
|
return mCuts;
|
73
|
}
|
74
|
|
75
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76
|
|
77
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
78
|
{
|
79
|
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
|
public int getTouchControlType()
|
90
|
{
|
91
|
return TC_HEXAHEDRON;
|
92
|
}
|
93
|
|
94
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
95
|
|
96
|
public int getTouchControlSplit()
|
97
|
{
|
98
|
return TYPE_SPLIT_CORNER;
|
99
|
}
|
100
|
|
101
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102
|
|
103
|
public int[][][] getEnabled()
|
104
|
{
|
105
|
return new int[][][]
|
106
|
{
|
107
|
{{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
|
return TouchControlHexahedron.D3D;
|
121
|
}
|
122
|
|
123
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124
|
|
125
|
public Static3D[] getFaceAxis()
|
126
|
{
|
127
|
return TouchControlHexahedron.FACE_AXIS;
|
128
|
}
|
129
|
|
130
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
131
|
|
132
|
public float[][] getCubitPositions(int[] numLayers)
|
133
|
{
|
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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
157
|
|
158
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
159
|
{
|
160
|
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,10,8,1,3,5,7,11,6,9,4 };
|
161
|
return mObjectQuats[mQuatIndex[cubit]];
|
162
|
}
|
163
|
|
164
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
172
|
|
173
|
public ObjectShape getObjectShape(int variant)
|
174
|
{
|
175
|
int[][] indices = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
|
176
|
return new ObjectShape(getVertices(variant), indices);
|
177
|
}
|
178
|
|
179
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180
|
|
181
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
182
|
{
|
183
|
float h1 = isInIconMode() ? 0.001f : 0.035f;
|
184
|
float h2 = isInIconMode() ? 0.001f : 0.010f;
|
185
|
float[][] bands = { {h1,30,0.16f,0.8f,6,1,2}, {h2,30,0.16f,0.8f,6,1,2} };
|
186
|
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
|
float[][] corners = { {0.07f,0.40f}, {0.05f,0.30f} };
|
195
|
int[] cornerIndices = { 0,0,1,1,/*-1*/ };
|
196
|
float[][] centers = { {0.0f, -0.75f, -0.75f} };
|
197
|
int[] centerIndices = { 0,0,0,0,/*-1*/ };
|
198
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
|
199
|
}
|
200
|
|
201
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
202
|
|
203
|
public int getNumCubitVariants(int[] numLayers)
|
204
|
{
|
205
|
return 1;
|
206
|
}
|
207
|
|
208
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
209
|
|
210
|
public int getCubitVariant(int cubit, int[] numLayers)
|
211
|
{
|
212
|
return 0;
|
213
|
}
|
214
|
|
215
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
216
|
|
217
|
public float getStickerRadius()
|
218
|
{
|
219
|
return 0.09f;
|
220
|
}
|
221
|
|
222
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
223
|
|
224
|
public float getStickerStroke()
|
225
|
{
|
226
|
return isInIconMode() ? 0.22f : 0.15f;
|
227
|
}
|
228
|
|
229
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
230
|
|
231
|
public float[][][] getStickerAngles()
|
232
|
{
|
233
|
return null;
|
234
|
}
|
235
|
|
236
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
237
|
// PUBLIC API
|
238
|
|
239
|
public Static3D[] getRotationAxis()
|
240
|
{
|
241
|
return ROT_AXIS;
|
242
|
}
|
243
|
|
244
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
245
|
|
246
|
public int[][] getBasicAngles()
|
247
|
{
|
248
|
if( mBasicAngle==null )
|
249
|
{
|
250
|
int[] tmp = {3,3,3};
|
251
|
mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
|
252
|
}
|
253
|
|
254
|
return mBasicAngle;
|
255
|
}
|
256
|
}
|