1 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
f10a88a8
|
Leszek Koltunski
|
import org.distorted.helpers.ObjectShape;
|
25 |
9c06394a
|
Leszek Koltunski
|
import org.distorted.helpers.ObjectSticker;
|
26 |
6cf89a3e
|
Leszek Koltunski
|
import org.distorted.helpers.ScrambleState;
|
27 |
418aa554
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedEffects;
|
28 |
|
|
import org.distorted.library.main.DistortedTexture;
|
29 |
efa8aa48
|
Leszek Koltunski
|
import org.distorted.library.mesh.MeshSquare;
|
30 |
418aa554
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
31 |
|
|
import org.distorted.library.type.Static4D;
|
32 |
|
|
|
33 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34 |
|
|
|
35 |
efa81f0c
|
Leszek Koltunski
|
public abstract class TwistyDino extends Twisty6
|
36 |
418aa554
|
Leszek Koltunski
|
{
|
37 |
|
|
// the four rotation axis of a RubikDino. Must be normalized.
|
38 |
ad38d800
|
Leszek Koltunski
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
39 |
418aa554
|
Leszek Koltunski
|
{
|
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 |
d464f54f
|
Leszek Koltunski
|
private int[] mBasicAngle;
|
47 |
|
|
private Static4D[] mQuats;
|
48 |
|
|
private ObjectSticker[] mStickers;
|
49 |
85449b44
|
Leszek Koltunski
|
private float[][] mCenters;
|
50 |
e9a87113
|
Leszek Koltunski
|
private Movement mMovement;
|
51 |
d464f54f
|
Leszek Koltunski
|
ScrambleState[] mStates;
|
52 |
20898e6f
|
Leszek Koltunski
|
|
53 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54 |
|
|
|
55 |
9c2f0c91
|
Leszek Koltunski
|
TwistyDino(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
56 |
|
|
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
|
57 |
418aa554
|
Leszek Koltunski
|
{
|
58 |
db875721
|
Leszek Koltunski
|
super(size, size, quat, texture, mesh, effects, moves, obj, res, scrWidth);
|
59 |
418aa554
|
Leszek Koltunski
|
}
|
60 |
|
|
|
61 |
d464f54f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83 |
|
|
|
84 |
|
|
Static4D[] getQuats()
|
85 |
|
|
{
|
86 |
d464f54f
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
87 |
|
|
return mQuats;
|
88 |
418aa554
|
Leszek Koltunski
|
}
|
89 |
|
|
|
90 |
7403cdfa
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91 |
|
|
|
92 |
e6734aa9
|
Leszek Koltunski
|
float[][] getCuts(int size)
|
93 |
7403cdfa
|
Leszek Koltunski
|
{
|
94 |
e6734aa9
|
Leszek Koltunski
|
float[] cut = new float[] { -SQ3/3, +SQ3/3 };
|
95 |
|
|
return new float[][] { cut,cut,cut,cut };
|
96 |
7403cdfa
|
Leszek Koltunski
|
}
|
97 |
|
|
|
98 |
eab9d8f8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99 |
|
|
|
100 |
a64e07d0
|
Leszek Koltunski
|
int getNumStickerTypes(int numLayers)
|
101 |
eab9d8f8
|
Leszek Koltunski
|
{
|
102 |
d464f54f
|
Leszek Koltunski
|
return 1;
|
103 |
eab9d8f8
|
Leszek Koltunski
|
}
|
104 |
|
|
|
105 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
106 |
|
|
|
107 |
8f53e513
|
Leszek Koltunski
|
int getNumCubitFaces()
|
108 |
418aa554
|
Leszek Koltunski
|
{
|
109 |
8f53e513
|
Leszek Koltunski
|
return 4;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113 |
418aa554
|
Leszek Koltunski
|
|
114 |
e6cf7283
|
Leszek Koltunski
|
float[][] getCubitPositions(int size)
|
115 |
8f53e513
|
Leszek Koltunski
|
{
|
116 |
d464f54f
|
Leszek Koltunski
|
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 |
418aa554
|
Leszek Koltunski
|
}
|
137 |
|
|
|
138 |
f10a88a8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
139 |
|
|
|
140 |
3e605536
|
Leszek Koltunski
|
ObjectShape getObjectShape(int cubit, int numLayers)
|
141 |
f10a88a8
|
Leszek Koltunski
|
{
|
142 |
d464f54f
|
Leszek Koltunski
|
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 |
3e605536
|
Leszek Koltunski
|
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 |
d464f54f
|
Leszek Koltunski
|
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
151 |
f10a88a8
|
Leszek Koltunski
|
}
|
152 |
|
|
|
153 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
154 |
|
|
|
155 |
3e605536
|
Leszek Koltunski
|
Static4D getQuat(int cubit, int numLayers)
|
156 |
f10a88a8
|
Leszek Koltunski
|
{
|
157 |
d464f54f
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
158 |
|
|
return mQuats[cubit];
|
159 |
f10a88a8
|
Leszek Koltunski
|
}
|
160 |
|
|
|
161 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
162 |
|
|
|
163 |
3e605536
|
Leszek Koltunski
|
int getNumCubitVariants(int numLayers)
|
164 |
f10a88a8
|
Leszek Koltunski
|
{
|
165 |
3e605536
|
Leszek Koltunski
|
return 1;
|
166 |
f10a88a8
|
Leszek Koltunski
|
}
|
167 |
|
|
|
168 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
169 |
|
|
|
170 |
3e605536
|
Leszek Koltunski
|
int getCubitVariant(int cubit, int numLayers)
|
171 |
418aa554
|
Leszek Koltunski
|
{
|
172 |
3e605536
|
Leszek Koltunski
|
return 0;
|
173 |
418aa554
|
Leszek Koltunski
|
}
|
174 |
|
|
|
175 |
9c06394a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
176 |
|
|
|
177 |
|
|
ObjectSticker retSticker(int face)
|
178 |
|
|
{
|
179 |
d464f54f
|
Leszek Koltunski
|
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 |
abf36986
|
Leszek Koltunski
|
return mStickers[face/NUM_FACE_COLORS];
|
190 |
418aa554
|
Leszek Koltunski
|
}
|
191 |
|
|
|
192 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
193 |
|
|
// PUBLIC API
|
194 |
|
|
|
195 |
|
|
public Static3D[] getRotationAxis()
|
196 |
|
|
{
|
197 |
ad38d800
|
Leszek Koltunski
|
return ROT_AXIS;
|
198 |
418aa554
|
Leszek Koltunski
|
}
|
199 |
|
|
|
200 |
e9a87113
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201 |
|
|
|
202 |
|
|
public Movement getMovement()
|
203 |
|
|
{
|
204 |
|
|
if( mMovement==null ) mMovement = new MovementCornerTwisting();
|
205 |
|
|
return mMovement;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
209 |
|
|
|
210 |
925ed78f
|
Leszek Koltunski
|
public int[] getBasicAngle()
|
211 |
418aa554
|
Leszek Koltunski
|
{
|
212 |
d464f54f
|
Leszek Koltunski
|
if( mBasicAngle==null ) mBasicAngle = new int[] { 3,3,3,3 };
|
213 |
|
|
return mBasicAngle;
|
214 |
418aa554
|
Leszek Koltunski
|
}
|
215 |
|
|
|
216 |
6fd4a72c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
217 |
|
|
|
218 |
|
|
public int getComplexity(int numLayers)
|
219 |
|
|
{
|
220 |
|
|
return 2;
|
221 |
|
|
}
|
222 |
418aa554
|
Leszek Koltunski
|
}
|