Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_HEXAHEDRON;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_SPLIT_CORNER;
14

    
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17

    
18
import org.distorted.objectlib.helpers.FactoryCubit;
19
import org.distorted.objectlib.helpers.ObjectFaceShape;
20
import org.distorted.objectlib.helpers.ObjectShape;
21
import org.distorted.objectlib.helpers.ObjectVertexEffects;
22
import org.distorted.objectlib.main.InitAssets;
23
import org.distorted.objectlib.main.InitData;
24
import org.distorted.objectlib.shape.ShapeHexahedron;
25
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
26

    
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

    
29
abstract class TwistyDino extends ShapeHexahedron
30
{
31
  static final Static3D[] ROT_AXIS = new Static3D[]
32
         {
33
           new Static3D( SQ3/3, SQ3/3, SQ3/3),
34
           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
         };
38

    
39
  private int[][] mBasicAngle;
40
  private float[][] mCuts;
41
  private float[][] mCenters;
42
  private int[] mQuatIndex;
43
  int[][] mEdges;
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  TwistyDino(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
48
    {
49
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  @Override
55
  public float[][] returnRotationFactor()
56
    {
57
    float C = 1.5f;
58
    float[] f = new float[] { C,C,C };
59
    return new float[][] { f,f,f,f };
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,3,5,7,11,6,9,4 };
161
    return mObjectQuats[mQuatIndex[cubit]];
162
    }
163

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

    
166
  private float[][] getVertices(int variant)
167
    {
168
    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} };
169
    //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},{0,0,0} };
170
    }
171

    
172
///////////////////////////////////////////////////////////////////////////////////////////////////
173

    
174
  public ObjectShape getObjectShape(int variant)
175
    {
176
    int[][] indices = { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
177
    //int[][][] indices = { {{2,4,0},{2,1,4}},{{3,0,4},{4,1,3}},{{2,3,1}},{{3,2,0}} };
178
    return new ObjectShape(getVertices(variant), indices);
179
    }
180

    
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182

    
183
  public ObjectFaceShape getObjectFaceShape(int variant)
184
    {
185
    float h1 = isInIconMode() ? 0.001f : 0.035f;
186
    float h2 = isInIconMode() ? 0.001f : 0.010f;
187
    float[][] bands  = { {h1,30,0.16f,0.8f,6,1,2}, {h2,30,0.16f,0.8f,6,1,2} };
188
    int[] bandIndices= { 0,0,1,1 };
189
    return new ObjectFaceShape(bands,bandIndices,null);
190
    }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

    
194
  public ObjectVertexEffects getVertexEffects(int variant)
195
    {
196
    float[][] corners   = { {0.07f,0.40f}, {0.05f,0.30f} };
197
    int[] cornerIndices = { 0,0,1,1,/*-1*/ };
198
    float[][] centers   = { {0.0f, -0.75f, -0.75f} };
199
    int[] centerIndices = { 0,0,0,0,/*-1*/ };
200
    return FactoryCubit.generateVertexEffect(getVertices(variant),corners,cornerIndices,centers,centerIndices);
201
    }
202

    
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204

    
205
  public int getNumCubitVariants(int[] numLayers)
206
    {
207
    return 1;
208
    }
209

    
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211

    
212
  public int getCubitVariant(int cubit, int[] numLayers)
213
    {
214
    return 0;
215
    }
216

    
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218

    
219
  public float getStickerRadius()
220
    {
221
    return 0.09f;
222
    }
223

    
224
///////////////////////////////////////////////////////////////////////////////////////////////////
225

    
226
  public float getStickerStroke()
227
    {
228
    return isInIconMode() ? 0.22f : 0.15f;
229
    }
230

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

    
233
  public float[][] getStickerAngles()
234
    {
235
    return null;
236
    }
237

    
238
///////////////////////////////////////////////////////////////////////////////////////////////////
239
// PUBLIC API
240

    
241
  public Static3D[] getRotationAxis()
242
    {
243
    return ROT_AXIS;
244
    }
245

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

    
248
  public int[][] getBasicAngles()
249
    {
250
    if( mBasicAngle==null )
251
      {
252
      int[] tmp = {3,3,3};
253
      mBasicAngle = new int[][] { tmp,tmp,tmp,tmp };
254
      }
255

    
256
    return mBasicAngle;
257
    }
258

    
259
///////////////////////////////////////////////////////////////////////////////////////////////////
260

    
261
  public int getComplexity()
262
    {
263
    return 0;
264
    }
265
}
(14-14/47)