Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMixup3x3.java @ ccd8a6f2

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.InitData;
20
import org.distorted.objectlib.main.ObjectSignatures;
21
import org.distorted.objectlib.main.ObjectType;
22

    
23
import java.io.InputStream;
24

    
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

    
27
public class TwistyMixup3x3 extends TwistyMixup
28
{
29
  private static final float SHORT_EDGE = 1.5f-0.75f*SQ2;
30
  private static final float LONG_EDGE  = 1.5f*(SQ2-1);
31

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

    
34
  public TwistyMixup3x3(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
35
    {
36
    super(data, meshState, iconMode, quat, move, scale, stream);
37
    }
38

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

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

    
49
    return mCuts;
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  public float[][] getCubitPositions(int[] numLayers)
55
    {
56
    if( mPosition==null )
57
      {
58
      final float DIST_CORNER = LONG_EDGE+SHORT_EDGE;
59
      final float DIST_EDGE   = LONG_EDGE+SHORT_EDGE;
60
      final float DIST_CENTER = LONG_EDGE+SHORT_EDGE;
61

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

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

    
86
             {           0,           0, DIST_CENTER },
87
             {           0,           0,-DIST_CENTER },
88
             {           0, DIST_CENTER,           0 },
89
             {           0,-DIST_CENTER,           0 },
90
             { DIST_CENTER,           0,           0 },
91
             {-DIST_CENTER,           0,           0 },
92
         };
93
      }
94

    
95
    return mPosition;
96
    }
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  public Static4D getCubitQuats(int cubit, int[] numLayers)
101
    {
102
    if( mQuatIndex==null )
103
      {
104
      mQuatIndex = new int[] { 0,10,11,3,6,2,1,8,
105
                               0,4,11,5,7,12,13,6,10,20,3,18,
106
                               0,3,10,11,7,6 };
107
      }
108

    
109
    return mObjectQuats[mQuatIndex[cubit]];
110
    }
111

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  private float[][] getVertices(int variant)
115
    {
116
    float X = variant==0 ? SHORT_EDGE : LONG_EDGE;
117
    float Y = variant<=1 ? SHORT_EDGE : LONG_EDGE;
118
    float Z = SHORT_EDGE;
119

    
120
    return new float[][]
121
          {
122
              { -X,-Y,-Z },
123
              { -X,-Y,+Z },
124
              { -X,+Y,-Z },
125
              { -X,+Y,+Z },
126
              { +X,-Y,-Z },
127
              { +X,-Y,+Z },
128
              { +X,+Y,-Z },
129
              { +X,+Y,+Z },
130
          };
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  public ObjectShape getObjectShape(int variant)
136
    {
137
    int[][] indices =
138
          {
139
              {1,5,7,3},
140
              {3,7,6,2},
141
              {5,4,6,7},
142
              {0,1,3,2},
143
              {4,0,2,6},
144
              {0,4,5,1}
145
          };
146

    
147
    return new ObjectShape(getVertices(variant), indices);
148
    }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

    
152
  public ObjectFaceShape getObjectFaceShape(int variant)
153
    {
154
    float h1 = isInIconMode() ? 0.001f : 0.06f;
155
    float h2 = 0.001f;
156
    float[][] bands = { {h1,45,0.3f,0.5f,5,1,0}, {h2,45,0.3f,0.5f,5,1,0} };
157

    
158
    if( variant==0 )
159
      {
160
      int[] indices = { 0,0,0,1,1,1 };
161
      return new ObjectFaceShape(bands,indices,null);
162
      }
163
    if( variant==1 )
164
      {
165
      int[] indices = { 0,0,1,1,1,1 };
166
      return new ObjectFaceShape(bands,indices,null);
167
      }
168
    else
169
      {
170
      int[] indices = { 0,1,1,1,1,1 };
171
      return new ObjectFaceShape(bands,indices,null);
172
      }
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

    
177
  public ObjectVertexEffects getVertexEffects(int variant)
178
    {
179
    float[][] centers = { { 0.0f, 0.0f, 0.0f} };
180
    float[][] corners = { {0.04f,0.10f} };
181

    
182
    if( variant==0 )
183
      {
184
      int[] indices = { -1,0,0,0,0,0,0,0 };
185
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
186
      }
187
    if( variant==1 )
188
      {
189
      int[] indices = { -1,0,0,0,-1,0,0,0 };
190
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
191
      }
192
    else
193
      {
194
      int[] indices = { -1,0,-1,0,-1,0,-1,0 };
195
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
196
      }
197
    }
198

    
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200

    
201
  public int getNumCubitVariants(int[] numLayers)
202
    {
203
    return 3;
204
    }
205

    
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

    
208
  public int getCubitVariant(int cubit, int[] numLayers)
209
    {
210
    return cubit<8 ? 0 : (cubit<20?1:2);
211
    }
212

    
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214
// PUBLIC API
215

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

    
218
  public String getShortName()
219
    {
220
    return ObjectType.MIXU_3.name();
221
    }
222

    
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224

    
225
  public ObjectSignature getSignature()
226
    {
227
    return new ObjectSignature(ObjectSignatures.MIXU_3);
228
    }
229

    
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231

    
232
  public String getObjectName()
233
    {
234
    return "Mixup Cube";
235
    }
236

    
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

    
239
  public String getInventor()
240
    {
241
    return "Sergey Makarov";
242
    }
243

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

    
246
  public int getYearOfInvention()
247
    {
248
    return 1985;
249
    }
250

    
251
///////////////////////////////////////////////////////////////////////////////////////////////////
252

    
253
  public int getComplexity()
254
    {
255
    return 2;
256
    }
257

    
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259

    
260
  public String[][] getTutorials()
261
    {
262
    return new String[][]{
263
                          {"gb","w0DmJYwNI3Q","How to Solve the Mixup Cube","Z3"},
264
                          {"es","wHyf1imdAi4","Resolver Mixup 3x3","Cuby"},
265
                          {"ru","PN2ntFP6sfs","Как собрать Mixup","Цель+Действие=Результат"},
266
                          {"fr","QWsFaw0zUJU","Résolution du Mixup Cube","skieur cubb"},
267
                          {"de","vvDPyByyLyQ","Lösung für den 3x3x3 Mixup Cube","rofrisch"},
268
                          {"pl","TpG6MzWmwLQ","Mixup 3x3x3 Cube Tutorial","MrUK"},
269
                          {"br","_63j3i4Xa78","3x3 Mixup cube Tutorial 1/3","Cubo vicio"},
270
                          {"br","qpTnQavPLEI","3x3 Mixup cube Tutorial 2/3","Cubo vicio"},
271
                          {"br","nrFEm1ygcV4","3x3 Mixup cube Tutorial 3/3","Cubo vicio"},
272
                          {"kr","Ag4XkmC2v6c","3x3x3 믹스업 (Mix-up) 큐브 해법","듀나메스 큐브 해법연구소"},
273
                          {"vn","mWW6HYbvvh8","Mixup 3x3 Tutorial","VĂN CÔNG TÙNG"},
274
                         };
275
    }
276
}
(24-24/41)