1 |
eaee1ddc
|
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 |
|
|
import org.distorted.library.main.DistortedEffects;
|
25 |
|
|
import org.distorted.library.main.DistortedTexture;
|
26 |
|
|
import org.distorted.library.mesh.MeshSquare;
|
27 |
|
|
import org.distorted.library.type.Static4D;
|
28 |
|
|
import org.distorted.main.RubikSurfaceView;
|
29 |
|
|
|
30 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31 |
|
|
|
32 |
|
|
public class RubikDino4 extends RubikDino
|
33 |
|
|
{
|
34 |
|
|
private static final int[] mFaceMap = {4,4, 2,2, 2,2, 4,4,
|
35 |
|
|
0,0, 2,2, 1,1, 4,4,
|
36 |
|
|
0,0, 0,0, 1,1, 1,1 };
|
37 |
|
|
|
38 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
|
40 |
|
|
RubikDino4(int size, Static4D quat, DistortedTexture texture,
|
41 |
|
|
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
42 |
|
|
{
|
43 |
|
|
super(size, quat, texture, mesh, effects, moves, RubikObjectList.DIN4, res, scrWidth);
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47 |
|
|
|
48 |
|
|
int getFaceColor(int cubit, int cubitface, int size)
|
49 |
|
|
{
|
50 |
|
|
switch(cubitface)
|
51 |
|
|
{
|
52 |
|
|
case 0 : return mFaceMap[2*cubit];
|
53 |
|
|
case 1 : return mFaceMap[2*cubit+1];
|
54 |
|
|
default: return NUM_FACES;
|
55 |
|
|
}
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59 |
|
|
|
60 |
|
|
boolean shouldResetTextureMaps()
|
61 |
|
|
{
|
62 |
|
|
return true;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66 |
|
|
// Dino4 is solved if and only if the four groups of three same-colored cubits each are rotate with
|
67 |
|
|
// the same quaternion (actually we need to check only 3 first groups - if those are correct, the
|
68 |
|
|
// fourth one also needs to be correct).
|
69 |
|
|
//
|
70 |
|
|
// White group : 6,10,11
|
71 |
|
|
// Red group : 0,3,7
|
72 |
|
|
// Blue group : 1,2,5
|
73 |
|
|
// Yellow group: 4,8,9
|
74 |
|
|
|
75 |
|
|
public boolean isSolved()
|
76 |
|
|
{
|
77 |
|
|
int qR = CUBITS[0].mQuatIndex;
|
78 |
|
|
int qB = CUBITS[1].mQuatIndex;
|
79 |
|
|
int qY = CUBITS[4].mQuatIndex;
|
80 |
|
|
|
81 |
|
|
return (CUBITS[3].mQuatIndex == qR && CUBITS[7].mQuatIndex == qR &&
|
82 |
|
|
CUBITS[2].mQuatIndex == qB && CUBITS[5].mQuatIndex == qB &&
|
83 |
|
|
CUBITS[8].mQuatIndex == qY && CUBITS[9].mQuatIndex == qY );
|
84 |
|
|
}
|
85 |
|
|
}
|