Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMixup3x3Plus.java @ da5551f4

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import org.distorted.library.type.Static3D;
13
import org.distorted.library.type.Static4D;
14
import org.distorted.objectlib.helpers.FactoryCubit;
15
import org.distorted.objectlib.helpers.ObjectFaceShape;
16
import org.distorted.objectlib.helpers.ObjectShape;
17
import org.distorted.objectlib.signature.ObjectSignature;
18
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19
import org.distorted.objectlib.main.InitAssets;
20
import org.distorted.objectlib.main.InitData;
21
import org.distorted.objectlib.signature.ObjectConstants;
22
import org.distorted.objectlib.main.ObjectType;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
public class TwistyMixup3x3Plus extends TwistyMixup
27
{
28
  private static final float SHORT_EDGE = (6*SQ2-3)/14;
29
  private static final float LONG_EDGE  = (12-3*SQ2)/14;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  public TwistyMixup3x3Plus(int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
34
    {
35
    super(iconMode, quat, move, scale, data, asset);
36
    }
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
  public float[][] getCuts(int[] numLayers)
41
    {
42
    if( mCuts==null )
43
      {
44
      float[] cut = new float[] {-SHORT_EDGE,+SHORT_EDGE};
45
      mCuts = new float[][] { cut,cut,cut };
46
      }
47

    
48
    return mCuts;
49
    }
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  public float[][] getCubitPositions(int[] numLayers)
54
    {
55
    if( mPosition==null )
56
      {
57
      final float DIST_CORNER = LONG_EDGE+SHORT_EDGE;
58
      final float DIST_EDGE   = 1.5f*LONG_EDGE+SHORT_EDGE;
59
      final float DIST_CENTER = LONG_EDGE+SHORT_EDGE;
60
      final float DIST_SMALL  = 2.0f*LONG_EDGE+SHORT_EDGE;
61
      final float DIST        = 0.5f*LONG_EDGE+SHORT_EDGE;
62

    
63
      mPosition = new float[][]
64
         {
65
             { DIST_CORNER, DIST_CORNER, DIST_CORNER },
66
             { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
67
             { DIST_CORNER,-DIST_CORNER, DIST_CORNER },
68
             { DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
69
             {-DIST_CORNER, DIST_CORNER, DIST_CORNER },
70
             {-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
71
             {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
72
             {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
73

    
74
             {      0.0f, DIST_EDGE, DIST_EDGE },
75
             { DIST_EDGE,      0.0f, DIST_EDGE },
76
             {      0.0f,-DIST_EDGE, DIST_EDGE },
77
             {-DIST_EDGE,      0.0f, DIST_EDGE },
78
             { DIST_EDGE, DIST_EDGE,      0.0f },
79
             { DIST_EDGE,-DIST_EDGE,      0.0f },
80
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
81
             {-DIST_EDGE, DIST_EDGE,      0.0f },
82
             {      0.0f, DIST_EDGE,-DIST_EDGE },
83
             { DIST_EDGE,      0.0f,-DIST_EDGE },
84
             {      0.0f,-DIST_EDGE,-DIST_EDGE },
85
             {-DIST_EDGE,      0.0f,-DIST_EDGE },
86

    
87
             {           0,        DIST,  DIST_SMALL },
88
             {        DIST,           0,  DIST_SMALL },
89
             {           0,       -DIST,  DIST_SMALL },
90
             {       -DIST,           0,  DIST_SMALL },
91
             {           0,        DIST, -DIST_SMALL },
92
             {        DIST,           0, -DIST_SMALL },
93
             {           0,       -DIST, -DIST_SMALL },
94
             {       -DIST,           0, -DIST_SMALL },
95
             {           0,  DIST_SMALL,       -DIST },
96
             {        DIST,  DIST_SMALL,           0 },
97
             {           0,  DIST_SMALL,        DIST },
98
             {       -DIST,  DIST_SMALL,           0 },
99
             {           0, -DIST_SMALL,       -DIST },
100
             {        DIST, -DIST_SMALL,           0 },
101
             {           0, -DIST_SMALL,        DIST },
102
             {       -DIST, -DIST_SMALL,           0 },
103
             {  DIST_SMALL,        DIST,           0 },
104
             {  DIST_SMALL,           0,       -DIST },
105
             {  DIST_SMALL,       -DIST,           0 },
106
             {  DIST_SMALL,           0,        DIST },
107
             { -DIST_SMALL,        DIST,           0 },
108
             { -DIST_SMALL,           0,       -DIST },
109
             { -DIST_SMALL,       -DIST,           0 },
110
             { -DIST_SMALL,           0,        DIST },
111

    
112
             {           0,           0, DIST_CENTER },
113
             {           0,           0,-DIST_CENTER },
114
             {           0, DIST_CENTER,           0 },
115
             {           0,-DIST_CENTER,           0 },
116
             { DIST_CENTER,           0,           0 },
117
             {-DIST_CENTER,           0,           0 },
118
         };
119
      }
120

    
121
    return mPosition;
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  public Static4D getCubitQuats(int cubit, int[] numLayers)
127
    {
128
    if( mQuatIndex==null )
129
      {
130
      mQuatIndex = new int[] { 0,10,11,3,6,2,1,8,
131
                               0,4,11,5,7,12,13,6,10,20,3,18,
132
                               0,4,0,4, 3,15,3,15, 10,16,10,16, 11,19,11,19, 7,17,7,17, 6,18,6,18,
133
                               0,3,10,11,7,6 };
134
      }
135

    
136
    return mObjectQuats[mQuatIndex[cubit]];
137
    }
138

    
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140

    
141
  private float[][] getVertices(int variant)
142
    {
143
    if( variant==0 || variant==3 )
144
      {
145
      float X = variant==0 ? LONG_EDGE : SHORT_EDGE;
146
      float Y = variant==0 ? LONG_EDGE : SHORT_EDGE;
147
      float Z = LONG_EDGE;
148

    
149
      return new float[][]
150
          {
151
              { -X,-Y,-Z },
152
              { -X,-Y,+Z },
153
              { -X,+Y,-Z },
154
              { -X,+Y,+Z },
155
              { +X,-Y,-Z },
156
              { +X,-Y,+Z },
157
              { +X,+Y,-Z },
158
              { +X,+Y,+Z },
159
          };
160
      }
161
    else if( variant==1 )
162
      {
163
      float X = SHORT_EDGE;
164
      float Y = LONG_EDGE/2;
165
      float Z = LONG_EDGE/2;
166

    
167
      return new float[][]
168
          {
169
              { -X,+Y,+Z },
170
              { -X,+Y,-Z },
171
              { +X,+Y,-Z },
172
              { +X,+Y,+Z },
173
              { -X,-Y,+Z },
174
              { +X,-Y,+Z },
175
              { -X,-Y,-3*Z },
176
              { +X,-Y,-3*Z },
177
              { +X,-3*Y,-Z },
178
              { -X,-3*Y,-Z },
179
          };
180
      }
181
    else
182
      {
183
      float X = SHORT_EDGE;
184
      float Y = LONG_EDGE/2;
185

    
186
      return new float[][]
187
          {
188
              { -X,-Y, 0 },
189
              { -X,+Y, 0 },
190
              { +X,-Y, 0 },
191
              { +X,+Y, 0 },
192
              { -X, 0,-Y },
193
              { +X, 0,-Y }
194
          };
195
      }
196
    }
197

    
198
///////////////////////////////////////////////////////////////////////////////////////////////////
199

    
200
  public ObjectShape getObjectShape(int variant)
201
    {
202
    if( variant==0 || variant==3 )
203
      {
204
      int[][] indices =
205
          {
206
              {1,5,7,3},
207
              {3,7,6,2},
208
              {5,4,6,7},
209
              {0,1,3,2},
210
              {4,0,2,6},
211
              {0,4,5,1}
212
          };
213

    
214
      return new ObjectShape(getVertices(variant), indices);
215
      }
216
    else if( variant==1 )
217
      {
218
      int[][] indices =
219
          {
220
              {0,3,2,1},
221
              {4,5,3,0},
222
              {8,7,2,3,5},
223
              {6,9,4,0,1},
224
              {9,8,5,4},
225
              {7,6,1,2},
226
              {6,7,8,9}
227
          };
228

    
229
      return new ObjectShape(getVertices(variant), indices);
230
      }
231
    else
232
      {
233
      int[][] indices =
234
          {
235
              {0,2,3,1},
236
              {2,5,3},
237
              {1,4,0},
238
              {0,4,5,2},
239
              {3,5,4,1}
240
          };
241

    
242
      return new ObjectShape(getVertices(variant), indices);
243
      }
244
    }
245

    
246
///////////////////////////////////////////////////////////////////////////////////////////////////
247

    
248
  public ObjectFaceShape getObjectFaceShape(int variant)
249
    {
250
    float h1 = isInIconMode() ? 0.001f : 0.06f;
251
    float h2 = 0.001f;
252
    int angle = 25;
253
    float R = 0.7f;
254
    float S = 0.5f;
255
    float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0} };
256

    
257
    if( variant==0 )
258
      {
259
      int[] bandIndices = { 0,0,0,1,1,1 };
260
      return new ObjectFaceShape(bands,bandIndices,null);
261
      }
262
    if( variant==1 )
263
      {
264
      int[] bandIndices = { 0,0,1,1,1,1,1 };
265
      return new ObjectFaceShape(bands,bandIndices,null);
266
      }
267
    if( variant==2 )
268
      {
269
      int[] bandIndices = { 0,1,1,1,1 };
270
      return new ObjectFaceShape(bands,bandIndices,null);
271
      }
272
    else
273
      {
274
      int[] bandIndices = { 0,1,1,1,1,1 };
275
      return new ObjectFaceShape(bands,bandIndices,null);
276
      }
277
    }
278

    
279
///////////////////////////////////////////////////////////////////////////////////////////////////
280

    
281
  public ObjectVertexEffects getVertexEffects(int variant)
282
    {
283
    float[][] centers = { { 0.0f, 0.0f, 0.0f} };
284
    float[][] corners = { {0.04f,0.10f} };
285

    
286
    if( variant==0 )
287
      {
288
      int[] indices   = { -1,0,0,0,0,0,0,0 };
289
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
290
      }
291
    if( variant==1 )
292
      {
293
      int[] indices   = { 0,0,0,0,0,0,-1,-1,-1,-1 };
294
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
295
      }
296
    if( variant==2 )
297
      {
298
      int[] indices   = { 0,0,0,0,-1,-1 };
299
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
300
      }
301
    else
302
      {
303
      int[] indices   = { -1,0,-1,0,-1,0,-1,0 };
304
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
305
      }
306
    }
307

    
308
///////////////////////////////////////////////////////////////////////////////////////////////////
309

    
310
  public int getNumCubitVariants(int[] numLayers)
311
    {
312
    return 4;
313
    }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

    
317
  public int getCubitVariant(int cubit, int[] numLayers)
318
    {
319
    return cubit<8 ? 0 : (cubit<20 ? 1 : (cubit<44?2:3));
320
    }
321

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323
// PUBLIC API
324

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

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

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

    
334
  public ObjectSignature getSignature()
335
    {
336
    return new ObjectSignature(ObjectConstants.MIXP_3);
337
    }
338

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

    
341
  public String getObjectName()
342
    {
343
    return "Mixup Plus Cube";
344
    }
345

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

    
348
  public String getInventor()
349
    {
350
    return "Guan Yang";
351
    }
352

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

    
355
  public int getYearOfInvention()
356
    {
357
    return 2012;
358
    }
359

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

    
362
  public float getComplexity()
363
    {
364
    return 3.48f;
365
    }
366

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

    
369
  public String[][] getTutorials()
370
    {
371
    return new String[][]{
372
                          {"gb","0ABxlmD6AYQ","3x3 Mixup Plus Tutorial","Superantoniovivaldi"},
373
                          {"es","s19NAGbkbw4","Tutorial Mixup Plus 3x3x3","Kubekings"},
374
                          {"fr","QWsFaw0zUJU","Résolution du Mixup Plus","skieur cubb"},
375
                          {"ru","cdtK86ZeF2w","Как собрать Mixup plus 1/3","Иван Циков"},
376
                          {"ru","OHg0MfM2iEU","Как собрать Mixup plus 2/3","Иван Циков"},
377
                          {"ru","rtQoRAoMRS8","Как собрать Mixup plus 3/3","Иван Циков"},
378
                          {"pl","8Bm0LNsGfIs","Mixup 3x3x3 Plus TUTORIAL PL","MrUK"},
379
                          {"kr","80QKOZXGtBs","믹스업 플러스 (Mix-up Plus) 해법","듀나메스 큐브 해법연구소"},
380
                          {"vn","vuIfGk1Asmc","Tutorial N.206 - Mixup Plus","Duy Thích Rubik"},
381
                         };
382
    }
383
}
(37-37/57)