Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare1.java @ 33ba467a

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// 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 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
13 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
14
15 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.FactoryCubit;
16 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
17 ae9d9227 leszek
import org.distorted.objectlib.metadata.Metadata;
18 84a17011 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectVertexEffects;
19 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
20 361fd0de leszek
import org.distorted.objectlib.metadata.ListObjects;
21 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
22 9283a268 Leszek Koltunski
import org.distorted.objectlib.scrambling.ObjectScrambler;
23 29b82486 Leszek Koltunski
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
26
public class TwistySquare1 extends TwistySquare
27
{
28 82e62580 Leszek Koltunski
  private int[] mQuatIndex;
29 29b82486 Leszek Koltunski
  private float[][] mCenters;
30
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33 ae9d9227 leszek
  public TwistySquare1(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
34 29b82486 Leszek Koltunski
    {
35 ae9d9227 leszek
    super(iconMode, quat, move, scale, meta, asset);
36 29b82486 Leszek Koltunski
    }
37
38 a70b1e96 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40
  float getFactor()
41
    {
42
    return 1.0f;
43
    }
44
45 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47 ed0988c0 Leszek Koltunski
  @Override
48
  public int getScrambleType()
49 29b82486 Leszek Koltunski
    {
50 9283a268 Leszek Koltunski
    return ObjectScrambler.SCRAMBLING_SQUARE1;
51 29b82486 Leszek Koltunski
    }
52
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
55 9ba7f3f6 Leszek Koltunski
  public int[][] getScrambleEdges()
56 29b82486 Leszek Koltunski
    {
57 ed0988c0 Leszek Koltunski
    return null;
58 29b82486 Leszek Koltunski
    }
59
60 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
61
62
  public float[][] getCubitPositions(int[] numLayers)
63
    {
64
    if( mCenters==null )
65
      {
66
      mCenters = new float[][]
67
        {
68
         { 1.5f, 0.0f, 0.0f },
69
         {-1.5f, 0.0f, 0.0f },
70
71
         { 0.0f, 1.0f, 1.5f },
72
         { 1.5f, 1.0f, 0.0f },
73
         { 0.0f, 1.0f,-1.5f },
74
         {-1.5f, 1.0f, 0.0f },
75
         { 0.0f,-1.0f, 1.5f },
76
         { 1.5f,-1.0f, 0.0f },
77
         { 0.0f,-1.0f,-1.5f },
78
         {-1.5f,-1.0f, 0.0f },
79
80
         { 1.0f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f },
81
         { 1.0f, 1.0f,-2.0f, 2.0f, 1.0f,-1.0f },
82
         {-1.0f, 1.0f,-2.0f,-2.0f, 1.0f,-1.0f },
83
         {-1.0f, 1.0f, 2.0f,-2.0f, 1.0f, 1.0f },
84
         { 1.0f,-1.0f, 2.0f, 2.0f,-1.0f, 1.0f },
85
         { 1.0f,-1.0f,-2.0f, 2.0f,-1.0f,-1.0f },
86
         {-1.0f,-1.0f,-2.0f,-2.0f,-1.0f,-1.0f },
87
         {-1.0f,-1.0f, 2.0f,-2.0f,-1.0f, 1.0f }
88
        };
89
      }
90
    return mCenters;
91
    }
92
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94
95
  public Static4D getCubitQuats(int cubit, int[] numLayers)
96
    {
97 82e62580 Leszek Koltunski
    if( mQuatIndex ==null )
98 d0e6cf7f Leszek Koltunski
      {
99 82e62580 Leszek Koltunski
      mQuatIndex = new int[]
100 d0e6cf7f Leszek Koltunski
        {
101
        0, 6,
102 db6d9617 Leszek Koltunski
        0, 9, 6, 3, 17, 14, 23, 20,
103
        0, 9, 6, 3, 14, 23, 20, 17
104 d0e6cf7f Leszek Koltunski
        };
105
      }
106
107 82e62580 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
108 d0e6cf7f Leszek Koltunski
    }
109
110 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
111
112 84a17011 Leszek Koltunski
  private float[][] getVertices(int variant)
113 29b82486 Leszek Koltunski
    {
114
    if( variant==0 )
115
      {
116 84a17011 Leszek Koltunski
      return new float[][]
117 29b82486 Leszek Koltunski
        {
118 57ef6378 Leszek Koltunski
         { -1.5f-X, 0.5f, 1.5f },
119
         {    0.0f, 0.5f, 1.5f },
120
         {    0.0f, 0.5f,-1.5f },
121
         { -1.5f+X, 0.5f,-1.5f },
122
         { -1.5f-X,-0.5f, 1.5f },
123
         {    0.0f,-0.5f, 1.5f },
124
         {    0.0f,-0.5f,-1.5f },
125
         { -1.5f+X,-0.5f,-1.5f }
126 29b82486 Leszek Koltunski
        };
127 84a17011 Leszek Koltunski
      }
128
    else if( variant==1 )
129
      {
130
      return new float[][]
131
        {
132
         {  -X, 0.5f, 0.0f },
133
         {  +X, 0.5f, 0.0f },
134
         {0.0f, 0.5f,-1.5f },
135
         {  -X,-0.5f, 0.0f },
136
         {  +X,-0.5f, 0.0f },
137
         {0.0f,-0.5f,-1.5f },
138
        };
139
      }
140
    else
141
      {
142
      return new float[][]
143
        {
144
         { X-1.5f, 0.5f,  0.0f },
145
         {   0.0f, 0.5f,  0.0f },
146
         {   0.0f, 0.5f,X-1.5f },
147
         {  -1.5f, 0.5f, -1.5f },
148
         { X-1.5f,-0.5f,  0.0f },
149
         {   0.0f,-0.5f,  0.0f },
150
         {   0.0f,-0.5f,X-1.5f },
151
         {  -1.5f,-0.5f, -1.5f }
152
        };
153
      }
154
    }
155
156
///////////////////////////////////////////////////////////////////////////////////////////////////
157 29b82486 Leszek Koltunski
158 84a17011 Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
159
    {
160
    if( variant==0 )
161
      {
162 4e9f2df5 Leszek Koltunski
      int[][] indices =
163 29b82486 Leszek Koltunski
        {
164
         {4,5,1,0},
165
         {5,6,2,1},
166
         {6,7,3,2},
167 33c707e8 Leszek Koltunski
         {7,4,0,3},
168
         {0,1,2,3},
169 846b69f3 Leszek Koltunski
         {7,6,5,4}
170 29b82486 Leszek Koltunski
        };
171
172 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
173 29b82486 Leszek Koltunski
      }
174
    else if( variant==1 )
175
      {
176 4e9f2df5 Leszek Koltunski
      int[][] indices =
177 29b82486 Leszek Koltunski
        {
178
         {0,1,2},
179
         {3,4,1,0},
180 846b69f3 Leszek Koltunski
         {5,4,3},
181 29b82486 Leszek Koltunski
         {4,5,2,1},
182
         {5,3,0,2}
183
        };
184
185 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
186 29b82486 Leszek Koltunski
      }
187
    else
188
      {
189 4e9f2df5 Leszek Koltunski
      int[][] indices =
190 29b82486 Leszek Koltunski
        {
191
         {0,1,2,3},
192
         {4,5,1,0},
193
         {5,6,2,1},
194
         {7,4,0,3},
195 33c707e8 Leszek Koltunski
         {6,7,3,2},
196 846b69f3 Leszek Koltunski
         {7,6,5,4}
197 29b82486 Leszek Koltunski
        };
198
199 84a17011 Leszek Koltunski
      return new ObjectShape(getVertices(variant), indices);
200 3ee1d662 Leszek Koltunski
      }
201
    }
202
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204 29b82486 Leszek Koltunski
205 3ee1d662 Leszek Koltunski
  public ObjectFaceShape getObjectFaceShape(int variant)
206
    {
207 347f6cc1 Leszek Koltunski
    int angle1 = 25;
208
    int angle2 = 35;
209
    float R = 0.2f;
210
    float S = 0.8f;
211
212 3ee1d662 Leszek Koltunski
    if( variant==0 )
213
      {
214 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
215
      float h2 = isInIconMode() ? 0.001f : 0.02f;
216 347f6cc1 Leszek Koltunski
      float[][] bands = { {h1,angle1,R,S,5,2,1}, {h2,angle1,R,S,5,2,1}, {0.001f,angle1,R,S,5,2,1} };
217 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,1,2,2,2 };
218
      return new ObjectFaceShape(bands,indices,null);
219 3ee1d662 Leszek Koltunski
      }
220
    else if( variant==1 )
221
      {
222 3bf19410 Leszek Koltunski
      float height = isInIconMode() ? 0.001f : 0.038f;
223 347f6cc1 Leszek Koltunski
      float[][] bands = { {height,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
224 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1 };
225
      return new ObjectFaceShape(bands,indices,null);
226 3ee1d662 Leszek Koltunski
      }
227
    else
228
      {
229 3bf19410 Leszek Koltunski
      float height = isInIconMode() ? 0.001f : 0.038f;
230 347f6cc1 Leszek Koltunski
      float[][] bands = { {height,angle2,R,S, 5,2,1}, {0.001f,angle2,R,S, 5,2,1} };
231 84a17011 Leszek Koltunski
      int[] indices   = { 0,0,0,1,1,1 };
232
      return new ObjectFaceShape(bands,indices,null);
233
      }
234
    }
235
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237
238
  public ObjectVertexEffects getVertexEffects(int variant)
239
    {
240
    if( variant==0 )
241
      {
242
      float[][] corners = { {0.03f,0.05f} };
243
      int[] indices     = { 0,0,0,0,0,0,0,0 };
244
      float[][] centers = { { -0.75f, 0.0f, 0.0f} };
245
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
246
      }
247
    else if( variant==1 )
248
      {
249
      float[][] corners = { {0.04f,0.15f} };
250
      int[] indices     = { 0,0,-1,0,0,-1 };
251
      float[][] centers = { { 0.0f, 0.0f,-0.5f} };
252
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
253
      }
254
    else
255
      {
256 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.05f,0.13f} };
257
      int[] cornerIndices = { 0,0,0,-1,0,0,0,-1 };
258
      float[][] centers   = { { -0.5f, 0.0f,-0.5f} };
259
      int[] centerIndices = { -1,0,-1,-1,-1,0,-1,-1 };
260 84a17011 Leszek Koltunski
      return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
261 29b82486 Leszek Koltunski
      }
262
    }
