Project

General

Profile

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

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

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.metadata.Metadata;
18
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19
import org.distorted.objectlib.main.InitAssets;
20
import org.distorted.objectlib.metadata.ListObjects;
21

    
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

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

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
  public TwistyMixup3x3Plus(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
32
    {
33
    super(iconMode, quat, move, scale, meta, asset);
34
    }
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

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

    
46
    return mCuts;
47
    }
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

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

    
61
      mPosition = new float[][]
62
         {
63
             { DIST_CORNER, DIST_CORNER, DIST_CORNER },
64
             { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
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

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

    
85
             {           0,        DIST,  DIST_SMALL },
86
             {        DIST,           0,  DIST_SMALL },
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_SMALL,       -DIST },
94
             {        DIST,  DIST_SMALL,           0 },
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
             {  DIST_SMALL,        DIST,           0 },
102
             {  DIST_SMALL,           0,       -DIST },
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

    
110
             {           0,           0, DIST_CENTER },
111
             {           0,           0,-DIST_CENTER },
112
             {           0, DIST_CENTER,           0 },
113
             {           0,-DIST_CENTER,           0 },
114
             { DIST_CENTER,           0,           0 },
115
             {-DIST_CENTER,           0,           0 },
116
         };
117
      }
118

    
119
    return mPosition;
120
    }
121

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

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

    
134
    return mObjectQuats[mQuatIndex[cubit]];
135
    }
136

    
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

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

    
147
      return new float[][]
148
          {
149
              { -X,-Y,-Z },
150
              { -X,-Y,+Z },
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
          };
158
      }
159
    else if( variant==1 )
160
      {
161
      float X = SHORT_EDGE;
162
      float Y = LONG_EDGE/2;
163
      float Z = LONG_EDGE/2;
164

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

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

    
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197

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

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

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

    
240
      return new ObjectShape(getVertices(variant), indices);
241
      }
242
    }
243

    
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

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

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

    
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

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

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

    
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

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

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

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

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321
// PUBLIC API
322

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

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

    
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331

    
332
  public String[][] getTutorials()
333
    {
334
    return new String[][]{
335
                          {"gb","0ABxlmD6AYQ","3x3 Mixup Plus Tutorial","Superantoniovivaldi"},
336
                          {"es","s19NAGbkbw4","Tutorial Mixup Plus 3x3x3","Kubekings"},
337
                          {"fr","QWsFaw0zUJU","Résolution du Mixup Plus","skieur cubb"},
338
                          {"ru","cdtK86ZeF2w","Как собрать Mixup plus 1/3","Иван Циков"},
339
                          {"ru","OHg0MfM2iEU","Как собрать Mixup plus 2/3","Иван Циков"},
340
                          {"ru","rtQoRAoMRS8","Как собрать Mixup plus 3/3","Иван Циков"},
341
                          {"pl","8Bm0LNsGfIs","Mixup 3x3x3 Plus TUTORIAL PL","MrUK"},
342
                          {"kr","80QKOZXGtBs","믹스업 플러스 (Mix-up Plus) 해법","듀나메스 큐브 해법연구소"},
343
                          {"vn","vuIfGk1Asmc","Tutorial N.206 - Mixup Plus","Duy Thích Rubik"},
344
                         };
345
    }
346
}
(37-37/59)