Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyContainer.java @ cf93ea4e

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 org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14
import org.distorted.objectlib.helpers.FactoryCubit;
15
import org.distorted.objectlib.helpers.ObjectFaceShape;
16
import org.distorted.objectlib.helpers.ObjectShape;
17
import org.distorted.objectlib.helpers.ObjectSignature;
18
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19
import org.distorted.objectlib.main.InitAssets;
20
import org.distorted.objectlib.main.ObjectSignatures;
21
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
22
import org.distorted.objectlib.main.InitData;
23
import org.distorted.objectlib.main.ObjectType;
24
import org.distorted.objectlib.shape.ShapeHexahedron;
25
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
26

    
27
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
28
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
29

    
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

    
32
public class TwistyContainer extends ShapeHexahedron
33
{
34
  static final Static3D[] ROT_AXIS = new Static3D[]
35
         {
36
           new Static3D( SQ6/3,-SQ3/3,  0.0f),
37
           new Static3D( SQ6/3, SQ3/3,  0.0f),
38
           new Static3D(  0.0f,-SQ3/3, SQ6/3),
39
           new Static3D(  0.0f, SQ3/3, SQ6/3)
40
         };
41

    
42
  private int[][] mEdges;
43
  private int[][] mBasicAngle;
44
  private float[][] mCuts;
45
  private int[][] mFaceMap;
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  public TwistyContainer(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
50
    {
51
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
// we want colorful insides
56

    
57
  @Override
58
  public int getCubitFaceMap(int cubit, int face)
59
    {
60
    if( mFaceMap==null )
61
      {
62
      mFaceMap = new int[][]
63
         {
64
             { 3, 3, 3, 3, 3, 3},
65
             { 2, 2, 2, 2, 2, 2},
66

    
67
             { 0, 5, 5, 0, 0, 5},
68
             { 5, 1, 1, 5, 5, 1},
69
             { 1, 4, 4, 1, 1, 4},
70
             { 4, 0, 0, 4, 4, 0},
71

    
72
             { 4, 4, 4, 4, 4, 4},
73
             { 4, 4, 4, 4, 4, 4},
74
             { 0, 0, 0, 0, 0, 0},
75
             { 0, 0, 0, 0, 0, 0},
76
             { 5, 5, 5, 5, 5, 5},
77
             { 5, 5, 5, 5, 5, 5},
78
             { 1, 1, 1, 1, 1, 1},
79
             { 1, 1, 1, 1, 1, 1},
80
         };
81
      }
82

    
83
    return mFaceMap[cubit][face];
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

    
88
  public int[][] getScrambleEdges()
89
    {
90
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
91
    return mEdges;
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public float[][] getCuts(int[] numLayers)
97
    {
98
    if( mCuts==null )
99
      {
100
      float[] c = {0};
101
      mCuts = new float[][] {c,c,c,c};
102
      }
103

    
104
    return mCuts;
105
    }
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

    
109
  public boolean[][] getLayerRotatable(int[] numLayers)
110
    {
111
    boolean[] tmp = {true,true};
112
    return new boolean[][] { tmp,tmp,tmp,tmp };
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  public int getTouchControlType()
118
    {
119
    return TC_CHANGING_SHAPEMOD;
120
    }
121

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

    
124
  public int getTouchControlSplit()
125
    {
126
    return TYPE_NOT_SPLIT;
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

    
131
  public int[][][] getEnabled()
132
    {
133
    return null;
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  public float[] getDist3D(int[] numLayers)
139
    {
140
    return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144

    
145
  public Static3D[] getFaceAxis()
146
    {
147
    return TouchControlHexahedron.FACE_AXIS;
148
    }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

    
152
  public float[][] getCubitPositions(int[] numLayers)
153
    {
154
    return new float[][]
155
        {
156
            { 0.0f,  -SQ2, 0.0f},
157
            { 0.0f,   SQ2, 0.0f},
158

    
159
            { 1.0f,  0.0f,-1.0f},
160
            {-1.0f,  0.0f,-1.0f},
161
            {-1.0f,  0.0f, 1.0f},
162
            { 1.0f,  0.0f, 1.0f},
163

    
164
            { 0.0f,-SQ2/2, 1.0f},
165
            { 0.0f, SQ2/2, 1.0f},
166
            { 1.0f,-SQ2/2, 0.0f},
167
            { 1.0f, SQ2/2, 0.0f},
168
            { 0.0f,-SQ2/2,-1.0f},
169
            { 0.0f, SQ2/2,-1.0f},
170
            {-1.0f,-SQ2/2, 0.0f},
171
            {-1.0f, SQ2/2, 0.0f},
172
        };
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

    
177
  public Static4D getCubitQuats(int cubit, int[] numLayers)
178
    {
179
    switch(cubit)
180
      {
181
      case  0: return mObjectQuats[ 0];
182
      case  1: return mObjectQuats[10];
183

    
184
      case  2: return mObjectQuats[ 0];
185
      case  3: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
186
      case  4: return mObjectQuats[11];
187
      case  5: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
188

    
189
      case  6: return mObjectQuats[ 0];
190
      case  7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
191
      case  8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
192
      case  9: return mObjectQuats[10];
193
      case 10: return mObjectQuats[11];
194
      case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
195
      case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
196
      case 13: return mObjectQuats[ 9];
197
      }
198

    
199
    return null;
200
    }
201

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
  private float[][] getVertices(int variant)
205
    {
206
    if( variant==0 )
207
      {
208
      return new float[][] { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
209
      }
210
    else if( variant==1 )
211
      {
212
      return new float[][] { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
213
      }
214
    else
215
      {
216
      return new float[][] { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
217
      }
218
    }
219

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221

    
222
  public ObjectShape getObjectShape(int variant)
223
    {
224
    if( variant==0 )
225
      {
226
      int[][] indices = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
227
      return new ObjectShape(getVertices(variant), indices);
228
      }
229
    else if( variant==1 )
230
      {
231
      int[][] indices = { {4,3,1},{4,2,3},{2,0,3},{3,0,1},{1,0,4},{0,2,4} };
232
      return new ObjectShape(getVertices(variant), indices);
233
      }
234
    else
235
      {
236
      int[][] indices = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
237
      return new ObjectShape(getVertices(variant), indices);
238
      }
239
    }
240

    
241
///////////////////////////////////////////////////////////////////////////////////////////////////
242

    
243
  public ObjectFaceShape getObjectFaceShape(int variant)
244
    {
245
    if( variant==0 )
246
      {
247
      float h1 = isInIconMode() ? 0.001f : 0.05f;
248
      float h2 = isInIconMode() ? 0.001f : 0.01f;
249
      float[][] bands   = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
250
      int[] bandIndices = { 0,1,1,1,1 };
251
      return new ObjectFaceShape(bands,bandIndices,null);
252
      }
253
    else if( variant==1 )
254
      {
255
      float h1 = isInIconMode() ? 0.001f : 0.04f;
256
      float h2 = isInIconMode() ? 0.001f : 0.01f;
257
      float[][] bands   = { {h1,25,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
258
      int[] bandIndices = { 0,0,1,1,1,1 };
259
      return new ObjectFaceShape(bands,bandIndices,null);
260
      }
261
    else
262
      {
263
      float h1 = isInIconMode() ? 0.001f : 0.05f;
264
      float h2 = isInIconMode() ? 0.001f : 0.01f;
265
      float[][] bands   = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
266
      int[] bandIndices = { 0,1,1,1 };
267
      return new ObjectFaceShape(bands,bandIndices,null);
268
      }
269
    }
270

    
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

    
273
  public ObjectVertexEffects getVertexEffects(int variant)
274
    {
275
    if( variant==0 )
276
      {
277
      float[][] corners = { {0.03f,0.20f} };
278
      int[] indices     = { 0,0,0,0,-1 };
279
      float[][] centers = { { 0.0f, SQ2, 0.0f} };
280
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
281
      }
282
    else if( variant==1 )
283
      {
284
      float[][] corners = { {0.03f,0.20f} };
285
      int[] indices     = { -1,0,0,0,0 };
286
      float[][] centers = { {-1,0,1} };
287
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
288
      }
289
    else
290
      {
291
      float[][] corners = { {0.03f,0.20f} };
292
      int[] indices     = { 0,0,0,-1 };
293
      float[][] centers = { {0.0f, SQ2/2, -1.0f} };
294
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
295
      }
296
    }
297

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

    
300
  public int getNumCubitVariants(int[] numLayers)
301
    {
302
    return 3;
303
    }
304

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

    
307
  public int getCubitVariant(int cubit, int[] numLayers)
308
    {
309
    return cubit<2 ? 0 : (cubit<6 ? 1:2);
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  public float getStickerRadius()
315
    {
316
    return 0.10f;
317
    }
318

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

    
321
  public float getStickerStroke()
322
    {
323
    return isInIconMode() ? 0.20f : 0.06f;
324
    }
325

    
326
///////////////////////////////////////////////////////////////////////////////////////////////////
327

    
328
  public float[][] getStickerAngles()
329
    {
330
    return null;
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334
// PUBLIC API
335

    
336
  public Static3D[] getRotationAxis()
337
    {
338
    return ROT_AXIS;
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

    
343
  public int[][] getBasicAngles()
344
    {
345
    if( mBasicAngle ==null )
346
      {
347
      int num = getNumLayers()[0];
348
      int[] tmp = new int[num];
349
      for(int i=0; i<num; i++) tmp[i] = 3;
350
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
351
      }
352

    
353
    return mBasicAngle;
354
    }
355

    
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357

    
358
  public String getShortName()
359
    {
360
    return ObjectType.CONT_2.name();
361
    }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
  public ObjectSignature getSignature()
366
    {
367
    return new ObjectSignature(ObjectSignatures.CONT_2);
368
    }
369

    
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371

    
372
  public String getObjectName()
373
    {
374
    return "Container";
375
    }
376

    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378

    
379
  public String getInventor()
380
    {
381
    return "Tony Fisher";
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  public int getYearOfInvention()
387
    {
388
    return 1998;
389
    }
390

    
391
///////////////////////////////////////////////////////////////////////////////////////////////////
392

    
393
  public int getComplexity()
394
    {
395
    return 2;
396
    }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

    
400
  public String[][] getTutorials()
401
    {
402
    return new String[][] {
403
                          {"gb","THndZ2H7OO4","Container Cube Tutorial","SuperAntoniovivaldi"},
404
                          {"es","8K2PeCAcpNU","Tutorial Container Puzzle","GioMart"},
405
                          {"ru","rh3rMuESOIM","Как собрать Container cube","RubicsGuide"},
406
                          {"fr","V4lmnbLjUdc","Résolution du Container Cube","skieur cubb"},
407
                          {"de","TRJEIgcda0Y","Container Cube Tutorial","Pezcraft"},
408
                          {"pl","jdJpUc-LaKY","Container Cube TUTORIAL PL","MrUK"},
409
                          {"br","44JnUyGTAD8","Tutorial do Cubo Container","Cubo vicio"},
410
                          {"kr","6HJKHLxaIPk","컨테이너 큐브 해법 강좌","굿맨's 큐브 이야기"},
411
                          {"vn","RLD9srIrDcI","Tutorial N.97 - Container","Duy Thích Rubik"},
412
                         };
413
    }
414
}
(5-5/41)