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 |
418aa554
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedEffects;
|
27 |
|
|
import org.distorted.library.main.DistortedTexture;
|
28 |
efa8aa48
|
Leszek Koltunski
|
import org.distorted.library.mesh.MeshSquare;
|
29 |
418aa554
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
30 |
|
|
import org.distorted.library.type.Static4D;
|
31 |
|
|
|
32 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
|
|
34 |
9c2f0c91
|
Leszek Koltunski
|
public abstract class TwistyDino extends TwistyObject
|
35 |
418aa554
|
Leszek Koltunski
|
{
|
36 |
|
|
// the four rotation axis of a RubikDino. Must be normalized.
|
37 |
ad38d800
|
Leszek Koltunski
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
38 |
418aa554
|
Leszek Koltunski
|
{
|
39 |
|
|
new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
|
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 |
|
|
};
|
44 |
|
|
|
45 |
925ed78f
|
Leszek Koltunski
|
private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
|
46 |
|
|
|
47 |
418aa554
|
Leszek Koltunski
|
private static final int[] FACE_COLORS = new int[]
|
48 |
|
|
{
|
49 |
ece1b58d
|
Leszek Koltunski
|
COLOR_YELLOW, COLOR_WHITE,
|
50 |
|
|
COLOR_BLUE , COLOR_GREEN,
|
51 |
323b217c
|
Leszek Koltunski
|
COLOR_RED , COLOR_ORANGE
|
52 |
418aa554
|
Leszek Koltunski
|
};
|
53 |
|
|
|
54 |
|
|
// All legal rotation quats of a RubikDino
|
55 |
eaee1ddc
|
Leszek Koltunski
|
static final Static4D[] QUATS = new Static4D[]
|
56 |
418aa554
|
Leszek Koltunski
|
{
|
57 |
|
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
58 |
380162cb
|
Leszek Koltunski
|
new Static4D( 0.5f, 0.5f, 0.5f, -0.5f ),
|
59 |
8f53e513
|
Leszek Koltunski
|
new Static4D( 0.0f, 0.0f, 1.0f, 0.0f ),
|
60 |
380162cb
|
Leszek Koltunski
|
new Static4D( 0.5f, -0.5f, -0.5f, -0.5f ),
|
61 |
418aa554
|
Leszek Koltunski
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ),
|
62 |
|
|
new Static4D( 0.5f, 0.5f, -0.5f, -0.5f ),
|
63 |
|
|
new Static4D( 0.5f, -0.5f, 0.5f, -0.5f ),
|
64 |
8f53e513
|
Leszek Koltunski
|
new Static4D( 0.5f, -0.5f, -0.5f, 0.5f ),
|
65 |
380162cb
|
Leszek Koltunski
|
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
66 |
|
|
new Static4D( 0.5f, -0.5f, 0.5f, 0.5f ),
|
67 |
|
|
new Static4D( 1.0f, 0.0f, 0.0f, 0.0f ),
|
68 |
|
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f )
|
69 |
8f53e513
|
Leszek Koltunski
|
};
|
70 |
|
|
|
71 |
|
|
// centers of the 12 edges. Must be in the same order like QUATs above.
|
72 |
121e4a39
|
Leszek Koltunski
|
static final float[][] CENTERS = new float[][]
|
73 |
8f53e513
|
Leszek Koltunski
|
{
|
74 |
e6cf7283
|
Leszek Koltunski
|
{ 0.0f, 1.5f, 1.5f },
|
75 |
|
|
{ 1.5f, 0.0f, 1.5f },
|
76 |
|
|
{ 0.0f,-1.5f, 1.5f },
|
77 |
|
|
{-1.5f, 0.0f, 1.5f },
|
78 |
|
|
{ 1.5f, 1.5f, 0.0f },
|
79 |
|
|
{ 1.5f,-1.5f, 0.0f },
|
80 |
|
|
{-1.5f,-1.5f, 0.0f },
|
81 |
|
|
{-1.5f, 1.5f, 0.0f },
|
82 |
|
|
{ 0.0f, 1.5f,-1.5f },
|
83 |
|
|
{ 1.5f, 0.0f,-1.5f },
|
84 |
|
|
{ 0.0f,-1.5f,-1.5f },
|
85 |
|
|
{-1.5f, 0.0f,-1.5f }
|
86 |
418aa554
|
Leszek Koltunski
|
};
|
87 |
|
|
|
88 |
596d62a4
|
Leszek Koltunski
|
private static final double[][] VERTICES = new double[][]
|
89 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
90 |
596d62a4
|
Leszek Koltunski
|
{-1.5, 0.0, 0.0},
|
91 |
|
|
{ 1.5, 0.0, 0.0},
|
92 |
|
|
{ 0.0,-1.5, 0.0},
|
93 |
|
|
{ 0.0, 0.0,-1.5}
|
94 |
b1f2ccf5
|
Leszek Koltunski
|
};
|
95 |
|
|
|
96 |
596d62a4
|
Leszek Koltunski
|
private static final int[][] VERT_INDEXES = new int[][]
|
97 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
98 |
|
|
{2,1,0}, // counterclockwise!
|
99 |
596d62a4
|
Leszek Koltunski
|
{3,0,1},
|
100 |
b1f2ccf5
|
Leszek Koltunski
|
{2,3,1},
|
101 |
|
|
{3,2,0},
|
102 |
|
|
};
|
103 |
|
|
|
104 |
596d62a4
|
Leszek Koltunski
|
private static final float[][] STICKERS = new float[][]
|
105 |
|
|
{
|
106 |
|
|
{ 0.0f, -1.0f/3, 0.5f, 1.0f/6, -0.5f, 1.0f/6 }
|
107 |
|
|
};
|
108 |
|
|
|
109 |
9c06394a
|
Leszek Koltunski
|
private static final ObjectSticker[] mStickers;
|
110 |
|
|
|
111 |
|
|
static
|
112 |
|
|
{
|
113 |
|
|
float radius = 0.025f;
|
114 |
|
|
float stroke = 0.050f;
|
115 |
|
|
float[] radii = new float[] {radius,radius,radius};
|
116 |
|
|
mStickers = new ObjectSticker[STICKERS.length];
|
117 |
|
|
mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
|
118 |
|
|
}
|
119 |
418aa554
|
Leszek Koltunski
|
|
120 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121 |
|
|
|
122 |
9c2f0c91
|
Leszek Koltunski
|
TwistyDino(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
123 |
|
|
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
|
124 |
418aa554
|
Leszek Koltunski
|
{
|
125 |
db875721
|
Leszek Koltunski
|
super(size, size, quat, texture, mesh, effects, moves, obj, res, scrWidth);
|
126 |
418aa554
|
Leszek Koltunski
|
}
|
127 |
|
|
|
128 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
129 |
|
|
|
130 |
|
|
float getScreenRatio()
|
131 |
|
|
{
|
132 |
c7e79b69
|
Leszek Koltunski
|
return 0.5f;
|
133 |
418aa554
|
Leszek Koltunski
|
}
|
134 |
|
|
|
135 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136 |
|
|
|
137 |
|
|
Static4D[] getQuats()
|
138 |
|
|
{
|
139 |
|
|
return QUATS;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143 |
|
|
|
144 |
|
|
int getNumFaces()
|
145 |
|
|
{
|
146 |
|
|
return FACE_COLORS.length;
|
147 |
|
|
}
|
148 |
|
|
|
149 |
7403cdfa
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
150 |
|
|
|
151 |
e6734aa9
|
Leszek Koltunski
|
float[][] getCuts(int size)
|
152 |
7403cdfa
|
Leszek Koltunski
|
{
|
153 |
e6734aa9
|
Leszek Koltunski
|
float[] cut = new float[] { -SQ3/3, +SQ3/3 };
|
154 |
|
|
return new float[][] { cut,cut,cut,cut };
|
155 |
7403cdfa
|
Leszek Koltunski
|
}
|
156 |
|
|
|
157 |
eab9d8f8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158 |
|
|
|
159 |
a64e07d0
|
Leszek Koltunski
|
int getNumStickerTypes(int numLayers)
|
160 |
eab9d8f8
|
Leszek Koltunski
|
{
|
161 |
596d62a4
|
Leszek Koltunski
|
return STICKERS.length;
|
162 |
eab9d8f8
|
Leszek Koltunski
|
}
|
163 |
|
|
|
164 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
|
|
|
166 |
8f53e513
|
Leszek Koltunski
|
int getNumCubitFaces()
|
167 |
418aa554
|
Leszek Koltunski
|
{
|
168 |
8f53e513
|
Leszek Koltunski
|
return 4;
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
172 |
418aa554
|
Leszek Koltunski
|
|
173 |
e6cf7283
|
Leszek Koltunski
|
float[][] getCubitPositions(int size)
|
174 |
8f53e513
|
Leszek Koltunski
|
{
|
175 |
|
|
return CENTERS;
|
176 |
418aa554
|
Leszek Koltunski
|
}
|
177 |
|
|
|
178 |
f10a88a8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
179 |
|
|
|
180 |
3e605536
|
Leszek Koltunski
|
ObjectShape getObjectShape(int cubit, int numLayers)
|
181 |
f10a88a8
|
Leszek Koltunski
|
{
|
182 |
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} };
|
183 |
|
|
int[] bandIndices = new int[] { 0,0,1,1 };
|
184 |
|
|
float[][] corners = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} };
|
185 |
|
|
int[] cornerIndices = new int[] { 0,0,1,1 };
|
186 |
|
|
float[][] centers = new float[][] { {0.0f, -0.75f, -0.75f} };
|
187 |
|
|
int[] centerIndices = new int[] { 0,0,0,0 };
|
188 |
|
|
return new ObjectShape(VERTICES,VERT_INDEXES,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
|
189 |
f10a88a8
|
Leszek Koltunski
|
}
|
190 |
|
|
|
191 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
192 |
|
|
|
193 |
3e605536
|
Leszek Koltunski
|
Static4D getQuat(int cubit, int numLayers)
|
194 |
f10a88a8
|
Leszek Koltunski
|
{
|
195 |
3e605536
|
Leszek Koltunski
|
return QUATS[cubit];
|
196 |
f10a88a8
|
Leszek Koltunski
|
}
|
197 |
|
|
|
198 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
199 |
|
|
|
200 |
3e605536
|
Leszek Koltunski
|
int getNumCubitVariants(int numLayers)
|
201 |
f10a88a8
|
Leszek Koltunski
|
{
|
202 |
3e605536
|
Leszek Koltunski
|
return 1;
|
203 |
f10a88a8
|
Leszek Koltunski
|
}
|
204 |
|
|
|
205 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
206 |
|
|
|
207 |
3e605536
|
Leszek Koltunski
|
int getCubitVariant(int cubit, int numLayers)
|
208 |
418aa554
|
Leszek Koltunski
|
{
|
209 |
3e605536
|
Leszek Koltunski
|
return 0;
|
210 |
418aa554
|
Leszek Koltunski
|
}
|
211 |
|
|
|
212 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
213 |
|
|
|
214 |
9c06394a
|
Leszek Koltunski
|
int getColor(int face)
|
215 |
418aa554
|
Leszek Koltunski
|
{
|
216 |
9c06394a
|
Leszek Koltunski
|
return FACE_COLORS[face];
|
217 |
|
|
}
|
218 |
76c2bd07
|
Leszek Koltunski
|
|
219 |
9c06394a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
220 |
|
|
|
221 |
|
|
ObjectSticker retSticker(int face)
|
222 |
|
|
{
|
223 |
|
|
return mStickers[face/NUM_FACES];
|
224 |
418aa554
|
Leszek Koltunski
|
}
|
225 |
|
|
|
226 |
fb377dae
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
227 |
|
|
|
228 |
|
|
float returnMultiplier()
|
229 |
|
|
{
|
230 |
|
|
return 2.0f;
|
231 |
|
|
}
|
232 |
|
|
|
233 |
418aa554
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
234 |
|
|
// PUBLIC API
|
235 |
|
|
|
236 |
|
|
public Static3D[] getRotationAxis()
|
237 |
|
|
{
|
238 |
ad38d800
|
Leszek Koltunski
|
return ROT_AXIS;
|
239 |
418aa554
|
Leszek Koltunski
|
}
|
240 |
|
|
|
241 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
242 |
|
|
|
243 |
925ed78f
|
Leszek Koltunski
|
public int[] getBasicAngle()
|
244 |
418aa554
|
Leszek Koltunski
|
{
|
245 |
925ed78f
|
Leszek Koltunski
|
return BASIC_ANGLE;
|
246 |
418aa554
|
Leszek Koltunski
|
}
|
247 |
|
|
|
248 |
6fd4a72c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
249 |
|
|
|
250 |
|
|
public int getComplexity(int numLayers)
|
251 |
|
|
{
|
252 |
|
|
return 2;
|
253 |
|
|
}
|
254 |
418aa554
|
Leszek Koltunski
|
}
|