Project

General

Profile

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

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

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
  public int[][] getScrambleEdges()
42
    {
43
    if( mEdges==null )
44
      {
45
      mEdges = new int[][]
46
        {
47
          { 0,2,1,2,2,2,   9,1,10,1,   11,3,12,3,13,3 },     // 0
48
          { 0,2,1,2,2,2,               11,3,12,3,13,3 },     // 1 SL
49
          {                9,1,10,1,   11,4,12,4,13,4 },     // 2 LO
50
          { 0,4,1,4,2,4,   9,1,10,1,                  },     // 3 UP
51
          {                9,1,10,1,                  }      // 4 UL
52
        };
53
      }
54

    
55
    return mEdges;
56
    }
57

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

    
60
  public float[][] getCubitPositions(int[] numLayers)
61
    {
62
    if( mCenters ==null )
63
      {
64
      mCenters = new float[][]
65
        {
66
         { 1.5f, 0.0f, 0.0f },
67
         {-1.5f, 0.0f, 0.0f },
68

    
69
         { 1.5f, 1.0f, 1.5f },
70
         { 1.5f, 1.0f,-1.5f },
71
         {-1.5f, 1.0f, 1.5f },
72
         {-1.5f, 1.0f,-1.5f },
73

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

    
81
    return mCenters;
82
    }
83

    
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85

    
86
  public Static4D getCubitQuats(int cubit, int[] numLayers)
87
    {
88
    if( mQuatIndex==null )
89
      {
90
      mQuatIndex = new int[]
91
        {
92
        0, 2,
93
        0, 3, 1, 2,
94
        0, 3, 1, 2,
95
        };
96
      }
97

    
98
    return mObjectQuats[mQuatIndex[cubit]];
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  private float[][] getVertices(int variant)
104
    {
105
    if( variant==0 )
106
      {
107
      return new float[][]
108
        {
109
         { -1.5f-X, 0.5f, 1.5f },
110
         {    0.0f, 0.5f, 1.5f },
111
         {    0.0f, 0.5f,-1.5f },
112
         { -1.5f+X, 0.5f,-1.5f },
113
         { -1.5f-X,-0.5f, 1.5f },
114
         {    0.0f,-0.5f, 1.5f },
115
         {    0.0f,-0.5f,-1.5f },
116
         { -1.5f+X,-0.5f,-1.5f }
117
        };
118
      }
119
    else
120
      {
121
      return new float[][]
122
        {
123
         { -1.5f-X, 0.5f, 0.0f   },
124
         {    0.0f, 0.5f, 0.0f   },
125
         {    0.0f, 0.5f,-1.5F+X },
126
         {   -1.5f, 0.5f,-1.5f   },
127
         { -1.5f-X,-0.5f, 0.0f   },
128
         {    0.0f,-0.5f, 0.0f   },
129
         {    0.0f,-0.5f,-1.5F+X },
130
         {   -1.5f,-0.5f,-1.5f   },
131
        };
132
      }
133
    }
134

    
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136

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

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

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

    
154
  public ObjectFaceShape getObjectFaceShape(int variant)
155
    {
156
    float h1 = isInIconMode() ? 0.001f : 0.04f;
157
    float h2 = isInIconMode() ? 0.001f : 0.02f;
158
    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} };
159
    int[] indices;
160

    
161
         if( variant==0 ) indices= new int[] { 0,0,1,2,2,2 };
162
    else if( variant==1 ) indices= new int[] { 0,0,2,2,0,2 };
163
    else                  indices= new int[] { 0,0,2,2,2,0 };
164

    
165
    return new ObjectFaceShape(bands,indices,null);
166
    }
167

    
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

    
170
  public ObjectVertexEffects getVertexEffects(int variant)
171
    {
172
    float[][] corners = { {0.03f,0.05f} };
173
    int[] indices     = { 0,0,0,0,0,0,0,0 };
174
    float[][] centers = { { -0.75f, 0.0f, variant==0 ? 0.0f : -0.75f } };
175
    return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
176
    }
177

    
178
///////////////////////////////////////////////////////////////////////////////////////////////////
179

    
180
  public int getNumCubitVariants(int[] numLayers)
181
    {
182
    return 3;
183
    }
184

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

    
187
  public int getCubitVariant(int cubit, int[] numLayers)
188
    {
189
    return cubit<2 ? 0 : (cubit<6 ? 1:2 );
190
    }
191

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

    
194
  public float getStickerRadius()
195
    {
196
    return 0.12f;
197
    }
198

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

    
201
  public float getStickerStroke()
202
    {
203
    return isInIconMode() ? 0.20f : 0.10f;
204
    }
205

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

    
208
  public float[][] getStickerAngles()
209
    {
210
    return null;
211
    }
212

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

    
216
  public int[][] getBasicAngles()
217
    {
218
    return new int[][] { {4,4,4},{2,2},{4,4,4} };
219
    }
220

    
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

    
223
  public String getShortName()
224
    {
225
    return ObjectType.SQU0_3.name();
226
    }
227

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

    
230
  public ObjectSignature getSignature()
231
    {
232
    return new ObjectSignature(ObjectSignatures.SQU0_3);
233
    }
234

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

    
237
  public String getObjectName()
238
    {
239
    return "Square-0";
240
    }
241

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

    
244
  public String getInventor()
245
    {
246
    return "Aleksandra Franc";
247
    }
248

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

    
251
  public int getYearOfInvention()
252
    {
253
    return 2008;
254
    }
255

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

    
258
  public int getComplexity()
259
    {
260
    return 1;
261
    }
262

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

    
265
  public String[][] getTutorials()
266
    {
267
    return new String[][] {
268
                           {"gb","RqFhpWTApOo","Square-0 Cube Tutorial","Michele Regano"},
269
                           {"es","A6mGEQC06mc","Tutorial Cómo hacer un Square-0","Pablo"},
270
                           {"fr","zMIjj46inXg","Résoudre le Square-0","rubik'sIngrid"},
271
                          };
272
    }
273
}
(36-36/43)