Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMixup3x3.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 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.InitData;
28
import org.distorted.objectlib.main.ObjectType;
29

    
30
import java.io.InputStream;
31

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

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

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

    
41
  public TwistyMixup3x3(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[] {-LONG_EDGE,+LONG_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   = LONG_EDGE+SHORT_EDGE;
67
      final float DIST_CENTER = LONG_EDGE+SHORT_EDGE;
68

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

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

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

    
102
    return mPosition;
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

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

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

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

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

    
127
    float[][] vertices =
128
          {
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
              { +X,+Y,+Z },
137
          };
138

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

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

    
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

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

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

    
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183

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

    
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

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

    
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197
// PUBLIC API
198

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

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

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

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

    
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214

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

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221

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

    
227
///////////////////////////////////////////////////////////////////////////////////////////////////
228

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

    
234
///////////////////////////////////////////////////////////////////////////////////////////////////
235

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

    
241
///////////////////////////////////////////////////////////////////////////////////////////////////
242

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