Project

General

Profile

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

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

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 Twisty6
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 int[] mBasicAngle;
47
  private Static4D[] mQuats;
48
  private ObjectSticker[] mStickers;
49
  private float[][] mCenters;
50
  private Movement mMovement;
51
  ScrambleState[] mStates;
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  TwistyDino(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
56
             DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
57
    {
58
    super(size, size, quat, texture, mesh, effects, moves, obj, res, scrWidth);
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  private void initializeQuats()
64
    {
65
    mQuats = new Static4D[]
66
         {
67
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
68
         new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
69
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
70
         new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
71
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
72
         new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
73
         new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
74
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
75
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
76
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
77
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
78
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f )
79
         };
80
    }
81

    
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

    
84
  Static4D[] getQuats()
85
    {
86
    if( mQuats==null ) initializeQuats();
87
    return mQuats;
88
    }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  float[][] getCuts(int size)
93
    {
94
    float[] cut = new float[] { -SQ3/3, +SQ3/3 };
95
    return new float[][] { cut,cut,cut,cut };
96
    }
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  int getNumStickerTypes(int numLayers)
101
    {
102
    return 1;
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

    
107
  int getNumCubitFaces()
108
    {
109
    return 4;
110
    }
111

    
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

    
114
  float[][] getCubitPositions(int size)
115
    {
116
    if( mCenters ==null )
117
      {
118
      mCenters = new float[][]
119
         {
120
             { 0.0f, 1.5f, 1.5f },
121
             { 1.5f, 0.0f, 1.5f },
122
             { 0.0f,-1.5f, 1.5f },
123
             {-1.5f, 0.0f, 1.5f },
124
             { 1.5f, 1.5f, 0.0f },
125
             { 1.5f,-1.5f, 0.0f },
126
             {-1.5f,-1.5f, 0.0f },
127
             {-1.5f, 1.5f, 0.0f },
128
             { 0.0f, 1.5f,-1.5f },
129
             { 1.5f, 0.0f,-1.5f },
130
             { 0.0f,-1.5f,-1.5f },
131
             {-1.5f, 0.0f,-1.5f }
132
         };
133
      }
134

    
135
    return mCenters;
136
    }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

    
140
  ObjectShape getObjectShape(int cubit, int numLayers)
141
    {
142
    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} };
143
    int[][] vert_indices= new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
144
    float[][] bands     = new float[][] { {0.035f,30,0.16f,0.8f,6,2,2}, {0.010f,30,0.16f,0.2f,6,2,2} };
145
    int[] bandIndices   = new int[] { 0,0,1,1 };
146
    float[][] corners   = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} };
147
    int[] cornerIndices = new int[] { 0,0,1,1 };
148
    float[][] centers   = new float[][] { {0.0f, -0.75f, -0.75f} };
149
    int[] centerIndices = new int[] { 0,0,0,0 };
150
    return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
151
    }
152

    
153
///////////////////////////////////////////////////////////////////////////////////////////////////
154

    
155
  Static4D getQuat(int cubit, int numLayers)
156
    {
157
    if( mQuats==null ) initializeQuats();
158
    return mQuats[cubit];
159
    }
160

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

    
163
  int getNumCubitVariants(int numLayers)
164
    {
165
    return 1;
166
    }
167

    
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

    
170
  int getCubitVariant(int cubit, int numLayers)
171
    {
172
    return 0;
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

    
177
  ObjectSticker retSticker(int face)
178
    {
179
    if( mStickers==null )
180
      {
181
      float[][] STICKERS = new float[][] { { 0.0f, -1.0f/3, 0.5f, 1.0f/6, -0.5f, 1.0f/6 } };
182
      float radius = 0.025f;
183
      float stroke = 0.050f;
184
      float[] radii = new float[] {radius,radius,radius};
185
      mStickers     = new ObjectSticker[STICKERS.length];
186
      mStickers[0]  = new ObjectSticker(STICKERS[0],null,radii,stroke);
187
      }
188

    
189
    return mStickers[face/NUM_FACE_COLORS];
190
    }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193
// PUBLIC API
194

    
195
  public Static3D[] getRotationAxis()
196
    {
197
    return ROT_AXIS;
198
    }
199

    
200
///////////////////////////////////////////////////////////////////////////////////////////////////
201

    
202
  public Movement getMovement()
203
    {
204
    if( mMovement==null ) mMovement = new MovementCornerTwisting();
205
    return mMovement;
206
    }
207

    
208
///////////////////////////////////////////////////////////////////////////////////////////////////
209

    
210
  public int[] getBasicAngle()
211
    {
212
    if( mBasicAngle==null ) mBasicAngle = new int[] { 3,3,3,3 };
213
    return mBasicAngle;
214
    }
215

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

    
218
  public int getComplexity(int numLayers)
219
    {
220
    return 2;
221
    }
222
}
(29-29/48)