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.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.R;
|
29
|
|
30
|
import java.util.Random;
|
31
|
|
32
|
import static org.distorted.effects.scramble.ScrambleEffect.START_AXIS;
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
public class TwistyDino4 extends TwistyDino
|
37
|
{
|
38
|
private static final int[] mFaceMap = {4,4, 2,2, 2,2, 4,4,
|
39
|
0,0, 2,2, 1,1, 4,4,
|
40
|
0,0, 0,0, 1,1, 1,1 };
|
41
|
|
42
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
43
|
|
44
|
TwistyDino4(int size, Static4D quat, DistortedTexture texture,
|
45
|
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
46
|
{
|
47
|
super(size, quat, texture, mesh, effects, moves, ObjectList.DIN4, res, scrWidth);
|
48
|
}
|
49
|
|
50
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51
|
|
52
|
int getFaceColor(int cubit, int cubitface, int size)
|
53
|
{
|
54
|
switch(cubitface)
|
55
|
{
|
56
|
case 0 : return mFaceMap[2*cubit];
|
57
|
case 1 : return mFaceMap[2*cubit+1];
|
58
|
default: return NUM_FACES;
|
59
|
}
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
boolean shouldResetTextureMaps()
|
65
|
{
|
66
|
return true;
|
67
|
}
|
68
|
|
69
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70
|
|
71
|
public int randomizeNewRow(Random rnd, int oldRotAxis, int oldRow, int newRotAxis)
|
72
|
{
|
73
|
return (oldRotAxis==START_AXIS) ? ((newRotAxis==1 || newRotAxis==2) ? 0:2) : (oldRotAxis+newRotAxis==3 ? 2-oldRow : oldRow);
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
// Dino4 is solved if and only if the four groups of three same-colored cubits are each 'together'
|
78
|
// (actually we need to check only 3 first groups - if those are correct, the fourth one also needs
|
79
|
// to be correct).
|
80
|
//
|
81
|
// White group : (X,Y,Z) = 10,11,6
|
82
|
// Red group : (X,Y,Z) = 0,3,7
|
83
|
// Blue group : (X,Y,Z) = 2,1,5
|
84
|
// Yellow group: (X,Y,Z) = 8,9,4
|
85
|
//
|
86
|
// A group of 3 cubits is 'together' if and only if they are all rotated with one quat - but we cannot
|
87
|
// forget that the whole Dino can be mirrored! (so then qY = qX*Q2 and qZ = qX*Q8 )
|
88
|
//
|
89
|
// X cubits: 0, 2, 8, 10
|
90
|
// Y cubits: 1, 3, 9, 11
|
91
|
// Z cubits: 4, 5, 6, 7
|
92
|
|
93
|
public boolean isSolved()
|
94
|
{
|
95
|
int redX = CUBITS[0].mQuatIndex;
|
96
|
int bluX = CUBITS[2].mQuatIndex;
|
97
|
int yelX = CUBITS[8].mQuatIndex;
|
98
|
|
99
|
if (CUBITS[3].mQuatIndex == redX && CUBITS[7].mQuatIndex == redX &&
|
100
|
CUBITS[1].mQuatIndex == bluX && CUBITS[5].mQuatIndex == bluX &&
|
101
|
CUBITS[9].mQuatIndex == yelX && CUBITS[4].mQuatIndex == yelX ) return true;
|
102
|
|
103
|
if (CUBITS[3].mQuatIndex != mulQuat(redX,2)) return false;
|
104
|
if (CUBITS[7].mQuatIndex != mulQuat(redX,8)) return false;
|
105
|
if (CUBITS[1].mQuatIndex != mulQuat(bluX,2)) return false;
|
106
|
if (CUBITS[5].mQuatIndex != mulQuat(bluX,8)) return false;
|
107
|
if (CUBITS[9].mQuatIndex != mulQuat(yelX,2)) return false;
|
108
|
if (CUBITS[4].mQuatIndex != mulQuat(yelX,8)) return false;
|
109
|
|
110
|
return true;
|
111
|
}
|
112
|
|
113
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114
|
|
115
|
public int getObjectName(int numLayers)
|
116
|
{
|
117
|
return R.string.din43;
|
118
|
}
|
119
|
|
120
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121
|
|
122
|
public int getInventor(int numLayers)
|
123
|
{
|
124
|
return R.string.din43_inventor;
|
125
|
}
|
126
|
}
|