Project

General

Profile

Download (9.06 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / TwistyDino.java @ e9a87113

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.objects;
21

    
22
import android.content.res.Resources;
23

    
24
import org.distorted.helpers.ObjectShape;
25
import org.distorted.helpers.ObjectSticker;
26
import org.distorted.helpers.ScrambleState;
27
import org.distorted.library.main.DistortedEffects;
28
import org.distorted.library.main.DistortedTexture;
29
import org.distorted.library.mesh.MeshSquare;
30
import org.distorted.library.type.Static3D;
31
import org.distorted.library.type.Static4D;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

    
35
public abstract class TwistyDino extends TwistyObject
36
{
37
  // the four rotation axis of a RubikDino. Must be normalized.
38
  static final Static3D[] ROT_AXIS = new Static3D[]
39
         {
40
           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
41
           new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
42
           new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
43
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
44
         };
45

    
46
  private static final int[] FACE_COLORS = new int[]
47
         {
48
           COLOR_YELLOW, COLOR_WHITE,
49
           COLOR_BLUE  , COLOR_GREEN,
50
           COLOR_RED   , COLOR_ORANGE
51
         };
52

    
53
  private int[] mBasicAngle;
54
  private Static4D[] mQuats;
55
  private ObjectSticker[] mStickers;
56
  private float[][] mCenters;
57
  private Movement mMovement;
58
  ScrambleState[] mStates;
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
  TwistyDino(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
63
             DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
64
    {
65
    super(size, size, quat, texture, mesh, effects, moves, obj, res, scrWidth);
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  private void initializeQuats()
71
    {
72
    mQuats = new Static4D[]
73
         {
74
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
75
         new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
76
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
77
         new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
78
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
79
         new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
80
         new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
81
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
82
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
83
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
84
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
85
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f )
86
         };
87
    }
88

    
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

    
91
  float getScreenRatio()
92
    {
93
    return 0.5f;
94
    }
95

    
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97

    
98
  Static4D[] getQuats()
99
    {
100
    if( mQuats==null ) initializeQuats();
101
    return mQuats;
102
    }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
  int getNumFaceColors()
107
    {
108
    return FACE_COLORS.length;
109
    }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

    
113
  float[][] getCuts(int size)
114
    {
115
    float[] cut = new float[] { -SQ3/3, +SQ3/3 };
116
    return new float[][] { cut,cut,cut,cut };
117
    }
118

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

    
121
  int getNumStickerTypes(int numLayers)
122
    {
123
    return 1;
124
    }
125

    
126
///////////////////////////////////////////////////////////////////////////////////////////////////
127

    
128
  int getNumCubitFaces()
129
    {
130
    return 4;
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  float[][] getCubitPositions(int size)
136
    {
137
    if( mCenters ==null )
138
      {
139
      mCenters = new float[][]
140
         {
141
             { 0.0f, 1.5f, 1.5f },
142
             { 1.5f, 0.0f, 1.5f },
143
             { 0.0f,-1.5f, 1.5f },
144
             {-1.5f, 0.0f, 1.5f },
145
             { 1.5f, 1.5f, 0.0f },
146
             { 1.5f,-1.5f, 0.0f },
147
             {-1.5f,-1.5f, 0.0f },
148
             {-1.5f, 1.5f, 0.0f },
149
             { 0.0f, 1.5f,-1.5f },
150
             { 1.5f, 0.0f,-1.5f },
151
             { 0.0f,-1.5f,-1.5f },
152
             {-1.5f, 0.0f,-1.5f }
153
         };
154
      }
155

    
156
    return mCenters;
157
    }
158

    
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

    
161
  ObjectShape getObjectShape(int cubit, int numLayers)
162
    {
163
    double[][] vertices = new double[][] { {-1.5, 0.0, 0.0},{ 1.5, 0.0, 0.0},{ 0.0,-1.5, 0.0},{ 0.0, 0.0,-1.5} };
164
    int[][] vert_indices= new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
165
    float[][] bands     = new float[][] { {0.035f,30,0.16f,0.8f,6,2,2}, {0.010f,30,0.16f,0.2f,6,2,2} };
166
    int[] bandIndices   = new int[] { 0,0,1,1 };
167
    float[][] corners   = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} };
168
    int[] cornerIndices = new int[] { 0,0,1,1 };
169
    float[][] centers   = new float[][] { {0.0f, -0.75f, -0.75f} };
170
    int[] centerIndices = new int[] { 0,0,0,0 };
171
    return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
172
    }
173

    
174
///////////////////////////////////////////////////////////////////////////////////////////////////
175

    
176
  Static4D getQuat(int cubit, int numLayers)
177
    {
178
    if( mQuats==null ) initializeQuats();
179
    return mQuats[cubit];
180
    }
181

    
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183

    
184
  int getNumCubitVariants(int numLayers)
185
    {
186
    return 1;
187
    }
188

    
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190

    
191
  int getCubitVariant(int cubit, int numLayers)
192
    {
193
    return 0;
194
    }
195

    
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197

    
198
  int getColor(int face)
199
    {
200
    return FACE_COLORS[face];
201
    }
202

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

    
205
  ObjectSticker retSticker(int face)
206
    {
207
    if( mStickers==null )
208
      {
209
      float[][] STICKERS = new float[][] { { 0.0f, -1.0f/3, 0.5f, 1.0f/6, -0.5f, 1.0f/6 } };
210
      float radius = 0.025f;
211
      float stroke = 0.050f;
212
      float[] radii = new float[] {radius,radius,radius};
213
      mStickers     = new ObjectSticker[STICKERS.length];
214
      mStickers[0]  = new ObjectSticker(STICKERS[0],null,radii,stroke);
215
      }
216

    
217
    return mStickers[face/NUM_FACE_COLORS];
218
    }
219

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221

    
222
  float returnMultiplier()
223
    {
224
    return 2.0f;
225
    }
226

    
227
///////////////////////////////////////////////////////////////////////////////////////////////////
228
// PUBLIC API
229

    
230
  public Static3D[] getRotationAxis()
231
    {
232
    return ROT_AXIS;
233
    }
234

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

    
237
  public Movement getMovement()
238
    {
239
    if( mMovement==null ) mMovement = new MovementCornerTwisting();
240
    return mMovement;
241
    }
242

    
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244

    
245
  public int[] getBasicAngle()
246
    {
247
    if( mBasicAngle==null ) mBasicAngle = new int[] { 3,3,3,3 };
248
    return mBasicAngle;
249
    }
250

    
251
///////////////////////////////////////////////////////////////////////////////////////////////////
252

    
253
  public int getComplexity(int numLayers)
254
    {
255
    return 2;
256
    }
257
}
(25-25/44)