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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
public class TwistyDino6 extends TwistyDino
|
35
|
{
|
36
|
private static final int[] mFaceMap = {4,2, 0,4, 4,3, 1,4,
|
37
|
2,0, 3,0, 3,1, 2,1,
|
38
|
5,2, 0,5, 5,3, 1,5 };
|
39
|
|
40
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41
|
|
42
|
TwistyDino6(int size, Static4D quat, DistortedTexture texture,
|
43
|
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
44
|
{
|
45
|
super(size, quat, texture, mesh, effects, moves, ObjectList.DINO, res, scrWidth);
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
int getFaceColor(int cubit, int cubitface, int size)
|
51
|
{
|
52
|
switch(cubitface)
|
53
|
{
|
54
|
case 0 : return mFaceMap[2*cubit];
|
55
|
case 1 : return mFaceMap[2*cubit+1];
|
56
|
default: return NUM_FACES;
|
57
|
}
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
boolean shouldResetTextureMaps()
|
63
|
{
|
64
|
return false;
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
|
70
|
{
|
71
|
if( num==0 )
|
72
|
{
|
73
|
scramble[num][0] = rnd.nextInt(NUM_AXIS);
|
74
|
scramble[num][1] = rnd.nextFloat()<=0.5f ? 0:2;
|
75
|
}
|
76
|
else
|
77
|
{
|
78
|
int newVector = rnd.nextInt(NUM_AXIS -1);
|
79
|
scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
|
80
|
scramble[num][1] = scramble[num-1][0]+scramble[num][0]==3 ? 2-scramble[num-1][1] : scramble[num-1][1];
|
81
|
}
|
82
|
|
83
|
switch( rnd.nextInt(2) )
|
84
|
{
|
85
|
case 0: scramble[num][2] = -1; break;
|
86
|
case 1: scramble[num][2] = 1; break;
|
87
|
}
|
88
|
}
|
89
|
|
90
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91
|
// Dino6 is solved if and only if:
|
92
|
//
|
93
|
// All four 'X' cubits (i.e. those whose longest edge goes along the X axis) are rotated
|
94
|
// by the same quaternion qX, similarly all four 'Y' cubits by the same qY and all four 'Z'
|
95
|
// by the same qZ, and then either:
|
96
|
//
|
97
|
// a) qX = qY = qZ
|
98
|
// b) qY = qX*Q2 and qZ = qX*Q8 (i.e. swap of WHITE and YELLOW faces)
|
99
|
// c) qX = qY*Q2 and qZ = qY*Q10 (i.e. swap of BLUE and GREEN faces)
|
100
|
// d) qX = qZ*Q8 and qY = qZ*Q10 (i.e. swap of RED and BROWN faces)
|
101
|
//
|
102
|
// BUT: cases b), c) and d) are really the same - it's all just a mirror image of the original.
|
103
|
//
|
104
|
// X cubits: 0, 2, 8, 10
|
105
|
// Y cubits: 1, 3, 9, 11
|
106
|
// Z cubits: 4, 5, 6, 7
|
107
|
|
108
|
public boolean isSolved()
|
109
|
{
|
110
|
int qX = CUBITS[0].mQuatIndex;
|
111
|
int qY = CUBITS[1].mQuatIndex;
|
112
|
int qZ = CUBITS[4].mQuatIndex;
|
113
|
|
114
|
if( CUBITS[2].mQuatIndex != qX || CUBITS[8].mQuatIndex != qX || CUBITS[10].mQuatIndex != qX ||
|
115
|
CUBITS[3].mQuatIndex != qY || CUBITS[9].mQuatIndex != qY || CUBITS[11].mQuatIndex != qY ||
|
116
|
CUBITS[5].mQuatIndex != qZ || CUBITS[6].mQuatIndex != qZ || CUBITS[ 7].mQuatIndex != qZ )
|
117
|
{
|
118
|
return false;
|
119
|
}
|
120
|
|
121
|
return ( qX==qY && qX==qZ ) || ( qY==mulQuat(qX,2) && qZ==mulQuat(qX,8) );
|
122
|
}
|
123
|
|
124
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125
|
|
126
|
public int getObjectName(int numLayers)
|
127
|
{
|
128
|
return R.string.dino3;
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
public int getInventor(int numLayers)
|
134
|
{
|
135
|
return R.string.dino3_inventor;
|
136
|
}
|
137
|
}
|