Project

General

Profile

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

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

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 TwistyMixup3x3 extends TwistyMixup
25
{
26
  private static final float SHORT_EDGE = 1.5f-0.75f*SQ2;
27
  private static final float LONG_EDGE  = 1.5f*(SQ2-1);
28

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

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

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

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

    
83
             {           0,           0, DIST_CENTER },
84
             {           0,           0,-DIST_CENTER },
85
             {           0, DIST_CENTER,           0 },
86
             {           0,-DIST_CENTER,           0 },
87
             { DIST_CENTER,           0,           0 },
88
             {-DIST_CENTER,           0,           0 },
89
         };
90
      }
91

    
92
    return mPosition;
93
    }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

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

    
106
    return mObjectQuats[mQuatIndex[cubit]];
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

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

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

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

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

    
144
    return new ObjectShape(getVertices(variant), indices);
145
    }
146

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

    
149
  public ObjectFaceShape getObjectFaceShape(int variant)
150
    {
151
    float h1 = isInIconMode() ? 0.001f : 0.06f;
152
    float h2 = 0.001f;
153
    int angle = 25;
154
    float R = 0.7f;
155
    float S = 0.5f;
156
    float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,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 ListObjects.MIXU_3.name();
221
    }
222

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

    
225
  public String[][] getTutorials()
226
    {
227
    return new String[][]{
228
                          {"gb","w0DmJYwNI3Q","How to Solve the Mixup Cube","Z3"},
229
                          {"es","wHyf1imdAi4","Resolver Mixup 3x3","Cuby"},
230
                          {"ru","PN2ntFP6sfs","Как собрать Mixup","Цель+Действие=Результат"},
231
                          {"fr","QWsFaw0zUJU","Résolution du Mixup Cube","skieur cubb"},
232
                          {"de","vvDPyByyLyQ","Lösung für den 3x3x3 Mixup Cube","rofrisch"},
233
                          {"pl","TpG6MzWmwLQ","Mixup 3x3x3 Cube Tutorial","MrUK"},
234
                          {"br","_63j3i4Xa78","3x3 Mixup cube Tutorial 1/3","Cubo vicio"},
235
                          {"br","qpTnQavPLEI","3x3 Mixup cube Tutorial 2/3","Cubo vicio"},
236
                          {"br","nrFEm1ygcV4","3x3 Mixup cube Tutorial 3/3","Cubo vicio"},
237
                          {"kr","Ag4XkmC2v6c","3x3x3 믹스업 (Mix-up) 큐브 해법","듀나메스 큐브 해법연구소"},
238
                          {"vn","mWW6HYbvvh8","Mixup 3x3 Tutorial","VĂN CÔNG TÙNG"},
239
                         };
240
    }
241
}
(36-36/59)