Project

General

Profile

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

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

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