Project

General

Profile

Download (15 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyTins.java @ a2c64ac3

1 5d7bb479 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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
import org.distorted.objectlib.helpers.FactoryCubit;
18
import org.distorted.objectlib.helpers.ObjectFaceShape;
19
import org.distorted.objectlib.helpers.ObjectShape;
20
import org.distorted.objectlib.helpers.ObjectSignature;
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.main.ObjectSignatures;
25
import org.distorted.objectlib.main.ObjectType;
26
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
27
import org.distorted.objectlib.shape.ShapeHexahedron;
28
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
29
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31
32
public class TwistyTins extends ShapeHexahedron
33
{
34
  static final Static3D[] ROT_AXIS = new Static3D[]
35
         {
36
           new Static3D( SQ3/3, SQ3/3, SQ3/3),
37
           new Static3D( SQ3/3, SQ3/3,-SQ3/3),
38
           new Static3D( SQ3/3,-SQ3/3, SQ3/3),
39
           new Static3D( SQ3/3,-SQ3/3,-SQ3/3)
40
         };
41
42
  private int[][] mEdges;
43
  private int[][] mBasicAngle;
44
  private float[][] mCuts;
45
  private float[][] mPosition;
46
  private int[] mQuatIndex;
47
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49
50
  public TwistyTins(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
51
    {
52
    super(meshState, iconMode, 4, quat, move, scale, data, asset);
53
    }
54
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56
57
  public int[][] getScrambleEdges()
58
    {
59
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
60
    return mEdges;
61
    }
62
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
65
  public float[][] getCuts(int[] numLayers)
66
    {
67
    if( mCuts==null )
68
      {
69
      float C1 = -4*SQ3/3;
70
      float C2 = -2*SQ3/3;
71
      float C3 =  2*SQ3/3;
72
      float C4 =    SQ3+0.01f;
73
74
      float[] cut1 = new float[] { C1, C2, C3, C4 };
75
      float[] cut2 = new float[] {-C4,-C3,-C2,-C1 };
76
77
      mCuts = new float[][] { cut1,cut2,cut2,cut1 };
78
      }
79
80
    return mCuts;
81
    }
82
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84
85
  public boolean[][] getLayerRotatable(int[] numLayers)
86
    {
87
    boolean[] tmp = new boolean[] {true,true,false,true,true};
88
    return new boolean[][] { tmp,tmp,tmp,tmp };
89
    }
90
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92
93
  public int getTouchControlType()
94
    {
95
    return TC_HEXAHEDRON;
96
    }
97
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99
100
  public int getTouchControlSplit()
101
    {
102
    return TYPE_SPLIT_CORNER;
103
    }
104
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106
107
  public int[][][] getEnabled()
108
    {
109
    return new int[][][]
110
      {
111
          {{0,1},{3,1},{2,3},{0,2}},
112
          {{2,3},{3,1},{0,1},{0,2}},
113
          {{1,2},{0,1},{0,3},{2,3}},
114
          {{1,2},{2,3},{0,3},{0,1}},
115
          {{0,3},{0,2},{1,2},{1,3}},
116
          {{1,2},{0,2},{0,3},{1,3}},
117
      };
118
    }
119
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
122
  public float[] getDist3D(int[] numLayers)
123
    {
124
    return TouchControlHexahedron.D3D;
125
    }
126
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128
129
  public Static3D[] getFaceAxis()
130
    {
131
    return TouchControlHexahedron.FACE_AXIS;
132
    }
133
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135
// corner cubes, corner 'dino' , edges, centers.
136
137
  public float[][] getCubitPositions(int[] numLayers)
138
    {
139
    if( mPosition==null )
140
      {
141
      float C1 = 1.5f;
142
      float C2 = 1.0f;
143
      float C3 = 2.0f;
144
      float C4 = 0.5f;
145
      float C5 = 0.25f;
146
      float C6 = 0.75f;
147
148
      mPosition = new float[][]
149
         {
150
             { C1, C1, C1},
151
             {-C1, C1,-C1},
152
             { C1,-C1,-C1},
153
             {-C1,-C1, C1},
154
155
             {-C2, C3, C3},
156
             {-C3, C2, C3},
157
             {-C3, C3, C2},
158
             { C2, C3,-C3},
159
             { C3, C2,-C3},
160
             { C3, C3,-C2},
161
             { C2,-C3, C3},
162
             { C3,-C2, C3},
163
             { C3,-C3, C2},
164
             {-C2,-C3,-C3},
165
             {-C3,-C2,-C3},
166
             {-C3,-C3,-C2},
167
168
             { C4, C3, C3},
169
             { C3, C4, C3},
170
             {-C4,-C3, C3},
171
             {-C3,-C4, C3},
172
             { C3, C3, C4},
173
             { C3,-C3,-C4},
174
             {-C3,-C3, C4},
175
             {-C3, C3,-C4},
176
             {-C4, C3,-C3},
177
             { C3,-C4,-C3},
178
             { C4,-C3,-C3},
179
             {-C3, C4,-C3},
180
181
             {-C5, C6, C3}, // F
182
             { C6,-C5, C3},
183
             { C5,-C6, C3},
184
             {-C6, C5, C3},
185
             { C5, C6,-C3}, // B
186
             {-C6,-C5,-C3},
187
             {-C5,-C6,-C3},
188
             { C6, C5,-C3},
189
             { C3, C6,-C5}, // R
190
             { C3, C5,-C6},
191
             { C3,-C6, C5},
192
             { C3,-C5, C6},
193
             {-C3, C6, C5}, // L
194
             {-C3, C5, C6},
195
             {-C3,-C6,-C5},
196
             {-C3,-C5,-C6},
197
             { C5, C3,-C6}, // T
198
             { C6, C3,-C5},
199
             {-C5, C3, C6},
200
             {-C6, C3, C5},
201
             { C5,-C3, C6}, // D
202
             { C6,-C3, C5},
203
             {-C5,-C3,-C6},
204
             {-C6,-C3,-C5},
205
         };
206
      }
207
208
    return mPosition;
209
    }
210
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212
213
  public Static4D getCubitQuats(int cubit, int[] numLayers)
214
    {
215
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0, 3, 4, 6,
216
                                                    0, 8, 7,11, 5, 1,10, 2, 4, 9, 3, 6,
217
                                                    0, 2,10, 8, 1, 4, 6, 7,11, 5, 9, 3,
218
                                                    0, 0, 0, 0, 9, 9, 9, 9, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 4, 4, 4, 4
219
                                                  };
220
    return mObjectQuats[mQuatIndex[cubit]];
221
    }
222
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224
225
  private float[][] getVertices(int variant)
226
    {
227
    if( variant==0 )
228
      {
229
      return new float[][]
230
          {
231
             { 0.0f, 0.0f, 0.0f },
232
             {-0.5f, 0.5f, 0.5f },
233
             {-0.5f,-0.5f, 0.5f },
234
             { 0.5f, 0.5f, 0.5f },
235
             { 0.5f,-0.5f, 0.5f },
236
             { 0.5f, 0.5f,-0.5f },
237
             { 0.5f,-0.5f,-0.5f },
238
             {-0.5f, 0.5f,-0.5f },
239
          };
240
      }
241
    else if( variant==1 )
242
      {
243
      return new float[][]
244
          {
245
             {-1.0f, 0.0f, 0.0f},
246
             { 1.0f, 0.0f, 0.0f},
247
             { 0.0f,-1.0f, 0.0f},
248
             { 0.0f, 0.0f,-1.0f}
249
          };
250
      }
251
    else if( variant==2 )
252
      {
253
      return new float[][]
254
          {
255
             {-0.5f, 0.0f, 0.0f},
256
             { 0.5f, 0.0f, 0.0f},
257
             { 0.5f,-1.0f, 0.0f},
258
             { 0.0f,-1.5f, 0.0f},
259
             {-1.0f,-0.5f, 0.0f},
260
             {-1.0f, 0.0f,-0.5f},
261
             { 0.0f, 0.0f,-1.5f},
262
             { 0.5f, 0.0f,-1.0f}
263
          };
264
      }
265
    else
266
      {
267
      return new float[][]
268
          {
269
             {-0.25f, 0.75f, 0.0f},
270
             { 0.75f,-0.25f, 0.0f},
271
             { 0.25f,-0.75f, 0.0f},
272
             {-0.75f, 0.25f, 0.0f},
273
             { 0.00f, 0.00f,-1.0f},
274
          };
275
      }
276
    }
277
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279
280
  public ObjectShape getObjectShape(int variant)
281
    {
282
    if( variant==0 )
283
      {
284
      int[][] indices =
285
          {
286
             { 2,4,3,1 },
287
             { 1,3,5,7 },
288
             { 4,6,5,3 },
289
             { 0,4,2 },
290
             { 0,7,5 },
291
             { 0,6,4 },
292
             { 0,1,7 },
293
             { 0,2,1 },
294
             { 0,5,6 }
295
          };
296
297
      return new ObjectShape(getVertices(variant), indices);
298
      }
299
    else if( variant==1 )
300
      {
301
      int[][] indices =
302
          {
303
             {2,1,0},
304
             {3,0,1},
305
             {2,3,1},
306
             {3,2,0}
307
          };
308
309
      return new ObjectShape(getVertices(variant), indices);
310
      }
311
    else if( variant==2 )
312
      {
313
      int[][] indices =
314
          {
315
             {4,3,2,1,0},
316
             {0,1,7,6,5},
317
             {1,2,7},
318
             {2,3,6,7},
319
             {3,4,5,6},
320 a2c64ac3 Leszek Koltunski
             {0,5,4}
321 5d7bb479 Leszek Koltunski
          };
322
323
      return new ObjectShape(getVertices(variant), indices);
324
      }
325
    else
326
      {
327
      int[][] indices =
328
          {
329
             {3,2,1,0},
330
             {4,1,2},
331
             {4,0,1},
332
             {4,3,0},
333
             {4,2,3}
334
          };
335
336
      return new ObjectShape(getVertices(variant), indices);
337
      }
338
    }
339
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341
342
  public ObjectFaceShape getObjectFaceShape(int variant)
343
    {
344
    if( variant==0 )
345
      {
346
      float h1 = isInIconMode() ? 0.001f : 0.06f;
347
      float h2 = isInIconMode() ? 0.001f : 0.01f;
348
      float[][] bands = { {h1,35,0.5f,0.7f,5,1,0}, {h2,35,0.2f,0.4f,5,1,0} };
349
      int[] indices   = { 0,0,0,1,1,1,1,1,1 };
350
      return new ObjectFaceShape(bands,indices,null);
351
      }
352
    else if( variant==1 )
353
      {
354
      float h1 = isInIconMode() ? 0.001f : 0.035f;
355
      float h2 = isInIconMode() ? 0.001f : 0.010f;
356
      float[][] bands  = { {h1,30,0.16f,0.8f,5,0,0}, {h2,30,0.16f,0.2f,5,0,0} };
357
      int[] bandIndices= { 0,0,1,1 };
358
      return new ObjectFaceShape(bands,bandIndices,null);
359
      }
360
    else if( variant==2 )
361
      {
362
      float h1 = isInIconMode() ? 0.001f : 0.035f;
363
      float h2 = isInIconMode() ? 0.001f : 0.010f;
364
      float[][] bands  = { {h1,30,0.16f,0.8f,5,1,0}, {h2,30,0.16f,0.2f,5,0,0} };
365
      int[] bandIndices= { 0,0,1,1,1,1 };
366
      return new ObjectFaceShape(bands,bandIndices,null);
367
      }
368
    else
369
      {
370 a2c64ac3 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.040f;
371 5d7bb479 Leszek Koltunski
      float h2 = isInIconMode() ? 0.001f : 0.010f;
372 a2c64ac3 Leszek Koltunski
      float[][] bands  = { {h1,30,0.3f,0.5f,5,0,0}, {h2,30,0.1f,0.2f,3,0,0} };
373 5d7bb479 Leszek Koltunski
      int[] bandIndices= { 0,1,1,1,1 };
374
      return new ObjectFaceShape(bands,bandIndices,null);
375
      }
376
    }
377
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
380
  public ObjectVertexEffects getVertexEffects(int variant)
381
    {
382
    if( variant==0 )
383
      {
384
      float[][] corners = { {0.06f,0.12f} };
385
      int[] indices     = { -1,0,-1,0,0,0,-1,-1 };
386
      float[][] centers = { { 0.0f, 0.0f, 0.0f} };
387
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
388
      }
389
    else if( variant==1 )
390
      {
391 a2c64ac3 Leszek Koltunski
      float[][] corners   = { {0.05f,0.30f}, {0.05f,0.20f} };
392 5d7bb479 Leszek Koltunski
      int[] cornerIndices = { 0,0,1,1 };
393
      float[][] centers   = { {0.0f, -0.75f, -0.75f} };
394
      int[] centerIndices = { 0,0,0,0 };
395
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
396
      }
397
    else if( variant==2 )
398
      {
399 a2c64ac3 Leszek Koltunski
      float[][] corners   = { {0.05f,0.20f}, {0.05f,0.15f} };
400 5d7bb479 Leszek Koltunski
      int[] cornerIndices = { 0,0,1,1,1,1,1,1 };
401
      float[][] centers   = { {0.0f, -0.5f, -0.5f} };
402
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
403
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
404
      }
405
    else
406
      {
407
      return null;
408
      }
409
    }
410
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412
413
  public int getNumCubitVariants(int[] numLayers)
414
    {
415
    return 4;
416
    }
417
418
///////////////////////////////////////////////////////////////////////////////////////////////////
419
420
  public int getCubitVariant(int cubit, int[] numLayers)
421
    {
422
    return cubit<4 ? 0: (cubit<16 ? 1: (cubit<28 ? 2:3));
423
    }
424
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426
427
  public float getStickerRadius()
428
    {
429
    return 0.09f;
430
    }
431
432
///////////////////////////////////////////////////////////////////////////////////////////////////
433
434
  public float getStickerStroke()
435
    {
436
    return isInIconMode() ? 0.20f : 0.09f;
437
    }
438
439
///////////////////////////////////////////////////////////////////////////////////////////////////
440
441
  public float[][] getStickerAngles()
442
    {
443
    return null;
444
    }
445
446
///////////////////////////////////////////////////////////////////////////////////////////////////
447
// PUBLIC API
448
449
  public Static3D[] getRotationAxis()
450
    {
451
    return ROT_AXIS;
452
    }
453
454
///////////////////////////////////////////////////////////////////////////////////////////////////
455
456
  public int[][] getBasicAngles()
457
    {
458
    if( mBasicAngle ==null )
459
      {
460
      int[] tmp = {3,3,3,3,3};
461
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
462
      }
463
464
    return mBasicAngle;
465
    }
466
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468
469
  public String getShortName()
470
    {
471
    return ObjectType.TINS_5.name();
472
    }
473
474
///////////////////////////////////////////////////////////////////////////////////////////////////
475
476
  public ObjectSignature getSignature()
477
    {
478
    return new ObjectSignature(ObjectSignatures.TINS_5);
479
    }
480
481
///////////////////////////////////////////////////////////////////////////////////////////////////
482
483
  public String getObjectName()
484
    {
485
    return "Tins Cube";
486
    }
487
488
///////////////////////////////////////////////////////////////////////////////////////////////////
489
490
  public String getInventor()
491
    {
492
    return "조현준";
493
    }
494
495
///////////////////////////////////////////////////////////////////////////////////////////////////
496
497
  public int getYearOfInvention()
498
    {
499
    return 2021;
500
    }
501
502
///////////////////////////////////////////////////////////////////////////////////////////////////
503
504
  public int getComplexity()
505
    {
506
    return 2;
507
    }
508
509
///////////////////////////////////////////////////////////////////////////////////////////////////
510
511
  public String[][] getTutorials()
512
    {
513
    return null;
514
    }
515
}