Project

General

Profile

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

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

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 org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.helpers.ObjectFaceShape;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.helpers.ObjectSignature;
27
import org.distorted.objectlib.main.ObjectType;
28

    
29
import java.io.InputStream;
30

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

    
33
public class TwistyMixup3x3 extends TwistyMixup
34
{
35
  private static final float SHORT_EDGE = 1.5f-0.75f*SQ2;
36
  private static final float LONG_EDGE  = 1.5f*(SQ2-1);
37

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

    
40
  public TwistyMixup3x3(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
41
    {
42
    super(numL, meshState, iconMode, quat, move, scale, stream);
43
    }
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

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

    
55
    return mCuts;
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

    
60
  public float[][] getCubitPositions(int[] numLayers)
61
    {
62
    if( mPosition==null )
63
      {
64
      final float DIST_CORNER = LONG_EDGE+SHORT_EDGE;
65
      final float DIST_EDGE   = LONG_EDGE+SHORT_EDGE;
66
      final float DIST_CENTER = LONG_EDGE+SHORT_EDGE;
67

    
68
      mPosition = new float[][]
69
         {
70
             { DIST_CORNER, DIST_CORNER, DIST_CORNER },
71
             { DIST_CORNER, DIST_CORNER,-DIST_CORNER },
72
             { DIST_CORNER,-DIST_CORNER, DIST_CORNER },
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

    
79
             {      0.0f, DIST_EDGE, DIST_EDGE },
80
             { DIST_EDGE,      0.0f, DIST_EDGE },
81
             {      0.0f,-DIST_EDGE, DIST_EDGE },
82
             {-DIST_EDGE,      0.0f, DIST_EDGE },
83
             { DIST_EDGE, DIST_EDGE,      0.0f },
84
             { DIST_EDGE,-DIST_EDGE,      0.0f },
85
             {-DIST_EDGE,-DIST_EDGE,      0.0f },
86
             {-DIST_EDGE, DIST_EDGE,      0.0f },
87
             {      0.0f, DIST_EDGE,-DIST_EDGE },
88
             { DIST_EDGE,      0.0f,-DIST_EDGE },
89
             {      0.0f,-DIST_EDGE,-DIST_EDGE },
90
             {-DIST_EDGE,      0.0f,-DIST_EDGE },
91

    
92
             {           0,           0, DIST_CENTER },
93
             {           0,           0,-DIST_CENTER },
94
             {           0, DIST_CENTER,           0 },
95
             {           0,-DIST_CENTER,           0 },
96
             { DIST_CENTER,           0,           0 },
97
             {-DIST_CENTER,           0,           0 },
98
         };
99
      }
100

    
101
    return mPosition;
102
    }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
  public Static4D getCubitQuats(int cubit, int[] numLayers)
107
    {
108
    if( mQuatIndex==null )
109
      {
110
      mQuatIndex = new int[] { 0,10,11,3,6,2,1,8,
111
                               0,4,11,5,7,12,13,6,10,20,3,18,
112
                               0,3,10,11,7,6 };
113
      }
114

    
115
    return mObjectQuats[mQuatIndex[cubit]];
116
    }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

    
120
  public ObjectShape getObjectShape(int variant)
121
    {
122
    float X = variant==0 ? SHORT_EDGE : LONG_EDGE;
123
    float Y = variant<=1 ? SHORT_EDGE : LONG_EDGE;
124
    float Z = SHORT_EDGE;
125

    
126
    float[][] vertices =
127
          {
128
              { -X,-Y,-Z },
129
              { -X,-Y,+Z },
130
              { -X,+Y,-Z },
131
              { -X,+Y,+Z },
132
              { +X,-Y,-Z },
133
              { +X,-Y,+Z },
134
              { +X,+Y,-Z },
135
              { +X,+Y,+Z },
136
          };
137

    
138
    int[][] indices =
139
          {
140
              {1,5,7,3},
141
              {3,7,6,2},
142
              {5,4,6,7},
143
              {0,1,3,2},
144
              {4,0,2,6},
145
              {0,4,5,1}
146
          };
147

    
148
    return new ObjectShape(vertices, indices);
149
    }
150

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

    
153
  public ObjectFaceShape getObjectFaceShape(int variant)
154
    {
155
    float h1 = isInIconMode() ? 0.001f : 0.06f;
156
    float h2 = 0.001f;
157
    float[][] bands   = { {h1,45,0.3f,0.5f,5,1,0}, {h2,45,0.3f,0.5f,5,1,0} };
158
    float[][] centers = { { 0.0f, 0.0f, 0.0f} };
159
    float[][] corners = { {0.04f,0.10f} };
160

    
161
    if( variant==0 )
162
      {
163
      int[] bandIndices = { 0,0,0,1,1,1 };
164
      int[] indices     = { -1,0,0,0,0,0,0,0 };
165
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
166
      }
167
    if( variant==1 )
168
      {
169
      int[] bandIndices = { 0,0,1,1,1,1 };
170
      int[] indices     = { -1,0,0,0,-1,0,0,0 };
171
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
172
      }
173
    else
174
      {
175
      int[] bandIndices = { 0,1,1,1,1,1 };
176
      int[] indices     = { -1,0,-1,0,-1,0,-1,0 };
177
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
178
      }
179
    }
180

    
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182

    
183
  public int getNumCubitVariants(int[] numLayers)
184
    {
185
    return 3;
186
    }
187

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189

    
190
  public int getCubitVariant(int cubit, int[] numLayers)
191
    {
192
    return cubit<8 ? 0 : (cubit<20?1:2);
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196
// PUBLIC API
197

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

    
200
  public String getShortName()
201
    {
202
    return ObjectType.MIXU_3.name();
203
    }
204

    
205
///////////////////////////////////////////////////////////////////////////////////////////////////
206

    
207
  public ObjectSignature getSignature()
208
    {
209
    return new ObjectSignature(ObjectType.MIXU_3);
210
    }
211

    
212
///////////////////////////////////////////////////////////////////////////////////////////////////
213

    
214
  public String getObjectName()
215
    {
216
    return "Mixup Cube";
217
    }
218

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

    
221
  public String getInventor()
222
    {
223
    return "Sergey Makarov";
224
    }
225

    
226
///////////////////////////////////////////////////////////////////////////////////////////////////
227

    
228
  public int getYearOfInvention()
229
    {
230
    return 1985;
231
    }
232

    
233
///////////////////////////////////////////////////////////////////////////////////////////////////
234

    
235
  public int getComplexity()
236
    {
237
    return 2;
238
    }
239

    
240
///////////////////////////////////////////////////////////////////////////////////////////////////
241

    
242
  public String[][] getTutorials()
243
    {
244
    return new String[][]{
245
                          {"gb","w0DmJYwNI3Q","How to Solve the Mixup Cube","Z3"},
246
                          {"es","wHyf1imdAi4","Resolver Mixup 3x3","Cuby"},
247
                          {"ru","PN2ntFP6sfs","Как собрать Mixup","Цель+Действие=Результат"},
248
                          {"fr","QWsFaw0zUJU","Résolution du Mixup Cube","skieur cubb"},
249
                          {"de","vvDPyByyLyQ","Lösung für den 3x3x3 Mixup Cube","rofrisch"},
250
                          {"pl","TpG6MzWmwLQ","Mixup 3x3x3 Cube Tutorial","MrUK"},
251
                          {"br","_63j3i4Xa78","3x3 Mixup cube Tutorial 1/3","Cubo vicio"},
252
                          {"br","qpTnQavPLEI","3x3 Mixup cube Tutorial 2/3","Cubo vicio"},
253
                          {"br","nrFEm1ygcV4","3x3 Mixup cube Tutorial 3/3","Cubo vicio"},
254
                          {"kr","Ag4XkmC2v6c","3x3x3 믹스업 (Mix-up) 큐브 해법","듀나메스 큐브 해법연구소"},
255
                          {"vn","mWW6HYbvvh8","Mixup 3x3 Tutorial","VĂN CÔNG TÙNG"},
256
                         };
257
    }
258
}
(25-25/40)