Project

General

Profile

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

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

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