Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
23
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
24 29b82486 Leszek Koltunski
25 82eb152a Leszek Koltunski
import java.io.InputStream;
26 29b82486 Leszek Koltunski
27
import org.distorted.library.type.Static3D;
28
import org.distorted.library.type.Static4D;
29
30 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
31 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
32 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
33 386af988 Leszek Koltunski
import org.distorted.objectlib.main.ShapeHexahedron;
34 4c9ca251 Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
35 29b82486 Leszek Koltunski
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37
38 386af988 Leszek Koltunski
abstract class TwistyDino extends ShapeHexahedron
39 29b82486 Leszek Koltunski
{
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 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
49 29b82486 Leszek Koltunski
  private float[][] mCuts;
50
  private float[][] mCenters;
51
  ScrambleState[] mStates;
52 802fe251 Leszek Koltunski
  private int[] mQuatIndex;
53 29b82486 Leszek Koltunski
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56 3bf19410 Leszek Koltunski
  TwistyDino(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
57 29b82486 Leszek Koltunski
    {
58 3bf19410 Leszek Koltunski
    super(numL, meshState, iconMode, numL[0], quat, move, scale, stream);
59 29b82486 Leszek Koltunski
    }
60
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62
63 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
64 29b82486 Leszek Koltunski
    {
65
    if( mCuts==null )
66
      {
67
      float[] cut = new float[] { -SQ3/3, +SQ3/3 };
68
      mCuts = new float[][] { cut,cut,cut,cut };
69
      }
70
71
    return mCuts;
72
    }
73
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
76 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
77 29b82486 Leszek Koltunski
    {
78 59c20632 Leszek Koltunski
    int numAxis = ROT_AXIS.length;
79
    boolean[] tmp = new boolean[] {true,false,true};
80
    boolean[][] layerRotatable = new boolean[numAxis][];
81
    for(int i=0; i<numAxis; i++) layerRotatable[i] = tmp;
82
83
    return layerRotatable;
84
    }
85
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87
88 11fa413d Leszek Koltunski
  public int getTouchControlType()
89 59c20632 Leszek Koltunski
    {
90 c9c71c3f Leszek Koltunski
    return TC_HEXAHEDRON;
91 59c20632 Leszek Koltunski
    }
92
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94
95 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
96 59c20632 Leszek Koltunski
    {
97
    return TYPE_SPLIT_CORNER;
98
    }
99
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101
102
  public int[][][] getEnabled()
103
    {
104
    return new int[][][]
105 29b82486 Leszek Koltunski
      {
106 59c20632 Leszek Koltunski
          {{0,1},{3,1},{2,3},{0,2}},
107
          {{2,3},{3,1},{0,1},{0,2}},
108
          {{1,2},{0,1},{0,3},{2,3}},
109
          {{1,2},{2,3},{0,3},{0,1}},
110
          {{0,3},{0,2},{1,2},{1,3}},
111
          {{1,2},{0,2},{0,3},{1,3}},
112
      };
113
    }
114
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116
117
  public float[] getDist3D(int[] numLayers)
118
    {
119 4c9ca251 Leszek Koltunski
    return TouchControlHexahedron.D3D;
120
    }
121
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123
124
  public Static3D[] getFaceAxis()
125
    {
126
    return TouchControlHexahedron.FACE_AXIS;
127 29b82486 Leszek Koltunski
    }
128
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130
131 7b832206 Leszek Koltunski
  public float[][] getCubitPositions(int[] numLayers)
132 29b82486 Leszek Koltunski
    {
133
    if( mCenters ==null )
134
      {
135
      mCenters = new float[][]
136
         {
137
             { 0.0f, 1.5f, 1.5f },
138
             { 1.5f, 0.0f, 1.5f },
139
             { 0.0f,-1.5f, 1.5f },
140
             {-1.5f, 0.0f, 1.5f },
141
             { 1.5f, 1.5f, 0.0f },
142
             { 1.5f,-1.5f, 0.0f },
143
             {-1.5f,-1.5f, 0.0f },
144
             {-1.5f, 1.5f, 0.0f },
145
             { 0.0f, 1.5f,-1.5f },
146
             { 1.5f, 0.0f,-1.5f },
147
             { 0.0f,-1.5f,-1.5f },
148
             {-1.5f, 0.0f,-1.5f }
149
         };
150
      }
151
152
    return mCenters;
153
    }
154
155 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
156
157
  public Static4D getCubitQuats(int cubit, int[] numLayers)
158
    {
159 802fe251 Leszek Koltunski
    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,2,10,8,1,4,6,7,11,5,9,3 };
160
    return mObjectQuats[mQuatIndex[cubit]];
161 d0e6cf7f Leszek Koltunski
    }
162
163 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
164
165 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
166 29b82486 Leszek Koltunski
    {
167 4e9f2df5 Leszek Koltunski
    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} };
