Project

General

Profile

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

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

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