Project

General

Profile

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

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

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 java.io.InputStream;
13

    
14
import org.distorted.library.type.Static3D;
15
import org.distorted.library.type.Static4D;
16
import org.distorted.objectlib.helpers.ObjectFaceShape;
17
import org.distorted.objectlib.helpers.ObjectShape;
18
import org.distorted.objectlib.helpers.ObjectSignature;
19
import org.distorted.objectlib.main.InitData;
20
import org.distorted.objectlib.scrambling.ScrambleState;
21
import org.distorted.objectlib.main.ObjectType;
22
import org.distorted.objectlib.main.ShapeHexahedron;
23
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
24

    
25
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
26
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
27

    
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

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

    
40
  private ScrambleState[] mStates;
41
  private int[][] mBasicAngle;
42
  private float[][] mCuts;
43
  private int[][] mFaceMap;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  public TwistyContainer(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
48
    {
49
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53
// we want colorful insides
54

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

    
65
             { 0, 5, 5, 0, 0, 5},
66
             { 5, 1, 1, 5, 5, 1},
67
             { 1, 4, 4, 1, 1, 4},
68
             { 4, 0, 0, 4, 4, 0},
69

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

    
81
    return mFaceMap[cubit][face];
82
    }
83

    
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85

    
86
  public ScrambleState[] getScrambleStates()
87
    {
88
    if( mStates==null )
89
      {
90
      int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
91

    
92
      mStates = new ScrambleState[]
93
        {
94
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
95
        };
96
      }
97

    
98
    return mStates;
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public float[][] getCuts(int[] numLayers)
104
    {
105
    if( mCuts==null )
106
      {
107
      float[] c = {0};
108
      mCuts = new float[][] {c,c,c,c};
109
      }
110

    
111
    return mCuts;
112
    }
113

    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

    
116
  public boolean[][] getLayerRotatable(int[] numLayers)
117
    {
118
    boolean[] tmp = {true,true};
119
    return new boolean[][] { tmp,tmp,tmp,tmp };
120
    }
121

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

    
124
  public int getTouchControlType()
125
    {
126
    return TC_CHANGING_SHAPEMOD;
127
    }
128

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

    
131
  public int getTouchControlSplit()
132
    {
133
    return TYPE_NOT_SPLIT;
134
    }
135

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

    
138
  public int[][][] getEnabled()
139
    {
140
    return null;
141
    }
142

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

    
145
  public float[] getDist3D(int[] numLayers)
146
    {
147
    return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
148
    }
149

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

    
152
  public Static3D[] getFaceAxis()
153
    {
154
    return TouchControlHexahedron.FACE_AXIS;
155
    }
156

    
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158

    
159
  public float[][] getCubitPositions(int[] numLayers)
160
    {
161
    return new float[][]
162
        {
163
            { 0.0f,  -SQ2, 0.0f},
164
            { 0.0f,  +SQ2, 0.0f},
165

    
166
            { 1.0f,  0.0f,-1.0f},
167
            {-1.0f,  0.0f,-1.0f},
168
            {-1.0f,  0.0f, 1.0f},
169
            { 1.0f,  0.0f, 1.0f},
170

    
171
            { 0.0f,-SQ2/2, 1.0f},
172
            { 0.0f,+SQ2/2, 1.0f},
173
            { 1.0f,-SQ2/2, 0.0f},
174
            { 1.0f, SQ2/2, 0.0f},
175
            { 0.0f,-SQ2/2,-1.0f},
176
            { 0.0f,+SQ2/2,-1.0f},
177
            {-1.0f,-SQ2/2, 0.0f},
178
            {-1.0f, SQ2/2, 0.0f},
179
        };
180
    }
181

    
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183

    
184
  public Static4D getCubitQuats(int cubit, int[] numLayers)
185
    {
186
    switch(cubit)
187
      {
188
      case  0: return mObjectQuats[ 0];
189
      case  1: return mObjectQuats[10];
190

    
191
      case  2: return mObjectQuats[ 0];
192
      case  3: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
193
      case  4: return mObjectQuats[11];
194
      case  5: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
195

    
196
      case  6: return mObjectQuats[ 0];
197
      case  7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
198
      case  8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
199
      case  9: return mObjectQuats[10];
200
      case 10: return mObjectQuats[11];
201
      case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
202
      case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
203
      case 13: return mObjectQuats[ 9];
204
      }
205

    
206
    return null;
207
    }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  public ObjectShape getObjectShape(int variant)
212
    {
213
    if( variant==0 )
214
      {
215
      float[][] vertices= { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
216
      int[][] indices   = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
217
      return new ObjectShape(vertices, indices);
218
      }
219
    else if( variant==1 )
220
      {
221
      float[][] vertices= { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
222
      int[][] indices   = { {4,3,1},{4,2,3},{2,0,3},{3,0,1},{1,0,4},{0,2,4} };
223
      return new ObjectShape(vertices, indices);
224
      }
225
    else
226
      {
227
      float[][] vertices= { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
228
      int[][] indices   = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
229
      return new ObjectShape(vertices, indices);
230
      }
231
    }
232

    
233
///////////////////////////////////////////////////////////////////////////////////////////////////
234

    
235
  public ObjectFaceShape getObjectFaceShape(int variant)
236
    {
237
    if( variant==0 )
238
      {
239
      float h1 = isInIconMode() ? 0.001f : 0.05f;
240
      float h2 = isInIconMode() ? 0.001f : 0.01f;
241
      float[][] bands   = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
242
      int[] bandIndices = { 0,1,1,1,1 };
243
      float[][] corners = { {0.03f,0.20f} };
244
      int[] indices     = { 0,0,0,0,-1 };
245
      float[][] centers = { { 0.0f, SQ2, 0.0f} };
246
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
247
      }
248
    else if( variant==1 )
249
      {
250
      float h1 = isInIconMode() ? 0.001f : 0.04f;
251
      float h2 = isInIconMode() ? 0.001f : 0.01f;
252
      float[][] bands   = { {h1,25,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
253
      int[] bandIndices = { 0,0,1,1,1,1 };
254
      float[][] corners = { {0.03f,0.20f} };
255
      int[] indices     = { -1,0,0,0,0 };
256
      float[][] centers = { {-1,0,1} };
257
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
258
      }
259
    else
260
      {
261
      float h1 = isInIconMode() ? 0.001f : 0.05f;
262
      float h2 = isInIconMode() ? 0.001f : 0.01f;
263
      float[][] bands   = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
264
      int[] bandIndices = { 0,1,1,1 };
265
      float[][] corners = { {0.03f,0.20f} };
266
      int[] indices     = { 0,0,0,-1 };
267
      float[][] centers = { {0.0f, SQ2/2, -1.0f} };
268
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
269
      }
270
    }
271

    
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273

    
274
  public int getNumCubitVariants(int[] numLayers)
275
    {
276
    return 3;
277
    }
278

    
279
///////////////////////////////////////////////////////////////////////////////////////////////////
280

    
281
  public int getCubitVariant(int cubit, int[] numLayers)
282
    {
283
    return cubit<2 ? 0 : (cubit<6 ? 1:2);
284
    }
285

    
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287

    
288
  public float getStickerRadius()
289
    {
290
    return 0.10f;
291
    }
292

    
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294

    
295
  public float getStickerStroke()
296
    {
297
    return isInIconMode() ? 0.20f : 0.06f;
298
    }
299

    
300
///////////////////////////////////////////////////////////////////////////////////////////////////
301

    
302
  public float[][] getStickerAngles()
303
    {
304
    return null;
305
    }
306

    
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308
// PUBLIC API
309

    
310
  public Static3D[] getRotationAxis()
311
    {
312
    return ROT_AXIS;
313
    }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

    
317
  public int[][] getBasicAngles()
318
    {
319
    if( mBasicAngle ==null )
320
      {
321
      int num = getNumLayers()[0];
322
      int[] tmp = new int[num];
323
      for(int i=0; i<num; i++) tmp[i] = 3;
324
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
325
      }
326

    
327
    return mBasicAngle;
328
    }
329

    
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331

    
332
  public String getShortName()
333
    {
334
    return ObjectType.CONT_2.name();
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

    
339
  public ObjectSignature getSignature()
340
    {
341
    return new ObjectSignature(ObjectType.CONT_2);
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  public String getObjectName()
347
    {
348
    return "Container";
349
    }
350

    
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352

    
353
  public String getInventor()
354
    {
355
    return "Tony Fisher";
356
    }
357

    
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

    
360
  public int getYearOfInvention()
361
    {
362
    return 1998;
363
    }
364

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

    
367
  public int getComplexity()
368
    {
369
    return 2;
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

    
374
  public String[][] getTutorials()
375
    {
376
    return new String[][] {
377
                          {"gb","THndZ2H7OO4","Container Cube Tutorial","SuperAntoniovivaldi"},
378
                          {"es","8K2PeCAcpNU","Tutorial Container Puzzle","GioMart"},
379
                          {"ru","rh3rMuESOIM","Как собрать Container cube","RubicsGuide"},
380
                          {"fr","V4lmnbLjUdc","Résolution du Container Cube","skieur cubb"},
381
                          {"de","TRJEIgcda0Y","Container Cube Tutorial","Pezcraft"},
382
                          {"pl","jdJpUc-LaKY","Container Cube TUTORIAL PL","MrUK"},
383
                          {"br","44JnUyGTAD8","Tutorial do Cubo Container","Cubo vicio"},
384
                          {"kr","6HJKHLxaIPk","컨테이너 큐브 해법 강좌","굿맨's 큐브 이야기"},
385
                          {"vn","RLD9srIrDcI","Tutorial N.97 - Container","Duy Thích Rubik"},
386
                         };
387
    }
388
}
(3-3/36)