Project

General

Profile

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

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

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.helpers.ScrambleState;
33
import org.distorted.objectlib.main.ObjectControl;
34
import org.distorted.objectlib.main.ShapeHexahedron;
35

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

    
38
abstract class TwistyDino extends ShapeHexahedron
39
{
40
  static final Static3D[] ROT_AXIS = new Static3D[]
41
         {
42
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
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
         };
47

    
48
  private int[] mBasicAngle;
49
  private Static4D[] mQuats;
50
  private float[][] mCuts;
51
  private float[][] mCenters;
52
  ScrambleState[] mStates;
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

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

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  private void initializeQuats()
64
    {
65
    mQuats = new Static4D[]
66
         {
67
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
68
         new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
69
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
70
         new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
71
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
72
         new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
73
         new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
74
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
75
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
76
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
77
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
78
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f )
79
         };
80
    }
81

    
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

    
84
  public Static4D[] getQuats()
85
    {
86
    if( mQuats==null ) initializeQuats();
87
    return mQuats;
88
    }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  public float[][] getCuts(int[] numLayers)
93
    {
94
    if( mCuts==null )
95
      {
96
      float[] cut = new float[] { -SQ3/3, +SQ3/3 };
97
      mCuts = new float[][] { cut,cut,cut,cut };
98
      }
99

    
100
    return mCuts;
101
    }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  public boolean[][] getLayerRotatable(int[] numLayers)
106
    {
107
    int numAxis = ROT_AXIS.length;
108
    boolean[] tmp = new boolean[] {true,false,true};
109
    boolean[][] layerRotatable = new boolean[numAxis][];
110
    for(int i=0; i<numAxis; i++) layerRotatable[i] = tmp;
111

    
112
    return layerRotatable;
113
    }
114

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

    
117
  public int getTouchControlType()
118
    {
119
    return TC_HEXAHEDRON;
120
    }
121

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

    
124
  public int getTouchControlSplit()
125
    {
126
    return TYPE_SPLIT_CORNER;
127
    }
128

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

    
131
  public int[][][] getEnabled()
132
    {
133
    return new int[][][]
134
      {
135
          {{0,1},{3,1},{2,3},{0,2}},
136
          {{2,3},{3,1},{0,1},{0,2}},
137
          {{1,2},{0,1},{0,3},{2,3}},
138
          {{1,2},{2,3},{0,3},{0,1}},
139
          {{0,3},{0,2},{1,2},{1,3}},
140
          {{1,2},{0,2},{0,3},{1,3}},
141
      };
142
    }
143

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145

    
146
  public float[] getDist3D(int[] numLayers)
147
    {
148
    return null;
149
    }
150

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

    
153
  public float[][] getCubitPositions(int[] numLayers)
154
    {
155
    if( mCenters ==null )
156
      {
157
      mCenters = new float[][]
158
         {
159
             { 0.0f, 1.5f, 1.5f },
160
             { 1.5f, 0.0f, 1.5f },
161
             { 0.0f,-1.5f, 1.5f },
162
             {-1.5f, 0.0f, 1.5f },
163
             { 1.5f, 1.5f, 0.0f },
164
             { 1.5f,-1.5f, 0.0f },
165
             {-1.5f,-1.5f, 0.0f },
166
             {-1.5f, 1.5f, 0.0f },
167
             { 0.0f, 1.5f,-1.5f },
168
             { 1.5f, 0.0f,-1.5f },
169
             { 0.0f,-1.5f,-1.5f },
170
             {-1.5f, 0.0f,-1.5f }
171
         };
172
      }
173

    
174
    return mCenters;
175
    }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

    
179
  public ObjectShape getObjectShape(int variant)
180
    {
181
    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} };
182
    int[][] indices   = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
183
    return new ObjectShape(vertices, indices, 2);
184
    }
185

    
186
///////////////////////////////////////////////////////////////////////////////////////////////////
187

    
188
  public ObjectFaceShape getObjectFaceShape(int variant)
189
    {
190
    float[][] bands     = { {0.035f,30,0.16f,0.8f,6,2,2}, {0.010f,30,0.16f,0.2f,6,2,2} };
191
    int[] bandIndices   = { 0,0,1,1 };
192
    float[][] corners   = { {0.07f,0.40f}, {0.05f,0.30f} };
193
    int[] cornerIndices = { 0,0,1,1 };
194
    float[][] centers   = { {0.0f, -0.75f, -0.75f} };
195
    int[] centerIndices = { 0,0,0,0 };
196
    return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices, null);
197
    }
198

    
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200

    
201
  public Static4D getQuat(int cubit, int[] numLayers)
202
    {
203
    if( mQuats==null ) initializeQuats();
204
    return mQuats[cubit];
205
    }
206

    
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208

    
209
  public int getNumCubitVariants(int[] numLayers)
210
    {
211
    return 1;
212
    }
213

    
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215

    
216
  public int getCubitVariant(int cubit, int[] numLayers)
217
    {
218
    return 0;
219
    }
220

    
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222

    
223
  public float getStickerRadius()
224
    {
225
    return 0.09f;
226
    }
227

    
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229

    
230
  public float getStickerStroke()
231
    {
232
    return ObjectControl.isInIconMode() ? 0.22f : 0.15f;
233
    }
234

    
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

    
237
  public float[][] getStickerAngles()
238
    {
239
    return null;
240
    }
241

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243
// PUBLIC API
244

    
245
  public Static3D[] getRotationAxis()
246
    {
247
    return ROT_AXIS;
248
    }
249

    
250
///////////////////////////////////////////////////////////////////////////////////////////////////
251

    
252
  public int[] getBasicAngle()
253
    {
254
    if( mBasicAngle==null ) mBasicAngle = new int[] { 3,3,3,3 };
255
    return mBasicAngle;
256
    }
257

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

    
260
  public int getComplexity()
261
    {
262
    return 0;
263
    }
264
}
(8-8/26)