Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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 static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
24

    
25
import java.io.InputStream;
26

    
27
import org.distorted.library.type.Static3D;
28
import org.distorted.library.type.Static4D;
29

    
30
import org.distorted.objectlib.helpers.ObjectFaceShape;
31
import org.distorted.objectlib.helpers.ObjectShape;
32
import org.distorted.objectlib.main.InitData;
33
import org.distorted.objectlib.scrambling.ScrambleState;
34
import org.distorted.objectlib.main.ShapeHexahedron;
35
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
abstract class TwistyDino extends ShapeHexahedron
40
{
41
  static final Static3D[] ROT_AXIS = new Static3D[]
42
         {
43
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
44
           new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
45
           new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
46
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
47
         };
48

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

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

    
57
  TwistyDino(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

    
64
  public float[][] getCuts(int[] numLayers)
65
    {
66
    if( mCuts==null )
67
      {
68
      float[] cut = new float[] { -SQ3/3, +SQ3/3 };
69
      mCuts = new float[][] { cut,cut,cut,cut };
70
      }
71

    
72
    return mCuts;
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
  public boolean[][] getLayerRotatable(int[] numLayers)
78
    {
79
    int numAxis = ROT_AXIS.length;
80
    boolean[] tmp = new boolean[] {true,false,true};
81
    boolean[][] layerRotatable = new boolean[numAxis][];
82
    for(int i=0; i<numAxis; i++) layerRotatable[i] = tmp;
83

    
84
    return layerRotatable;
85
    }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public int getTouchControlType()
90
    {
91
    return TC_HEXAHEDRON;
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public int getTouchControlSplit()
97
    {
98
    return TYPE_SPLIT_CORNER;
99
    }
100

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

    
103
  public int[][][] getEnabled()
104
    {
105
    return new int[][][]
106
      {
107
          {{0,1},{3,1},{2,3},{0,2}},
108
          {{2,3},{3,1},{0,1},{0,2}},
109
          {{1,2},{0,1},{0,3},{2,3}},
110
          {{1,2},{2,3},{0,3},{0,1}},
111
          {{0,3},{0,2},{1,2},{1,3}},
112
          {{1,2},{0,2},{0,3},{1,3}},
113
      };
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

    
118
  public float[] getDist3D(int[] numLayers)
119
    {
120
    return TouchControlHexahedron.D3D;
121
    }
122

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

    
125
  public Static3D[] getFaceAxis()
126
    {
127
    return TouchControlHexahedron.FACE_AXIS;
128
    }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
  public float[][] getCubitPositions(int[] numLayers)
133
    {
134
    if( mCenters ==null )
135
      {
136
      mCenters = new float[][]
137
         {
138
             { 0.0f, 1.5f, 1.5f },
139
             { 1.5f, 0.0f, 1.5f },
140
             { 0.0f,-1.5f, 1.5f },
141
             {-1.5f, 0.0f, 1.5f },
142
             { 1.5f, 1.5f, 0.0f },
143
             { 1.5f,-1.5f, 0.0f },
144
             {-1.5f,-1.5f, 0.0f },
145
             {-1.5f, 1.5f, 0.0f },
146
             { 0.0f, 1.5f,-1.5f },
147
             { 1.5f, 0.0f,-1.5f },
148
             { 0.0f,-1.5f,-1.5f },
149
             {-1.5f, 0.0f,-1.5f }
150
         };
151
      }
152

    
153
    return mCenters;
154
    }
155

    
156
///////////////////////////////////////////////////////////////////////////////////////////////////
157

    
158
  public Static4D getCubitQuats(int cubit, int[] numLayers)
159
    {
160
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,10,8,1,4,6,7,11,5,9,3 };
161
    return mObjectQuats[mQuatIndex[cubit]];
162
    }
163

    
164
///////////////////////////////////////////////////////////////////////////////////////////////////
165

    
166
  public ObjectShape getObjectShape(int variant)
167
    {
168
    float[][] vertices= { {-1.5f, 0.0f, 0.0f},{ 1.5f, 0.0f, 0.0f},{ 0.0f,-1.5f, 0.0f},{ 0.0f, 0.0f,-1.5f} };
169
    int[][] indices   = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
170
    return new ObjectShape(vertices, indices);
171
    }
172

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174

    
175
  public ObjectFaceShape getObjectFaceShape(int variant)
176
    {
177
    float h1 = isInIconMode() ? 0.001f : 0.035f;
178
    float h2 = isInIconMode() ? 0.001f : 0.010f;
179
    float[][] bands     = { {h1,30,0.16f,0.8f,6,2,2}, {h2,30,0.16f,0.2f,6,2,2} };
180
    int[] bandIndices   = { 0,0,1,1 };
181
    float[][] corners   = { {0.07f,0.40f}, {0.05f,0.30f} };
182
    int[] cornerIndices = { 0,0,1,1 };
183
    float[][] centers   = { {0.0f, -0.75f, -0.75f} };
184
    int[] centerIndices = { 0,0,0,0 };
185
    return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices, null);
186
    }
187

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

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

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

    
197
  public int getCubitVariant(int cubit, int[] numLayers)
198
    {
199
    return 0;
200
    }
201

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

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

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

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

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

    
218
  public float[][] getStickerAngles()
219
    {
220
    return null;
221
    }
222

    
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224
// PUBLIC API
225

    
226
  public Static3D[] getRotationAxis()
227
    {
228
    return ROT_AXIS;
229
    }
230

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

    
233
  public int[][] getBasicAngles()
234
    {
235
    if( mBasicAngle==null )
236
      {
237
      int num = getNumLayers()[0];
238
      int[] tmp = new int[num];
239
      for(int i=0; i<num; i++) tmp[i] = 3;
240
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
241
      }
242

    
243
    return mBasicAngle;
244
    }
245

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

    
248
  public int getComplexity()
249
    {
250
    return 0;
251
    }
252
}
(13-13/40)