Project

General

Profile

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

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

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.ObjectControl;
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, Static4D quat, Static3D move, float scale, InputStream stream)
57
    {
58
    super(numL, meshState, 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
             { 1, 4, 4, 1, 1, 4},
75
             { 4, 0, 0, 4, 4, 0},
76
             { 0, 5, 5, 0, 0, 5},
77
             { 5, 1, 1, 5, 5, 1},
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[11];
201
      case  3: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
202
      case  4: return mObjectQuats[ 0];
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[][] bands   = { {0.05f,35,0.26f,0.7f,5,1,1}, {0.01f,15,0.1f,0.7f,5,1,1} };
249
      int[] bandIndices = { 0,1,1,1,1 };
250
      float[][] corners = { {0.03f,0.20f} };
251
      int[] indices     = { 0,0,0,0,-1 };
252
      float[][] centers = { { 0.0f, SQ2, 0.0f} };
253
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
254
      }
255
    else if( variant==1 )
256
      {
257
      float[][] bands   = { {0.04f,25,0.26f,0.7f,5,1,1}, {0.01f,15,0.1f,0.7f,5,1,1} };
258
      int[] bandIndices = { 0,0,1,1,1,1 };
259
      float[][] corners = { {0.03f,0.20f} };
260
      int[] indices     = { -1,0,0,0,0 };
261
      float[][] centers = { {-1,0,1} };
262
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
263
      }
264
    else
265
      {
266
      float[][] bands   = { {0.05f,35,0.26f,0.7f,5,1,1}, {0.01f,15,0.1f,0.7f,5,1,1} };
267
      int[] bandIndices = { 0,1,1,1 };
268
      float[][] corners = { {0.03f,0.20f} };
269
      int[] indices     = { 0,0,0,-1 };
270
      float[][] centers = { {0.0f, SQ2/2, -1.0f} };
271
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
272
      }
273
    }
274

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276

    
277
  public int getNumCubitVariants(int[] numLayers)
278
    {
279
    return 3;
280
    }
281

    
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

    
284
  public int getCubitVariant(int cubit, int[] numLayers)
285
    {
286
    return cubit<2 ? 0 : (cubit<6 ? 1:2);
287
    }
288

    
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

    
291
  public float getStickerRadius()
292
    {
293
    return 0.10f;
294
    }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

    
298
  public float getStickerStroke()
299
    {
300
    return ObjectControl.isInIconMode() ? 0.20f : 0.06f;
301
    }
302

    
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304

    
305
  public float[][] getStickerAngles()
306
    {
307
    return null;
308
    }
309

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311
// PUBLIC API
312

    
313
  public Static3D[] getRotationAxis()
314
    {
315
    return ROT_AXIS;
316
    }
317

    
318
///////////////////////////////////////////////////////////////////////////////////////////////////
319

    
320
  public int[] getBasicAngles()
321
    {
322
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
323
    return mBasicAngle;
324
    }
325

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

    
328
  public String getShortName()
329
    {
330
    return ObjectType.CONT_2.name();
331
    }
332

    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

    
335
  public long getSignature()
336
    {
337
    return ObjectType.CONT_2.ordinal();
338
    }
339

    
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

    
342
  public String getObjectName()
343
    {
344
    return "Container";
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

    
349
  public String getInventor()
350
    {
351
    return "Tony Fisher";
352
    }
353

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  public int getYearOfInvention()
357
    {
358
    return 1998;
359
    }
360

    
361
///////////////////////////////////////////////////////////////////////////////////////////////////
362

    
363
  public int getComplexity()
364
    {
365
    return 2;
366
    }
367

    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369

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