Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMorphix.java @ a8295031

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objectlib.objects;
21

    
22
import org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.helpers.ObjectFaceShape;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.helpers.ObjectSignature;
27
import org.distorted.objectlib.main.InitData;
28
import org.distorted.objectlib.scrambling.ScrambleState;
29
import org.distorted.objectlib.main.ObjectType;
30
import org.distorted.objectlib.main.ShapeTetrahedron;
31
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
32

    
33
import java.io.InputStream;
34

    
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
36
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
public class TwistyMorphix extends ShapeTetrahedron
41
{
42
  static final Static3D[] ROT_AXIS = new Static3D[]
43
         {
44
           new Static3D( SQ2/2, 0.0f, SQ2/2),
45
           new Static3D(  0.0f, 1.0f,  0.0f),
46
           new Static3D( SQ2/2, 0.0f,-SQ2/2),
47
         };
48

    
49
  private ScrambleState[] mStates;
50
  private int[][] mBasicAngle;
51
  private float[][] mCuts;
52
  private float[][] mCenters;
53
  private int[] mQuatIndex;
54

    
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

    
57
  public TwistyMorphix(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
58
    {
59
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
60
    }
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63
// same as in a 2x2
64

    
65
  public ScrambleState[] getScrambleStates()
66
    {
67
    if( mStates==null )
68
      {
69
      int[] tmp = { 0,-1,0,0,1,0,0,2,0, 1,-1,0,1,1,0,1,2,0 };
70

    
71
      mStates = new ScrambleState[]
72
          {
73
          new ScrambleState( new int[][] { tmp,tmp,tmp } )
74
          };
75
      }
76

    
77
    return mStates;
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  public float[][] getCuts(int[] numLayers)
83
    {
84
    if( mCuts==null )
85
      {
86
      float[] cut = new float[] {0};
87
      mCuts = new float[][] { cut,cut,cut };
88
      }
89

    
90
    return mCuts;
91
    }
92

    
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

    
95
  public boolean[][] getLayerRotatable(int[] numLayers)
96
    {
97
    boolean[] tmp = new boolean[] {true,true};
98
    return new boolean[][] { tmp,tmp,tmp };
99
    }
100

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

    
103
  public int getTouchControlType()
104
    {
105
    return TC_CHANGING_SHAPEMOD;
106
    }
107

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

    
110
  public int getTouchControlSplit()
111
    {
112
    return TYPE_NOT_SPLIT;
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  public int[][][] getEnabled()
118
    {
119
    return null;
120
    }
121

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

    
124
  public float[] getDist3D(int[] numLayers)
125
    {
126
    return TouchControlTetrahedron.D3D;
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

    
131
  public Static3D[] getFaceAxis()
132
    {
133
    return TouchControlTetrahedron.FACE_AXIS;
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  public float[][] getCubitPositions(int[] numLayers)
139
    {
140
    if( mCenters==null )
141
      {
142
      final float A = SQ2/6;
143
      final float B = 1.0f/3;
144

    
145
      mCenters = new float[][]
146
         {
147
             {0.0f, -A,   +B},
148
             {0.0f, -A,   -B},
149
             {  +B,  A, 0.0f},
150
             {  -B,  A, 0.0f},
151
             {0.0f,  A,   +B},
152
             {0.0f,  A,   -B},
153
             {  +B, -A, 0.0f},
154
             {  -B, -A, 0.0f}
155
         };
156
      }
157

    
158
    return mCenters;
159
    }
160

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

    
163
  public Static4D getCubitQuats(int cubit, int[] numLayers)
164
    {
165
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,5,2,8,0,5,2,8 };
166
    return mObjectQuats[mQuatIndex[cubit]];
167
    }
168

    
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170

    
171
  public ObjectShape getObjectShape(int variant)
172
    {
173
    if( variant==0 )
174
      {
175
      final float Y = SQ2/2;
176
      final float Z = 1.0f;
177

    
178
      float[][] vertices =
179
          {
180
              {0.0f,-2*Y/3, 2*Z/3 },
181
              {0.0f,-2*Y/3,  -Z/3 },
182
              { Z/2,   Y/3,   Z/6 },
183
              {-Z/2,   Y/3,   Z/6 },
184
              {0.0f,   Y/3,  -Z/3 }
185
          };
186

    
187
      int[][] indices = { {0,2,3},{0,1,2},{0,3,1},{4,2,1},{4,1,3},{4,3,2} };
188

    
189
      return new ObjectShape(vertices, indices);
190
      }
191
    else
192
      {
193
      final float X = 1.0f;
194
      final float Y = SQ2/2;
195
      final float Z = 0.5f;
196

    
197
      float[][] vertices =
198
          {
199
              {-X/2,  -Y/3,   Z/3 },
200
              { X/2,  -Y/3,   Z/3 },
201
              {0.0f, 2*Y/3,-2*Z/3 },
202
              {0.0f,  -Y/3,-2*Z/3 }
203
          };
204

    
205
      int[][] indices = { {1,2,0},{3,1,0},{1,3,2},{3,0,2} };
206

    
207
      return new ObjectShape(vertices, indices);
208
      }
209
    }
210

    
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

    
213
  public ObjectFaceShape getObjectFaceShape(int variant)
214
    {
215
    float height = isInIconMode() ? 0.001f : 0.03f;
216

    
217
    if( variant==0 )
218
      {
219
      float[][] bands   = { {height,30,0.15f,0.5f,5,1,2}, {0.001f,30,0.2f,0.4f,5,1,2} };
220
      int[] bandIndices = { 0,0,0,1,1,1 };
221
      float[][] corners = { {0.08f,0.13f} };
222
      int[] indices     = { 0,0,0,0,-1 };
223
      float[][] centers = { { 0.0f,0.0f,0.0f } };
224
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
225
      }
226
    else
227
      {
228
      final float Y = SQ2/2;
229
      final float Z = 0.5f;
230
      float[][] bands   = { {height,30,0.15f,0.5f,5,1,1}, {0.001f,30,0.25f,0.5f,5,1,1} };
231
      int[] bandIndices = { 0,1,1,1 };
232
      float[][] corners = { {0.08f,0.13f} };
233
      int[] indices     = { 0,0,0,-1 };
234
      float[][] centers = { { 0.0f,-Y/3,-2*Z/3 } };
235
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
236
      }
237
    }
238

    
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240

    
241
  public int getNumCubitVariants(int[] numLayers)
242
    {
243
    return 2;
244
    }
245

    
246
///////////////////////////////////////////////////////////////////////////////////////////////////
247

    
248
  public int getCubitVariant(int cubit, int[] numLayers)
249
    {
250
    return cubit<4 ? 0 : 1;
251
    }
252

    
253
///////////////////////////////////////////////////////////////////////////////////////////////////
254

    
255
  public float getStickerRadius()
256
    {
257
    return 0.10f;
258
    }
259

    
260
///////////////////////////////////////////////////////////////////////////////////////////////////
261

    
262
  public float getStickerStroke()
263
    {
264
    return isInIconMode() ? 0.12f : 0.07f;
265
    }
266

    
267
///////////////////////////////////////////////////////////////////////////////////////////////////
268

    
269
  public float[][] getStickerAngles()
270
    {
271
    return null;
272
    }
273

    
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275
// PUBLIC API
276

    
277
  public Static3D[] getRotationAxis()
278
    {
279
    return ROT_AXIS;
280
    }
281

    
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

    
284
  public int[][] getBasicAngles()
285
    {
286
    if( mBasicAngle==null )
287
      {
288
      int num = getNumLayers()[0];
289
      int[] tmp = new int[num];
290
      for(int i=0; i<num; i++) tmp[i] = 4;
291
      mBasicAngle = new int[][] { tmp,tmp,tmp };
292
      }
293

    
294
    return mBasicAngle;
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

    
299
  public String getShortName()
300
    {
301
    return ObjectType.MORP_2.name();
302
    }
303

    
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305

    
306
  public ObjectSignature getSignature()
307
    {
308
    return new ObjectSignature(ObjectType.MORP_2);
309
    }
310

    
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312

    
313
  public String getObjectName()
314
    {
315
    return "Pyramorphix";
316
    }
317

    
318
///////////////////////////////////////////////////////////////////////////////////////////////////
319

    
320
  public String getInventor()
321
    {
322
    return "Manfred Fritsche";
323
    }
324

    
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326

    
327
  public int getYearOfInvention()
328
    {
329
    return 0;
330
    }
331

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

    
334
  public int getComplexity()
335
    {
336
    return 1;
337
    }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

    
341
  public String[][] getTutorials()
342
    {
343
    return new String[][] {
344
                          {"gb","dD67B3cRaFw","Pyramorphix Solve Tutorial","SpeedCubeReview"},
345
                          {"es","RA37LhYlEW8","Resolver Pyramorphix","Cuby"},
346
                          {"ru","fTNXLAAuGAI","Как собрать Пираморфикс 2х2","Алексей Ярыгин"},
347
                          {"fr","SfEqoud5KRc","Résolution du Pyramorphix","Asthalis"},
348
                          {"de","1VDGoVJZCug","Pyramorphix - Tutorial","GerCubing"},
349
                          {"pl","b7VpuXloBNU","Mastermorphix 2x2 TUTORIAL PL","MrUK"},
350
                          {"br","wByfDxTrbC8","Como resolver o Pyramorphix","Rafael Cinoto"},
351
                          {"kr","WIy5ZvTXsOY","피라몰픽스 쉽게 맞추기","큐브놀이터"},
352
                          {"vn","6CuTRLjKHho","Tutorial N.14 - Pyramorphix","Duy Thích Rubik"},
353
                         };
354
    }
355
}
(27-27/40)