Project

General

Profile

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

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

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.metadata.Metadata;
18
import org.distorted.objectlib.signature.ObjectSignature;
19
import org.distorted.objectlib.helpers.ObjectVertexEffects;
20
import org.distorted.objectlib.main.InitAssets;
21
import org.distorted.objectlib.signature.ObjectConstants;
22
import org.distorted.objectlib.metadata.ListObjects;
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 iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
35
    {
36
    super(iconMode, quat, move, scale, meta, 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
    int angle = 35;
166
    float R = 0.2f;
167
    float S = 0.8f;
168
    float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0}, {0.001f,angle,R,S,5,1,0} };
169
    int[] indices;
170

    
171
         if( variant==0 ) indices= new int[] { 0,0,1,2,2,2 };
172
    else if( variant==1 ) indices= new int[] { 0,0,2,2,0,2 };
173
    else                  indices= new int[] { 0,0,2,2,2,0 };
174

    
175
    return new ObjectFaceShape(bands,indices,null);
176
    }
177

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

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

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

    
190
  public int getNumCubitVariants(int[] numLayers)
191
    {
192
    return 3;
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

    
197
  public int getCubitVariant(int cubit, int[] numLayers)
198
    {
199
    return cubit<2 ? 0 : (cubit<6 ? 1:2 );
200
    }
201

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
  public float getStickerRadius()
205
    {
206
    return 0.12f;
207
    }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  public float getStickerStroke()
212
    {
213
    return isInIconMode() ? 0.20f : 0.10f;
214
    }
215

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217
// PUBLIC API
218

    
219
  public int[][] getBasicAngles()
220
    {
221
    return new int[][] { {4,4,4},{2,2},{4,4,4} };
222
    }
223

    
224
///////////////////////////////////////////////////////////////////////////////////////////////////
225

    
226
  public String getShortName()
227
    {
228
    return ListObjects.SQU0_3.name();
229
    }
230

    
231
///////////////////////////////////////////////////////////////////////////////////////////////////
232

    
233
  public ObjectSignature getSignature()
234
    {
235
    return new ObjectSignature(ObjectConstants.SQU0_3);
236
    }
237

    
238
///////////////////////////////////////////////////////////////////////////////////////////////////
239

    
240
  public String getObjectName()
241
    {
242
    return "Square-0";
243
    }
244

    
245
///////////////////////////////////////////////////////////////////////////////////////////////////
246

    
247
  public String getInventor()
248
    {
249
    return "Aleksandra Franc";
250
    }
251

    
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253

    
254
  public int getYearOfInvention()
255
    {
256
    return 2008;
257
    }
258

    
259
///////////////////////////////////////////////////////////////////////////////////////////////////
260

    
261
  public float getComplexity()
262
    {
263
    return 1.05f;
264
    }
265

    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267

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