Project

General

Profile

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

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

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
    int I=5; int J=2; int K=8;
164
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,I,J,K,0,I,J,K };
165
    return mObjectQuats[mQuatIndex[cubit]];
166
    }
167

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

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

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

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

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

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

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

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

    
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211

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

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

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

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

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

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

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

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

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

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

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

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

    
273
///////////////////////////////////////////////////////////////////////////////////////////////////
274
// PUBLIC API
275

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

    
281
///////////////////////////////////////////////////////////////////////////////////////////////////
282

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

    
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

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

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

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

    
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304

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

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311

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

    
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318

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

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

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

    
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332

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