1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 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.helpers.ScrambleState;
|
27
|
import org.distorted.objectlib.main.ObjectControl;
|
28
|
import org.distorted.objectlib.main.ObjectType;
|
29
|
import org.distorted.objectlib.main.ShapeHexahedron;
|
30
|
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
|
31
|
|
32
|
import java.io.InputStream;
|
33
|
|
34
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
|
35
|
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
public class TwistyContainer extends ShapeHexahedron
|
40
|
{
|
41
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
42
|
{
|
43
|
new Static3D( SQ6/3,-SQ3/3, 0.0f),
|
44
|
new Static3D( SQ6/3, SQ3/3, 0.0f),
|
45
|
new Static3D( 0.0f,-SQ3/3, SQ6/3),
|
46
|
new Static3D( 0.0f, SQ3/3, SQ6/3)
|
47
|
};
|
48
|
|
49
|
private ScrambleState[] mStates;
|
50
|
private int[] mBasicAngle;
|
51
|
private float[][] mCuts;
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
public TwistyContainer(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
|
56
|
{
|
57
|
super(numL, meshState, numL[0], quat, move, scale, stream);
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
@Override
|
63
|
public int getInternalColor()
|
64
|
{
|
65
|
return 0xff999999;
|
66
|
}
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
|
70
|
public ScrambleState[] getScrambleStates()
|
71
|
{
|
72
|
if( mStates==null )
|
73
|
{
|
74
|
int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
|
75
|
|
76
|
mStates = new ScrambleState[]
|
77
|
{
|
78
|
new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
|
79
|
};
|
80
|
}
|
81
|
|
82
|
return mStates;
|
83
|
}
|
84
|
|
85
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86
|
|
87
|
public float[][] getCuts(int[] numLayers)
|
88
|
{
|
89
|
if( mCuts==null )
|
90
|
{
|
91
|
float[] c = {0};
|
92
|
mCuts = new float[][] {c,c,c,c};
|
93
|
}
|
94
|
|
95
|
return mCuts;
|
96
|
}
|
97
|
|
98
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99
|
|
100
|
public boolean[][] getLayerRotatable(int[] numLayers)
|
101
|
{
|
102
|
boolean[] tmp = {true,true};
|
103
|
return new boolean[][] { tmp,tmp,tmp,tmp };
|
104
|
}
|
105
|
|
106
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107
|
|
108
|
public int getTouchControlType()
|
109
|
{
|
110
|
return TC_CHANGING_SHAPEMOD;
|
111
|
}
|
112
|
|
113
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114
|
|
115
|
public int getTouchControlSplit()
|
116
|
{
|
117
|
return TYPE_NOT_SPLIT;
|
118
|
}
|
119
|
|
120
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121
|
|
122
|
public int[][][] getEnabled()
|
123
|
{
|
124
|
return null;
|
125
|
}
|
126
|
|
127
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128
|
|
129
|
public float[] getDist3D(int[] numLayers)
|
130
|
{
|
131
|
return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135
|
|
136
|
public Static3D[] getFaceAxis()
|
137
|
{
|
138
|
return TouchControlHexahedron.FACE_AXIS;
|
139
|
}
|
140
|
|
141
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142
|
|
143
|
public float[][] getCubitPositions(int[] numLayers)
|
144
|
{
|
145
|
return new float[][]
|
146
|
{
|
147
|
{ 0.0f, -SQ2, 0.0f},
|
148
|
{ 0.0f, +SQ2, 0.0f},
|
149
|
|
150
|
{-1.0f, 0.0f, 1.0f},
|
151
|
{ 1.0f, 0.0f, 1.0f},
|
152
|
{ 1.0f, 0.0f,-1.0f},
|
153
|
{-1.0f, 0.0f,-1.0f},
|
154
|
|
155
|
{ 0.0f,-SQ2/2, 1.0f},
|
156
|
{ 0.0f,+SQ2/2, 1.0f},
|
157
|
{ 1.0f,-SQ2/2, 0.0f},
|
158
|
{ 1.0f, SQ2/2, 0.0f},
|
159
|
{ 0.0f,-SQ2/2,-1.0f},
|
160
|
{ 0.0f,+SQ2/2,-1.0f},
|
161
|
{-1.0f,-SQ2/2, 0.0f},
|
162
|
{-1.0f, SQ2/2, 0.0f},
|
163
|
};
|
164
|
}
|
165
|
|
166
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
167
|
|
168
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
169
|
{
|
170
|
switch(cubit)
|
171
|
{
|
172
|
case 0: return mObjectQuats[ 0];
|
173
|
case 1: return mObjectQuats[10];
|
174
|
|
175
|
case 2: return mObjectQuats[11];
|
176
|
case 3: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
|
177
|
case 4: return mObjectQuats[ 0];
|
178
|
case 5: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
|
179
|
|
180
|
case 6: return mObjectQuats[ 0];
|
181
|
case 7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
|
182
|
case 8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
|
183
|
case 9: return mObjectQuats[10];
|
184
|
case 10: return mObjectQuats[11];
|
185
|
case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
|
186
|
case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
|
187
|
case 13: return mObjectQuats[ 9];
|
188
|
}
|
189
|
|
190
|
return null;
|
191
|
}
|
192
|
|
193
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
194
|
|
195
|
public ObjectShape getObjectShape(int variant)
|
196
|
{
|
197
|
if( variant==0 )
|
198
|
{
|
199
|
float[][] vertices= { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
|
200
|
int[][] indices = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
|
201
|
return new ObjectShape(vertices, indices);
|
202
|
}
|
203
|
else if( variant==1 )
|
204
|
{
|
205
|
float[][] vertices= { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
|
206
|
int[][] indices = { {4,3,1},{4,2,3},{2,0,3},{3,0,1},{1,0,4},{0,2,4} };
|
207
|
return new ObjectShape(vertices, indices);
|
208
|
}
|
209
|
else
|
210
|
{
|
211
|
float[][] vertices= { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
|
212
|
int[][] indices = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
|
213
|
return new ObjectShape(vertices, indices);
|
214
|
}
|
215
|
}
|
216
|
|
217
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
218
|
|
219
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
220
|
{
|
221
|
if( variant==0 )
|
222
|
{
|
223
|
float[][] bands = { {0.05f,35,0.26f,0.7f,5,2,1}, {0.001f,35,0.26f,0.7f,5,2,1} };
|
224
|
int[] bandIndices = { 0,1,1,1,1 };
|
225
|
float[][] corners = { {0.03f,0.20f} };
|
226
|
int[] indices = { 0,0,0,0,-1 };
|
227
|
float[][] centers = { { 0.0f, SQ2, 0.0f} };
|
228
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
229
|
}
|
230
|
else if( variant==1 )
|
231
|
{
|
232
|
float[][] bands = { {0.04f,25,0.26f,0.7f,5,1,1}, {0.001f,25,0.26f,0.7f,5,1,1} };
|
233
|
int[] bandIndices = { 0,0,1,1,1,1 };
|
234
|
float[][] corners = { {0.03f,0.20f} };
|
235
|
int[] indices = { -1,0,0,0,0 };
|
236
|
float[][] centers = { {-1,0,1} };
|
237
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
238
|
}
|
239
|
else
|
240
|
{
|
241
|
float[][] bands = { {0.05f,35,0.26f,0.7f,5,1,1}, {0.001f,35,0.26f,0.7f,5,1,1} };
|
242
|
int[] bandIndices = { 0,1,1,1 };
|
243
|
float[][] corners = { {0.03f,0.20f} };
|
244
|
int[] indices = { 0,0,0,-1 };
|
245
|
float[][] centers = { {0.0f, SQ2/2, -1.0f} };
|
246
|
return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
|
247
|
}
|
248
|
}
|
249
|
|
250
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
251
|
|
252
|
public int getNumCubitVariants(int[] numLayers)
|
253
|
{
|
254
|
return 3;
|
255
|
}
|
256
|
|
257
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
258
|
|
259
|
public int getCubitVariant(int cubit, int[] numLayers)
|
260
|
{
|
261
|
return cubit<2 ? 0 : (cubit<6 ? 1:2);
|
262
|
}
|
263
|
|
264
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
265
|
|
266
|
public float getStickerRadius()
|
267
|
{
|
268
|
return 0.10f;
|
269
|
}
|
270
|
|
271
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
272
|
|
273
|
public float getStickerStroke()
|
274
|
{
|
275
|
return ObjectControl.isInIconMode() ? 0.20f : 0.06f;
|
276
|
}
|
277
|
|
278
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
279
|
|
280
|
public float[][] getStickerAngles()
|
281
|
{
|
282
|
return null;
|
283
|
}
|
284
|
|
285
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
286
|
// PUBLIC API
|
287
|
|
288
|
public Static3D[] getRotationAxis()
|
289
|
{
|
290
|
return ROT_AXIS;
|
291
|
}
|
292
|
|
293
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
294
|
|
295
|
public int[] getBasicAngles()
|
296
|
{
|
297
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
|
298
|
return mBasicAngle;
|
299
|
}
|
300
|
|
301
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
302
|
|
303
|
public ObjectType intGetObjectType(int[] numLayers)
|
304
|
{
|
305
|
return ObjectType.CONT_2;
|
306
|
}
|
307
|
|
308
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
309
|
|
310
|
public String getObjectName()
|
311
|
{
|
312
|
return "Container";
|
313
|
}
|
314
|
|
315
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
316
|
|
317
|
public String getInventor()
|
318
|
{
|
319
|
return "Tony Fisher";
|
320
|
}
|
321
|
|
322
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
323
|
|
324
|
public int getYearOfInvention()
|
325
|
{
|
326
|
return 1998;
|
327
|
}
|
328
|
|
329
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
330
|
|
331
|
public int getComplexity()
|
332
|
{
|
333
|
return 2;
|
334
|
}
|
335
|
}
|