263
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265
266 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
267 29b82486 Leszek Koltunski
    {
268
    return 3;
269
    }
270
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272
273 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
274 29b82486 Leszek Koltunski
    {
275
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
276
    }
277
278 89704841 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
279
280 d53fb890 Leszek Koltunski
  public float getStickerRadius()
281 89704841 Leszek Koltunski
    {
282
    return 0.12f;
283
    }
284
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286
287 d53fb890 Leszek Koltunski
  public float getStickerStroke()
288 89704841 Leszek Koltunski
    {
289 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.10f;
290 89704841 Leszek Koltunski
    }
291
292 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
293
// PUBLIC API
294
295 5f54927b Leszek Koltunski
  public String getShortName()
296 61aa85e4 Leszek Koltunski
    {
297 361fd0de leszek
    return ListObjects.SQU1_3.name();
298 5f54927b Leszek Koltunski
    }
299
300 052e0362 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
301
302
  public String[][] getTutorials()
303
    {
304
    return new String[][]{
305
                          {"gb","0tX-f6RLgac","How to Solve the Square-1","Z3"},
306
                          {"es","mGtHDWj_i1o","Resolver SQUARE-1","Cuby"},
307
                          {"ru","XguuJTUwJoE","Как собрать Скваер-1","Алексей Ярыгин"},
308
                          {"fr","knRmTSa6aHQ","Comment résoudre le Square-1 (1/3)","Valentino Cube"},
309
                          {"fr","y-0ZrAgzETI","Comment résoudre le Square-1 (2/3)","Valentino Cube"},
310
                          {"fr","tYbE9GfEokw","Comment résoudre le Square-1 (3/3)","Valentino Cube"},
311
                          {"de","p9DMIzNQ3b8","Square-1 Tutorial (1/2)","Pezcraft"},
312
                          {"de","gM6E28JGmoo","Square-1 Tutorial (2/2)","Pezcraft"},
313
                          {"pl","_0rsImrp9jc","Jak ułożyć: Square-1","DżoDżo"},
314
                          {"br","geT7SvX0DEw","Tutorial do Square-1","Pedro Filho"},
315
                          {"kr","NcB50lWdQzE","스퀘어1 맞추는 방법","iamzoone"},
316 a399e91b Leszek Koltunski
                          {"vn","YvCZXkbZnNs","Tutorial N.120 - Square 1","Duy Thích Rubik"},
317 2318a72a leszek
                          {"tw","5XsmL2ex5G8","SQ1\"單一公式法\"教學","不正常魔術方塊研究中心"},
318 052e0362 Leszek Koltunski
                         };
319
    }
320 29b82486 Leszek Koltunski
}