Project

General

Profile

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

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

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

    
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26
import org.distorted.objectlib.helpers.ObjectFaceShape;
27
import org.distorted.objectlib.helpers.ObjectShape;
28
import org.distorted.objectlib.scrambling.ScrambleState;
29
import org.distorted.objectlib.main.ObjectType;
30
import org.distorted.objectlib.main.ShapeHexahedron;
31
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
32

    
33
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
34
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
public class TwistyContainer extends ShapeHexahedron
39
{
40
  static final Static3D[] ROT_AXIS = new Static3D[]
41
         {
42
           new Static3D( SQ6/3,-SQ3/3,  0.0f),
43
           new Static3D( SQ6/3, SQ3/3,  0.0f),
44
           new Static3D(  0.0f,-SQ3/3, SQ6/3),
45
           new Static3D(  0.0f, SQ3/3, SQ6/3)
46
         };
47

    
48
  private ScrambleState[] mStates;
49
  private int[][] mBasicAngle;
50
  private float[][] mCuts;
51
  private int[][] mFaceMap;
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  public TwistyContainer(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
56
    {
57
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
// we want colorful insides
62

    
63
  @Override
64
  public int getCubitFaceMap(int cubit, int face)
65
    {
66
    if( mFaceMap==null )
67
      {
68
      mFaceMap = new int[][]
69
         {
70
             { 3, 3, 3, 3, 3, 3},
71
             { 2, 2, 2, 2, 2, 2},
72

    
73
             { 0, 5, 5, 0, 0, 5},
74
             { 5, 1, 1, 5, 5, 1},
75
             { 1, 4, 4, 1, 1, 4},
76
             { 4, 0, 0, 4, 4, 0},
77

    
78
             { 4, 4, 4, 4, 4, 4},
79
             { 4, 4, 4, 4, 4, 4},
80
             { 0, 0, 0, 0, 0, 0},
81
             { 0, 0, 0, 0, 0, 0},
82
             { 5, 5, 5, 5, 5, 5},
83
             { 5, 5, 5, 5, 5, 5},
84
             { 1, 1, 1, 1, 1, 1},
85
             { 1, 1, 1, 1, 1, 1},
86
         };
87
      }
88

    
89
    return mFaceMap[cubit][face];
90
    }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
  public ScrambleState[] getScrambleStates()
95
    {
96
    if( mStates==null )
97
      {
98
      int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
99

    
100
      mStates = new ScrambleState[]
101
        {
102
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
103
        };
104
      }
105

    
106
    return mStates;
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  public float[][] getCuts(int[] numLayers)
112
    {
113
    if( mCuts==null )
114
      {
115
      float[] c = {0};
116
      mCuts = new float[][] {c,c,c,c};
117
      }
118

    
119
    return mCuts;
120
    }
121

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

    
124
  public boolean[][] getLayerRotatable(int[] numLayers)
125
    {
126
    boolean[] tmp = {true,true};
127
    return new boolean[][] { tmp,tmp,tmp,tmp };
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
  public int getTouchControlType()
133
    {
134
    return TC_CHANGING_SHAPEMOD;
135
    }
136

    
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

    
139
  public int getTouchControlSplit()
140
    {
141
    return TYPE_NOT_SPLIT;
142
    }
143

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145

    
146
  public int[][][] getEnabled()
147
    {
148
    return null;
149
    }
150

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

    
153
  public float[] getDist3D(int[] numLayers)
154
    {
155
    return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
156
    }
157

    
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159

    
160
  public Static3D[] getFaceAxis()
161
    {
162
    return TouchControlHexahedron.FACE_AXIS;
163
    }
164

    
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166

    
167
  public float[][] getCubitPositions(int[] numLayers)
168
    {
169
    return new float[][]
170
        {
171
            { 0.0f,  -SQ2, 0.0f},
172
            { 0.0f,  +SQ2, 0.0f},
173

    
174
            { 1.0f,  0.0f,-1.0f},
175
            {-1.0f,  0.0f,-1.0f},
176
            {-1.0f,  0.0f, 1.0f},
177
            { 1.0f,  0.0f, 1.0f},
178

    
179
            { 0.0f,-SQ2/2, 1.0f},
180
            { 0.0f,+SQ2/2, 1.0f},
181
            { 1.0f,-SQ2/2, 0.0f},
182
            { 1.0f, SQ2/2, 0.0f},
183
            { 0.0f,-SQ2/2,-1.0f},
184
            { 0.0f,+SQ2/2,-1.0f},
185
            {-1.0f,-SQ2/2, 0.0f},
186
            {-1.0f, SQ2/2, 0.0f},
187
        };
188
    }
189

    
190
///////////////////////////////////////////////////////////////////////////////////////////////////
191

    
192
  public Static4D getCubitQuats(int cubit, int[] numLayers)
193
    {
194
    switch(cubit)
195
      {
196
      case  0: return mObjectQuats[ 0];
197
      case  1: return mObjectQuats[10];
198

    
199
      case  2: return mObjectQuats[ 0];
200
      case  3: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
201
      case  4: return mObjectQuats[11];
202
      case  5: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
203

    
204
      case  6: return mObjectQuats[ 0];
205
      case  7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
206
      case  8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
207
      case  9: return mObjectQuats[10];
208
      case 10: return mObjectQuats[11];
209
      case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
210
      case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
211
      case 13: return mObjectQuats[ 9];
212
      }
213

    
214
    return null;
215
    }
216

    
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218

    
219
  public ObjectShape getObjectShape(int variant)
220
    {
221
    if( variant==0 )
222
      {
223
      float[][] vertices= { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
224
      int[][] indices   = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
225
      return new ObjectShape(vertices, indices);
226
      }
227
    else if( variant==1 )
228
      {
229
      float[][] vertices= { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
230
      int[][] indices   = { {4,3,1},{4,2,3},{2,0,3},{3,0,1},{1,0,4},{0,2,4} };
231
      return new ObjectShape(vertices, indices);
232
      }
233
    else
234
      {
235
      float[][] vertices= { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
236
      int[][] indices   = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
237
      return new ObjectShape(vertices, 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
      float[][] corners = { {0.03f,0.20f} };
252
      int[] indices     = { 0,0,0,0,-1 };
253
      float[][] centers = { { 0.0f, SQ2, 0.0f} };
254
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
255
      }
256
    else if( variant==1 )
257
      {
258
      float h1 = isInIconMode() ? 0.001f : 0.04f;
259
      float h2 = isInIconMode() ? 0.001f : 0.01f;
260
      float[][] bands   = { {h1,25,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
261
      int[] bandIndices = { 0,0,1,1,1,1 };
262
      float[][] corners = { {0.03f,0.20f} };
263
      int[] indices     = { -1,0,0,0,0 };
264
      float[][] centers = { {-1,0,1} };
265
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
266
      }
267
    else
268
      {
269
      float h1 = isInIconMode() ? 0.001f : 0.05f;
270
      float h2 = isInIconMode() ? 0.001f : 0.01f;
271
      float[][] bands   = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
272
      int[] bandIndices = { 0,1,1,1 };
273
      float[][] corners = { {0.03f,0.20f} };
274
      int[] indices     = { 0,0,0,-1 };
275
      float[][] centers = { {0.0f, SQ2/2, -1.0f} };
276
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
277
      }
278
    }
279

    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281

    
282
  public int getNumCubitVariants(int[] numLayers)
283
    {
284
    return 3;
285
    }
286

    
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288

    
289
  public int getCubitVariant(int cubit, int[] numLayers)
290
    {
291
    return cubit<2 ? 0 : (cubit<6 ? 1:2);
292
    }
293

    
294
///////////////////////////////////////////////////////////////////////////////////////////////////
295

    
296
  public float getStickerRadius()
297
    {
298
    return 0.10f;
299
    }
300

    
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302

    
303
  public float getStickerStroke()
304
    {
305
    return isInIconMode() ? 0.20f : 0.06f;
306
    }
307

    
308
///////////////////////////////////////////////////////////////////////////////////////////////////
309

    
310
  public float[][] getStickerAngles()
311
    {
312
    return null;
313
    }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316
// PUBLIC API
317

    
318
  public Static3D[] getRotationAxis()
319
    {
320
    return ROT_AXIS;
321
    }
322

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

    
325
  public int[][] getBasicAngles()
326
    {
327
    if( mBasicAngle ==null )
328
      {
329
      int num = getNumLayers()[0];
330
      int[] tmp = new int[num];
331
      for(int i=0; i<num; i++) tmp[i] = 3;
332
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
333
      }
334

    
335
    return mBasicAngle;
336
    }
337

    
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339

    
340
  public String getShortName()
341
    {
342
    return ObjectType.CONT_2.name();
343
    }
344

    
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346

    
347
  public long getSignature()
348
    {
349
    return ObjectType.CONT_2.ordinal();
350
    }
351

    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353

    
354
  public String getObjectName()
355
    {
356
    return "Container";
357
    }
358

    
359
///////////////////////////////////////////////////////////////////////////////////////////////////
360

    
361
  public String getInventor()
362
    {
363
    return "Tony Fisher";
364
    }
365

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367

    
368
  public int getYearOfInvention()
369
    {
370
    return 1998;
371
    }
372

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

    
375
  public int getComplexity()
376
    {
377
    return 2;
378
    }
379

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381

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