Project

General

Profile

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

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

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.scrambling.ScrambleState;
27
import org.distorted.objectlib.main.ObjectType;
28
import org.distorted.objectlib.main.ShapeTetrahedron;
29
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron;
30

    
31
import java.io.InputStream;
32

    
33
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
34
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

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

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

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  public TwistyMorphix(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
56
    {
57
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
// same as in a 2x2
62

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

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

    
75
    return mStates;
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

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

    
88
    return mCuts;
89
    }
90

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

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

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

    
101
  public int getTouchControlType()
102
    {
103
    return TC_CHANGING_SHAPEMOD;
104
    }
105

    
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

    
108
  public int getTouchControlSplit()
109
    {
110
    return TYPE_NOT_SPLIT;
111
    }
112

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
  public int[][][] getEnabled()
116
    {
117
    return null;
118
    }
119

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

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

    
127
///////////////////////////////////////////////////////////////////////////////////////////////////
128

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

    
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135

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

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

    
156
    return mCenters;
157
    }
158

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

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

    
167
///////////////////////////////////////////////////////////////////////////////////////////////////
168

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

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

    
185
      int[][] indices = { {0,2,3},{0,1,2},{0,3,1},{4,2,1},{4,1,3},{4,3,2} };
186

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

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

    
203
      int[][] indices = { {1,2,0},{3,1,0},{1,3,2},{3,0,2} };
204

    
205
      return new ObjectShape(vertices, indices);
206
      }
207
    }
208

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

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

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

    
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

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

    
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

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

    
251
///////////////////////////////////////////////////////////////////////////////////////////////////
252

    
253
  public float getStickerRadius()
254
    {
255
    return 0.10f;
256
    }
257

    
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259

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

    
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

    
267
  public float[][] getStickerAngles()
268
    {
269
    return null;
270
    }
271

    
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273
// PUBLIC API
274

    
275
  public Static3D[] getRotationAxis()
276
    {
277
    return ROT_AXIS;
278
    }
279

    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281

    
282
  public int[] getBasicAngles()
283
    {
284
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 4,4,4 };
285
    return mBasicAngle;
286
    }
287

    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289

    
290
  public String getShortName()
291
    {
292
    return ObjectType.MORP_2.name();
293
    }
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

    
297
  public long getSignature()
298
    {
299
    return ObjectType.MORP_2.ordinal();
300
    }
301

    
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

    
304
  public String getObjectName()
305
    {
306
    return "Pyramorphix";
307
    }
308

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

    
311
  public String getInventor()
312
    {
313
    return "Manfred Fritsche";
314
    }
315

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

    
318
  public int getYearOfInvention()
319
    {
320
    return 0;
321
    }
322

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

    
325
  public int getComplexity()
326
    {
327
    return 1;
328
    }
329

    
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331

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