Project

General

Profile

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

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

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
  ScrambleState[] mStates;
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

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

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  private void initializeQuats()
70
    {
71
    mQuats = new Static4D[]
72
         {
73
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
74
         new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
75
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
76
         new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
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.0f,  1.0f,  0.0f,  0.0f ),
82
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
83
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
84
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f )
85
         };
86
    }
87

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

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

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

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

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

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

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

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

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

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

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

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

    
155
    return mCenters;
156
    }
157

    
158
///////////////////////////////////////////////////////////////////////////////////////////////////
159

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

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174

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

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

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

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189

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

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

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

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

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

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

    
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

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

    
226
///////////////////////////////////////////////////////////////////////////////////////////////////
227
// PUBLIC API
228

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

    
234
///////////////////////////////////////////////////////////////////////////////////////////////////
235

    
236
  public int[] getBasicAngle()
237
    {
238
    if( mBasicAngle==null ) mBasicAngle = new int[] { 3,3,3,3 };
239
    return mBasicAngle;
240
    }
241

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

    
244
  public int getComplexity(int numLayers)
245
    {
246
    return 2;
247
    }
248
}
(24-24/43)