Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objectlib.objects;
21

    
22
import java.io.InputStream;
23

    
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26
import org.distorted.objectlib.helpers.ObjectFaceShape;
27
import org.distorted.objectlib.helpers.ObjectShape;
28
import org.distorted.objectlib.helpers.ObjectSignature;
29
import org.distorted.objectlib.main.InitData;
30
import org.distorted.objectlib.main.ObjectType;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class TwistyMixup3x3Plus extends TwistyMixup
35
{
36
  private static final float SHORT_EDGE = (6*SQ2-3)/14;
37
  private static final float LONG_EDGE  = (12-3*SQ2)/14;
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

    
41
  public TwistyMixup3x3Plus(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
42
    {
43
    super(data, meshState, iconMode, quat, move, scale, stream);
44
    }
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

    
48
  public float[][] getCuts(int[] numLayers)
49
    {
50
    if( mCuts==null )
51
      {
52
      float[] cut = new float[] {-SHORT_EDGE,+SHORT_EDGE};
53
      mCuts = new float[][] { cut,cut,cut };
54
      }
55

    
56
    return mCuts;
57
    }
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

    
61
  public float[][] getCubitPositions(int[] numLayers)
62
    {
63
    if( mPosition==null )
64
      {
65
      final float DIST_CORNER = LONG_EDGE+SHORT_EDGE;
66
      final float DIST_EDGE   = 1.5f*LONG_EDGE+SHORT_EDGE;
67
      final float DIST_CENTER = LONG_EDGE+SHORT_EDGE;
68
      final float DIST_SMALL  = 2.0f*LONG_EDGE+SHORT_EDGE;
69
      final float DIST        = 0.5f*LONG_EDGE+SHORT_EDGE;
70

    
71
      mPosition = new float[][]
72
         {
73
             { DIST_CORNER, DIST_CORNER, DIST_CORNER },
74
             { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
75
             { DIST_CORNER,-DIST_CORNER, DIST_CORNER },
76
             { DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
77
             {-DIST_CORNER, DIST_CORNER, DIST_CORNER },
78
             {-DIST_CORNER, DIST_CORNER,-DIST_CORNER },
79
             {-DIST_CORNER,-DIST_CORNER, DIST_CORNER },
80
             {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER },
81

    
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
             { DIST_EDGE, DIST_EDGE,      0.0f },
87
             { DIST_EDGE,-DIST_EDGE,      0.0f },
88
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
89
             {-DIST_EDGE, DIST_EDGE,      0.0f },
90
             {      0.0f, DIST_EDGE,-DIST_EDGE },
91
             { DIST_EDGE,      0.0f,-DIST_EDGE },
92
             {      0.0f,-DIST_EDGE,-DIST_EDGE },
93
             {-DIST_EDGE,      0.0f,-DIST_EDGE },
94

    
95
             {           0,        DIST,  DIST_SMALL },
96
             {        DIST,           0,  DIST_SMALL },
97
             {           0,       -DIST,  DIST_SMALL },
98
             {       -DIST,           0,  DIST_SMALL },
99
             {           0,        DIST, -DIST_SMALL },
100
             {        DIST,           0, -DIST_SMALL },
101
             {           0,       -DIST, -DIST_SMALL },
102
             {       -DIST,           0, -DIST_SMALL },
103
             {           0,  DIST_SMALL,       -DIST },
104
             {        DIST,  DIST_SMALL,           0 },
105
             {           0,  DIST_SMALL,        DIST },
106
             {       -DIST,  DIST_SMALL,           0 },
107
             {           0, -DIST_SMALL,       -DIST },
108
             {        DIST, -DIST_SMALL,           0 },
109
             {           0, -DIST_SMALL,        DIST },
110
             {       -DIST, -DIST_SMALL,           0 },
111
             {  DIST_SMALL,        DIST,           0 },
112
             {  DIST_SMALL,           0,       -DIST },
113
             {  DIST_SMALL,       -DIST,           0 },
114
             {  DIST_SMALL,           0,        DIST },
115
             { -DIST_SMALL,        DIST,           0 },
116
             { -DIST_SMALL,           0,       -DIST },
117
             { -DIST_SMALL,       -DIST,           0 },
118
             { -DIST_SMALL,           0,        DIST },
119

    
120
             {           0,           0, DIST_CENTER },
121
             {           0,           0,-DIST_CENTER },
122
             {           0, DIST_CENTER,           0 },
123
             {           0,-DIST_CENTER,           0 },
124
             { DIST_CENTER,           0,           0 },
125
             {-DIST_CENTER,           0,           0 },
126
         };
127
      }
128

    
129
    return mPosition;
130
    }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

    
134
  public Static4D getCubitQuats(int cubit, int[] numLayers)
135
    {
136
    if( mQuatIndex==null )
137
      {
138
      mQuatIndex = new int[] { 0,10,11,3,6,2,1,8,
139
                               0,4,11,5,7,12,13,6,10,20,3,18,
140
                               0,4,0,4, 3,15,3,15, 10,16,10,16, 11,19,11,19, 7,17,7,17, 6,18,6,18,
141
                               0,3,10,11,7,6 };
142
      }
143

    
144
    return mObjectQuats[mQuatIndex[cubit]];
145
    }
146

    
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148

    
149
  public ObjectShape getObjectShape(int variant)
150
    {
151
    if( variant==0 || variant==3 )
152
      {
153
      float X = variant==0 ? LONG_EDGE : SHORT_EDGE;
154
      float Y = variant==0 ? LONG_EDGE : SHORT_EDGE;
155
      float Z = LONG_EDGE;
156

    
157
      float[][] vertices =
158
          {
159
              { -X,-Y,-Z },
160
              { -X,-Y,+Z },
161
              { -X,+Y,-Z },
162
              { -X,+Y,+Z },
163
              { +X,-Y,-Z },
164
              { +X,-Y,+Z },
165
              { +X,+Y,-Z },
166
              { +X,+Y,+Z },
167
          };
168

    
169
      int[][] indices =
170
          {
171
              {1,5,7,3},
172
              {3,7,6,2},
173
              {5,4,6,7},
174
              {0,1,3,2},
175
              {4,0,2,6},
176
              {0,4,5,1}
177
          };
178

    
179
      return new ObjectShape(vertices, indices);
180
      }
181
    else if( variant==1 )
182
      {
183
      float X = SHORT_EDGE;
184
      float Y = LONG_EDGE/2;
185
      float Z = LONG_EDGE/2;
186

    
187
      float[][] vertices =
188
          {
189
              { -X,+Y,+Z },
190
              { -X,+Y,-Z },
191
              { +X,+Y,-Z },
192
              { +X,+Y,+Z },
193
              { -X,-Y,+Z },
194
              { +X,-Y,+Z },
195
              { -X,-Y,-3*Z },
196
              { +X,-Y,-3*Z },
197
              { +X,-3*Y,-Z },
198
              { -X,-3*Y,-Z },
199
          };
200

    
201
      int[][] indices =
202
          {
203
              {0,3,2,1},
204
              {4,5,3,0},
205
              {8,7,2,3,5},
206
              {6,9,4,0,1},
207
              {9,8,5,4},
208
              {7,6,1,2},
209
              {6,7,8,9}
210
          };
211

    
212
      return new ObjectShape(vertices, indices);
213
      }
214
    else
215
      {
216
      float X = SHORT_EDGE;
217
      float Y = LONG_EDGE/2;
218

    
219
      float[][] vertices =
220
          {
221
              { -X,-Y, 0 },
222
              { -X,+Y, 0 },
223
              { +X,-Y, 0 },
224
              { +X,+Y, 0 },
225
              { -X, 0,-Y },
226
              { +X, 0,-Y }
227
          };
228

    
229
      int[][] indices =
230
          {
231
              {0,2,3,1},
232
              {2,5,3},
233
              {1,4,0},
234
              {0,4,5,2},
235
              {3,5,4,1}
236
          };
237

    
238
      return new ObjectShape(vertices, indices);
239
      }
240
    }
241

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

    
244
  public ObjectFaceShape getObjectFaceShape(int variant)
245
    {
246
    float h1 = isInIconMode() ? 0.001f : 0.06f;
247
    float h2 = 0.001f;
248
    float[][] bands   = { {h1,45,0.3f,0.5f,5,1,0}, {h2,45,0.3f,0.5f,5,1,0} };
249
    float[][] centers = { { 0.0f, 0.0f, 0.0f} };
250
    float[][] corners = { {0.04f,0.10f} };
251

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

    
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279

    
280
  public int getNumCubitVariants(int[] numLayers)
281
    {
282
    return 4;
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  public int getCubitVariant(int cubit, int[] numLayers)
288
    {
289
    return cubit<8 ? 0 : (cubit<20 ? 1 : (cubit<44?2:3));
290
    }
291

    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293
// PUBLIC API
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

    
297
  public String getShortName()
298
    {
299
    return ObjectType.MIXP_3.name();
300
    }
301

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

    
304
  public ObjectSignature getSignature()
305
    {
306
    return new ObjectSignature(ObjectType.MIXP_3);
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

    
311
  public String getObjectName()
312
    {
313
    return "Mixup Plus Cube";
314
    }
315

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

    
318
  public String getInventor()
319
    {
320
    return "Guan Yang";
321
    }
322

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

    
325
  public int getYearOfInvention()
326
    {
327
    return 2012;
328
    }
329

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

    
332
  public int getComplexity()
333
    {
334
    return 3;
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

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