168
    int[][] indices   = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
169 59a971c1 Leszek Koltunski
    return new ObjectShape(vertices, indices);
170 3ee1d662 Leszek Koltunski
    }
171
172
///////////////////////////////////////////////////////////////////////////////////////////////////
173
174
  public ObjectFaceShape getObjectFaceShape(int variant)
175
    {
176 3bf19410 Leszek Koltunski
    float h1 = isInIconMode() ? 0.001f : 0.035f;
177
    float h2 = isInIconMode() ? 0.001f : 0.010f;
178
    float[][] bands     = { {h1,30,0.16f,0.8f,6,2,2}, {h2,30,0.16f,0.2f,6,2,2} };
179 4e9f2df5 Leszek Koltunski
    int[] bandIndices   = { 0,0,1,1 };
180
    float[][] corners   = { {0.07f,0.40f}, {0.05f,0.30f} };
181
    int[] cornerIndices = { 0,0,1,1 };
182
    float[][] centers   = { {0.0f, -0.75f, -0.75f} };
183
    int[] centerIndices = { 0,0,0,0 };
184 3ee1d662 Leszek Koltunski
    return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices, null);
185 29b82486 Leszek Koltunski
    }
186
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188
189 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
190 29b82486 Leszek Koltunski
    {
191
    return 1;
192
    }
193
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195
196 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
197 29b82486 Leszek Koltunski
    {
198
    return 0;
199
    }
200
201 3d766df3 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
202
203 d53fb890 Leszek Koltunski
  public float getStickerRadius()
204 3d766df3 Leszek Koltunski
    {
205 00f4980d Leszek Koltunski
    return 0.09f;
206 3d766df3 Leszek Koltunski
    }
207
208
///////////////////////////////////////////////////////////////////////////////////////////////////
209
210 d53fb890 Leszek Koltunski
  public float getStickerStroke()
211 3d766df3 Leszek Koltunski
    {
212 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.22f : 0.15f;
213 3d766df3 Leszek Koltunski
    }
214
215 00f4980d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
216
217 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
218 00f4980d Leszek Koltunski
    {
219
    return null;
220
    }
221
222 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
223
// PUBLIC API
224
225
  public Static3D[] getRotationAxis()
226
    {
227
    return ROT_AXIS;
228
    }
229
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231
232 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
233 29b82486 Leszek Koltunski
    {
234 beee90ab Leszek Koltunski
    if( mBasicAngle==null )
235
      {
236
      int num = getNumLayers()[0];
237
      int[] tmp = new int[num];
238
      for(int i=0; i<num; i++) tmp[i] = 3;
239
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
240
      }
241
242 29b82486 Leszek Koltunski
    return mBasicAngle;
243
    }
244
245
///////////////////////////////////////////////////////////////////////////////////////////////////
246
247 e26eb4e7 Leszek Koltunski
  public int getComplexity()
248 29b82486 Leszek Koltunski
    {
249 b4223a92 Leszek Koltunski
    return 0;
250 29b82486 Leszek Koltunski
    }
251
}