Project

General

Profile

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

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

1 0e161d26 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// 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 0e161d26 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12 7ec32155 Leszek Koltunski
import java.io.InputStream;
13
14 0e161d26 Leszek Koltunski
import org.distorted.library.type.Static3D;
15
import org.distorted.library.type.Static4D;
16 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
17 0e161d26 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
18
import org.distorted.objectlib.helpers.ObjectShape;
19 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
20 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
21 2dffaf22 Leszek Koltunski
import org.distorted.objectlib.main.ObjectSignatures;
22 9ba7f3f6 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
23 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
24 0e161d26 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
25 b31249d6 Leszek Koltunski
import org.distorted.objectlib.shape.ShapeHexahedron;
26 0e161d26 Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
27
28
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
29
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
30
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33
public class TwistyContainer extends ShapeHexahedron
34
{
35
  static final Static3D[] ROT_AXIS = new Static3D[]
36
         {
37
           new Static3D( SQ6/3,-SQ3/3,  0.0f),
38
           new Static3D( SQ6/3, SQ3/3,  0.0f),
39
           new Static3D(  0.0f,-SQ3/3, SQ6/3),
40
           new Static3D(  0.0f, SQ3/3, SQ6/3)
41
         };
42
43 9ba7f3f6 Leszek Koltunski
  private int[][] mEdges;
44 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
45 0e161d26 Leszek Koltunski
  private float[][] mCuts;
46 7ec32155 Leszek Koltunski
  private int[][] mFaceMap;
47 0e161d26 Leszek Koltunski
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49
50 a8295031 Leszek Koltunski
  public TwistyContainer(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
51 0e161d26 Leszek Koltunski
    {
52 a8295031 Leszek Koltunski
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
53 0e161d26 Leszek Koltunski
    }
54
55 7ec32155 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
56
// we want colorful insides
57
58
  @Override
59
  public int getCubitFaceMap(int cubit, int face)
60
    {
61
    if( mFaceMap==null )
62
      {
63
      mFaceMap = new int[][]
64
         {
65
             { 3, 3, 3, 3, 3, 3},
66
             { 2, 2, 2, 2, 2, 2},
67
68
             { 0, 5, 5, 0, 0, 5},
69
             { 5, 1, 1, 5, 5, 1},
70 dcce7b29 Leszek Koltunski
             { 1, 4, 4, 1, 1, 4},
71
             { 4, 0, 0, 4, 4, 0},
72 7ec32155 Leszek Koltunski
73
             { 4, 4, 4, 4, 4, 4},
74
             { 4, 4, 4, 4, 4, 4},
75
             { 0, 0, 0, 0, 0, 0},
76
             { 0, 0, 0, 0, 0, 0},
77
             { 5, 5, 5, 5, 5, 5},
78
             { 5, 5, 5, 5, 5, 5},
79
             { 1, 1, 1, 1, 1, 1},
80
             { 1, 1, 1, 1, 1, 1},
81
         };
82
      }
83
84
    return mFaceMap[cubit][face];
85
    }
86
87 0e161d26 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
88
89 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
90 0e161d26 Leszek Koltunski
    {
91 9ba7f3f6 Leszek Koltunski
    if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle);
92
    return mEdges;
93 0e161d26 Leszek Koltunski
    }
94
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
97
  public float[][] getCuts(int[] numLayers)
98
    {
99
    if( mCuts==null )
100
      {
101
      float[] c = {0};
102
      mCuts = new float[][] {c,c,c,c};
103
      }
104
105
    return mCuts;
106
    }
107
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109
110
  public boolean[][] getLayerRotatable(int[] numLayers)
111
    {
112
    boolean[] tmp = {true,true};
113
    return new boolean[][] { tmp,tmp,tmp,tmp };
114
    }
115
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
118
  public int getTouchControlType()
119
    {
120
    return TC_CHANGING_SHAPEMOD;
121
    }
122
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124
125
  public int getTouchControlSplit()
126
    {
127
    return TYPE_NOT_SPLIT;
128
    }
129
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131
132
  public int[][][] getEnabled()
133
    {
134
    return null;
135
    }
136
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138
139
  public float[] getDist3D(int[] numLayers)
140
    {
141
    return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
142
    }
143
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145
146
  public Static3D[] getFaceAxis()
147
    {
148
    return TouchControlHexahedron.FACE_AXIS;
149
    }
150
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152
153
  public float[][] getCubitPositions(int[] numLayers)
154
    {
155
    return new float[][]
156
        {
157
            { 0.0f,  -SQ2, 0.0f},
158 84a17011 Leszek Koltunski
            { 0.0f,   SQ2, 0.0f},
159 0e161d26 Leszek Koltunski
160
            { 1.0f,  0.0f,-1.0f},
161
            {-1.0f,  0.0f,-1.0f},
162 dcce7b29 Leszek Koltunski
            {-1.0f,  0.0f, 1.0f},
163
            { 1.0f,  0.0f, 1.0f},
164 0e161d26 Leszek Koltunski
165
            { 0.0f,-SQ2/2, 1.0f},
166 84a17011 Leszek Koltunski
            { 0.0f, SQ2/2, 1.0f},
167 0e161d26 Leszek Koltunski
            { 1.0f,-SQ2/2, 0.0f},
168
            { 1.0f, SQ2/2, 0.0f},
169
            { 0.0f,-SQ2/2,-1.0f},
170 84a17011 Leszek Koltunski
            { 0.0f, SQ2/2,-1.0f},
171 0e161d26 Leszek Koltunski
            {-1.0f,-SQ2/2, 0.0f},
172
            {-1.0f, SQ2/2, 0.0f},
173
        };
174
    }
175
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177
178
  public Static4D getCubitQuats(int cubit, int[] numLayers)
179
    {
180
    switch(cubit)
181
      {
182
      case  0: return mObjectQuats[ 0];
183
      case  1: return mObjectQuats[10];
184
185 dcce7b29 Leszek Koltunski
      case  2: return mObjectQuats[ 0];
186
      case  3: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
187
      case  4: return mObjectQuats[11];
188
      case  5: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
189 0e161d26 Leszek Koltunski
190
      case  6: return mObjectQuats[ 0];
191
      case  7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
192
      case  8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
193
      case  9: return mObjectQuats[10];
194
      case 10: return mObjectQuats[11];
195
      case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
196
      case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
197
      case 13: return mObjectQuats[ 9];
198
      }
199
200
    return null;
201
    }
202
203 84a17011 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
204
205
  private float[][] getVertices(int variant)
206
    {
207
    if( variant==0 )
208
      {
209
      return new float[][] { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
210
      }
211
    else if( variant==1 )
212
      {
213
      return new float[][] { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
214
      }
215
    else
216
      {
217
      return new float[][] { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
218
      }
219
    }
220
221 0e161d26 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
222
223
  public ObjectShape getObjectShape(int variant)
224
    {
225
    if( variant==0 )
226
      {
227 84a17011 Leszek Koltunski
      int[][] indices = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
228
      return new ObjectShape(getVertices(variant), indices);
229 0e161d26 Leszek Koltunski
      }
230
    else if( variant==1 )
231
      {
232 84a17011 Leszek Koltunski
      int[][] indices = { {4,3,1},{4,2,3},{2,0,3},{3,0,1},{1,0,4},{0,2,4} };
233
      return new ObjectShape(getVertices(variant), indices);
234 0e161d26 Leszek Koltunski
      }
235
    else
236
      {
237 84a17011 Leszek Koltunski
      int[][] indices = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
238
      return new ObjectShape(getVertices(variant), indices);
239 0e161d26 Leszek Koltunski
      }
240
    }
241
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243
244
  public ObjectFaceShape getObjectFaceShape(int variant)
245
    {
246
    if( variant==0 )
247
      {
248 3bf19410 Leszek Koltunski
      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 0e161d26 Leszek Koltunski
      int[] bandIndices = { 0,1,1,1,1 };
252 84a17011 Leszek Koltunski
      return new ObjectFaceShape(bands,bandIndices,null);
253 0e161d26 Leszek Koltunski
      }
254
    else if( variant==1 )
255
      {
256 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
257
      float h2 = isInIconMode() ? 0.001f : 0.01f;
258
      float[][] bands   = { {h1,25,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
259 0e161d26 Leszek Koltunski
      int[] bandIndices = { 0,0,1,1,1,1 };
260 84a17011 Leszek Koltunski
      return new ObjectFaceShape(bands,bandIndices,null);
261 0e161d26 Leszek Koltunski
      }
262
    else
263
      {
264 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.05f;
265
      float h2 = isInIconMode() ? 0.001f : 0.01f;
266
      float[][] bands   = { {h1,35,0.26f,0.7f,5,1,1}, {h2,15,0.1f,0.7f,5,1,1} };
267 0e161d26 Leszek Koltunski
      int[] bandIndices = { 0,1,1,1 };
268 84a17011 Leszek Koltunski
      return new ObjectFaceShape(bands,bandIndices,null);
269
      }
270
    }
271
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273
274
  public ObjectVertexEffects getVertexEffects(int variant)
275
    {
276
    if( variant==0 )
277
      {
278
      float[][] corners = { {0.03f,0.20f} };
279
      int[] indices     = { 0,0,0,0,-1 };
280
      float[][] centers = { { 0.0f, SQ2, 0.0f} };
281
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
282
      }
283
    else if( variant==1 )
284
      {
285
      float[][] corners = { {0.03f,0.20f} };
286
      int[] indices     = { -1,0,0,0,0 };
287
      float[][] centers = { {-1,0,1} };
288
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
289
      }
290
    else
291
      {
292 dae74fc9 Leszek Koltunski
      float[][] corners = { {0.03f,0.20f} };
293 0e161d26 Leszek Koltunski
      int[] indices     = { 0,0,0,-1 };
294
      float[][] centers = { {0.0f, SQ2/2, -1.0f} };
295 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
296 0e161d26 Leszek Koltunski
      }
297
    }
298
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300
301
  public int getNumCubitVariants(int[] numLayers)
302
    {
303
    return 3;
304
    }
305
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307
308
  public int getCubitVariant(int cubit, int[] numLayers)
309
    {
310
    return cubit<2 ? 0 : (cubit<6 ? 1:2);
311
    }
312
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314
315
  public float getStickerRadius()
316
    {
317 dae74fc9 Leszek Koltunski
    return 0.10f;
318 0e161d26 Leszek Koltunski
    }
319
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321
322
  public float getStickerStroke()
323
    {
324 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.06f;
325 0e161d26 Leszek Koltunski
    }
326
327
///////////////////////////////////////////////////////////////////////////////////////////////////
328
329
  public float[][] getStickerAngles()
330
    {
331
    return null;
332
    }
333
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335
// PUBLIC API
336
337
  public Static3D[] getRotationAxis()
338
    {
339
    return ROT_AXIS;
340
    }
341
342
///////////////////////////////////////////////////////////////////////////////////////////////////
343
344 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
345 0e161d26 Leszek Koltunski
    {
346 beee90ab Leszek Koltunski
    if( mBasicAngle ==null )
347
      {
348
      int num = getNumLayers()[0];
349
      int[] tmp = new int[num];
350
      for(int i=0; i<num; i++) tmp[i] = 3;
351
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
352
      }
353
354 0e161d26 Leszek Koltunski
    return mBasicAngle;
355
    }
356
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358
359 5f54927b Leszek Koltunski
  public String getShortName()
360 0e161d26 Leszek Koltunski
    {
361 5f54927b Leszek Koltunski
    return ObjectType.CONT_2.name();
362
    }
363
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365
366 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
367 5f54927b Leszek Koltunski
    {
368 2dffaf22 Leszek Koltunski
    return new ObjectSignature(ObjectSignatures.CONT_2);
369 0e161d26 Leszek Koltunski
    }
370
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372
373
  public String getObjectName()
374
    {
375
    return "Container";
376
    }
377
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379
380
  public String getInventor()
381
    {
382
    return "Tony Fisher";
383
    }
384
385
///////////////////////////////////////////////////////////////////////////////////////////////////
386
387
  public int getYearOfInvention()
388
    {
389
    return 1998;
390
    }
391
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393
394
  public int getComplexity()
395
    {
396
    return 2;
397
    }
398 052e0362 Leszek Koltunski
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400
401
  public String[][] getTutorials()
402
    {
403
    return new String[][] {
404
                          {"gb","THndZ2H7OO4","Container Cube Tutorial","SuperAntoniovivaldi"},
405
                          {"es","8K2PeCAcpNU","Tutorial Container Puzzle","GioMart"},
406
                          {"ru","rh3rMuESOIM","Как собрать Container cube","RubicsGuide"},
407
                          {"fr","V4lmnbLjUdc","Résolution du Container Cube","skieur cubb"},
408
                          {"de","TRJEIgcda0Y","Container Cube Tutorial","Pezcraft"},
409
                          {"pl","jdJpUc-LaKY","Container Cube TUTORIAL PL","MrUK"},
410
                          {"br","44JnUyGTAD8","Tutorial do Cubo Container","Cubo vicio"},
411
                          {"kr","6HJKHLxaIPk","컨테이너 큐브 해법 강좌","굿맨's 큐브 이야기"},
412 a399e91b Leszek Koltunski
                          {"vn","RLD9srIrDcI","Tutorial N.97 - Container","Duy Thích Rubik"},
413 052e0362 Leszek Koltunski
                         };
414
    }
415 0e161d26 Leszek Koltunski
}