Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare0.java @ a70b1e96

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2023 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.InitAssets;
20
import org.distorted.objectlib.main.InitData;
21
import org.distorted.objectlib.main.ObjectSignatures;
22
import org.distorted.objectlib.main.ObjectType;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
public class TwistySquare0 extends TwistySquare
27
{
28
  private int[][] mEdges;
29
  private int[] mQuatIndex;
30
  private float[][] mCenters;
31

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

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

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

    
41
  float getFactor()
42
    {
43
    return 1.3f;
44
    }
45

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

    
48
  public int[][] getScrambleEdges()
49
    {
50
    if( mEdges==null )
51
      {
52
      mEdges = new int[][]
53
        {
54
          { 0,2,1,2,2,2,   9,1,10,1,   11,3,12,3,13,3 },     // 0
55
          { 0,2,1,2,2,2,               11,3,12,3,13,3 },     // 1 SL
56
          {                9,1,10,1,   11,4,12,4,13,4 },     // 2 LO
57
          { 0,4,1,4,2,4,   9,1,10,1,                  },     // 3 UP
58
          {                9,1,10,1,                  }      // 4 UL
59
        };
60
      }
61

    
62
    return mEdges;
63
    }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

    
67
  public float[][] getCubitPositions(int[] numLayers)
68
    {
69
    if( mCenters ==null )
70
      {
71
      mCenters = new float[][]
72
        {
73
         { 1.5f, 0.0f, 0.0f },
74
         {-1.5f, 0.0f, 0.0f },
75

    
76
         { 1.5f, 1.0f, 1.5f },
77
         { 1.5f, 1.0f,-1.5f },
78
         {-1.5f, 1.0f, 1.5f },
79
         {-1.5f, 1.0f,-1.5f },
80

    
81
         { 1.5f,-1.0f, 1.5f },
82
         { 1.5f,-1.0f,-1.5f },
83
         {-1.5f,-1.0f, 1.5f },
84
         {-1.5f,-1.0f,-1.5f },
85
        };
86
      }
87

    
88
    return mCenters;
89
    }
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

    
93
  public Static4D getCubitQuats(int cubit, int[] numLayers)
94
    {
95
    if( mQuatIndex==null )
96
      {
97
      mQuatIndex = new int[]
98
        {
99
        0, 2,
100
        0, 3, 1, 2,
101
        0, 3, 1, 2,
102
        };
103
      }
104

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

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  private float[][] getVertices(int variant)
111
    {
112
    if( variant==0 )
113
      {
114
      return new float[][]
115
        {
116
         { -1.5f-X, 0.5f, 1.5f },
117
         {    0.0f, 0.5f, 1.5f },
118
         {    0.0f, 0.5f,-1.5f },
119
         { -1.5f+X, 0.5f,-1.5f },
120
         { -1.5f-X,-0.5f, 1.5f },
121
         {    0.0f,-0.5f, 1.5f },
122
         {    0.0f,-0.5f,-1.5f },
123
         { -1.5f+X,-0.5f,-1.5f }
124
        };
125
      }
126
    else
127
      {
128
      return new float[][]
129
        {
130
         { -1.5f-X, 0.5f, 0.0f   },
131
         {    0.0f, 0.5f, 0.0f   },
132
         {    0.0f, 0.5f,-1.5F+X },
133
         {   -1.5f, 0.5f,-1.5f   },
134
         { -1.5f-X,-0.5f, 0.0f   },
135
         {    0.0f,-0.5f, 0.0f   },
136
         {    0.0f,-0.5f,-1.5F+X },
137
         {   -1.5f,-0.5f,-1.5f   },
138
        };
139
      }
140
    }
141

    
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143

    
144
  public ObjectShape getObjectShape(int variant)
145
    {
146
    int[][] indices =
147
      {
148
        {4,5,1,0},
149
        {5,6,2,1},
150
        {6,7,3,2},
151
        {7,4,0,3},
152
        {0,1,2,3},
153
        {7,6,5,4}
154
      };
155

    
156
    return new ObjectShape(getVertices(variant), indices);
157
    }
158

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

    
161
  public ObjectFaceShape getObjectFaceShape(int variant)
162
    {
163
    float h1 = isInIconMode() ? 0.001f : 0.04f;
164
    float h2 = isInIconMode() ? 0.001f : 0.02f;
165
    float[][] bands = { {h1,35,0.2f,0.8f,5,1,0}, {h2,35,0.5f,1.0f,5,1,0}, {0.001f,35,0.3f,0.8f,5,1,0} };
166
    int[] indices;
167

    
168
         if( variant==0 ) indices= new int[] { 0,0,1,2,2,2 };
169
    else if( variant==1 ) indices= new int[] { 0,0,2,2,0,2 };
170
    else                  indices= new int[] { 0,0,2,2,2,0 };
171

    
172
    return new ObjectFaceShape(bands,indices,null);
173
    }
174

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

    
177
  public ObjectVertexEffects getVertexEffects(int variant)
178
    {
179
    float[][] corners = { {0.03f,0.05f} };
180
    int[] indices     = { 0,0,0,0,0,0,0,0 };
181
    float[][] centers = { { -0.75f, 0.0f, variant==0 ? 0.0f : -0.75f } };
182
    return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
183
    }
184

    
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186

    
187
  public int getNumCubitVariants(int[] numLayers)
188
    {
189
    return 3;
190
    }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

    
194
  public int getCubitVariant(int cubit, int[] numLayers)
195
    {
196
    return cubit<2 ? 0 : (cubit<6 ? 1:2 );
197
    }
198

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

    
201
  public float getStickerRadius()
202
    {
203
    return 0.12f;
204
    }
205

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

    
208
  public float getStickerStroke()
209
    {
210
    return isInIconMode() ? 0.20f : 0.10f;
211
    }
212

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

    
215
  public float[][] getStickerAngles()
216
    {
217
    return null;
218
    }
219

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221
// PUBLIC API
222

    
223
  public int[][] getBasicAngles()
224
    {
225
    return new int[][] { {4,4,4},{2,2},{4,4,4} };
226
    }
227

    
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

    
230
  public String getShortName()
231
    {
232
    return ObjectType.SQU0_3.name();
233
    }
234

    
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

    
237
  public ObjectSignature getSignature()
238
    {
239
    return new ObjectSignature(ObjectSignatures.SQU0_3);
240
    }
241

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

    
244
  public String getObjectName()
245
    {
246
    return "Square-0";
247
    }
248

    
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

    
251
  public String getInventor()
252
    {
253
    return "Aleksandra Franc";
254
    }
255

    
256
///////////////////////////////////////////////////////////////////////////////////////////////////
257

    
258
  public int getYearOfInvention()
259
    {
260
    return 2008;
261
    }
262

    
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264

    
265
  public int getComplexity()
266
    {
267
    return 1;
268
    }
269

    
270
///////////////////////////////////////////////////////////////////////////////////////////////////
271

    
272
  public String[][] getTutorials()
273
    {
274
    return new String[][] {
275
                           {"gb","RqFhpWTApOo","Square-0 Cube Tutorial","Michele Regano"},
276
                           {"es","A6mGEQC06mc","Tutorial Cómo hacer un Square-0","Pablo"},
277
                           {"fr","zMIjj46inXg","Résoudre le Square-0","rubik'sIngrid"},
278
                          };
279
    }
280
}
(39-39/47)