Project

General

Profile

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

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

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.helpers.ObjectSignature;
29
import org.distorted.objectlib.scrambling.ScrambleState;
30
import org.distorted.objectlib.main.ObjectType;
31
import org.distorted.objectlib.main.ShapeHexahedron;
32
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
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
  private int[][] mFaceMap;
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

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

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62
// we want colorful insides
63

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

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

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

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

    
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

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

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

    
107
    return mStates;
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

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

    
120
    return mCuts;
121
    }
122

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

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

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

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

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

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

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

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

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

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

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

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

    
166
///////////////////////////////////////////////////////////////////////////////////////////////////
167

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

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

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

    
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192

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

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

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

    
215
    return null;
216
    }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

    
220
  public ObjectShape getObjectShape(int variant)
221
    {
222
    if( variant==0 )
223
      {
224
      float[][] vertices= { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
225
      int[][] indices   = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
226
      return new ObjectShape(vertices, indices);
227
      }
228
    else if( variant==1 )
229
      {
230
      float[][] vertices= { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
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(vertices, indices);
233
      }
234
    else
235
      {
236
      float[][] vertices= { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
237
      int[][] indices   = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
238
      return new ObjectShape(vertices, indices);
239
      }
240
    }
241

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

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

    
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

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

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

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

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

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

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

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

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

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

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317
// PUBLIC API
318

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

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

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

    
336
    return mBasicAngle;
337
    }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

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

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

    
348
  public ObjectSignature getSignature()
349
    {
350
    return new ObjectSignature(ObjectType.CONT_2);
351
    }
352

    
353
///////////////////////////////////////////////////////////////////////////////////////////////////
354

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

    
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361

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

    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368

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

    
374
///////////////////////////////////////////////////////////////////////////////////////////////////
375

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

    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382

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