Project

General

Profile

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

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

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
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(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
58
    {
59
    super(numL, meshState, numL[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[][] bands     = { {0.035f,30,0.16f,0.8f,6,2,2}, {0.010f,30,0.16f,0.2f,6,2,2} };
178
    int[] bandIndices   = { 0,0,1,1 };
179
    float[][] corners   = { {0.07f,0.40f}, {0.05f,0.30f} };
180
    int[] cornerIndices = { 0,0,1,1 };
181
    float[][] centers   = { {0.0f, -0.75f, -0.75f} };
182
    int[] centerIndices = { 0,0,0,0 };
183
    return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices, null);
184
    }
185

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

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

    
193
///////////////////////////////////////////////////////////////////////////////////////////////////
194

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

    
200
///////////////////////////////////////////////////////////////////////////////////////////////////
201

    
202
  public float getStickerRadius()
203
    {
204
    return 0.09f;
205
    }
206

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

    
209
  public float getStickerStroke()
210
    {
211
    return ObjectControl.isInIconMode() ? 0.22f : 0.15f;
212
    }
213

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

    
216
  public float[][] getStickerAngles()
217
    {
218
    return null;
219
    }
220

    
221
///////////////////////////////////////////////////////////////////////////////////////////////////
222
// PUBLIC API
223

    
224
  public Static3D[] getRotationAxis()
225
    {
226
    return ROT_AXIS;
227
    }
228

    
229
///////////////////////////////////////////////////////////////////////////////////////////////////
230

    
231
  public int[] getBasicAngles()
232
    {
233
    if( mBasicAngle==null ) mBasicAngle = new int[] { 3,3,3,3 };
234
    return mBasicAngle;
235
    }
236

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

    
239
  public int getComplexity()
240
    {
241
    return 0;
242
    }
243
}
(8-8/26)