Project

General

Profile

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

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

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.helpers.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.main.ObjectSignatures;
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 meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
34
    {
35
    super(meshState, 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
    float[][] bands = { {h1,45,0.3f,0.5f,5,1,0}, {h2,45,0.3f,0.5f,5,1,0} };
253

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

    
276
///////////////////////////////////////////////////////////////////////////////////////////////////
277

    
278
  public ObjectVertexEffects getVertexEffects(int variant)
279
    {
280
    float[][] centers = { { 0.0f, 0.0f, 0.0f} };
281
    float[][] corners = { {0.04f,0.10f} };
282

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

    
305
///////////////////////////////////////////////////////////////////////////////////////////////////
306

    
307
  public int getNumCubitVariants(int[] numLayers)
308
    {
309
    return 4;
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

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

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320
// PUBLIC API
321

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323

    
324
  public String getShortName()
325
    {
326
    return ObjectType.MIXP_3.name();
327
    }
328

    
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330

    
331
  public ObjectSignature getSignature()
332
    {
333
    return new ObjectSignature(ObjectSignatures.MIXP_3);
334
    }
335

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

    
338
  public String getObjectName()
339
    {
340
    return "Mixup Plus Cube";
341
    }
342

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

    
345
  public String getInventor()
346
    {
347
    return "Guan Yang";
348
    }
349

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351

    
352
  public int getYearOfInvention()
353
    {
354
    return 2012;
355
    }
356

    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

    
359
  public int getComplexity()
360
    {
361
    return 3;
362
    }
363

    
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365

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