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
|
import android.graphics.Canvas;
|
24
|
import android.graphics.Paint;
|
25
|
|
26
|
import org.distorted.library.effect.MatrixEffectQuaternion;
|
27
|
import org.distorted.library.main.DistortedEffects;
|
28
|
import org.distorted.library.main.DistortedTexture;
|
29
|
import org.distorted.library.mesh.MeshBase;
|
30
|
import org.distorted.library.mesh.MeshSquare;
|
31
|
import org.distorted.library.type.Static3D;
|
32
|
import org.distorted.library.type.Static4D;
|
33
|
import org.distorted.main.R;
|
34
|
|
35
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36
|
|
37
|
public class TwistyKilominx extends TwistyMinx
|
38
|
{
|
39
|
private static MeshBase mMesh;
|
40
|
|
41
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42
|
|
43
|
TwistyKilominx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
44
|
DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
45
|
{
|
46
|
super(size, size, quat, texture, mesh, effects, moves, ObjectList.KILO, res, scrWidth);
|
47
|
}
|
48
|
|
49
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50
|
|
51
|
int getNumStickerTypes(int numLayers)
|
52
|
{
|
53
|
return 1;
|
54
|
}
|
55
|
|
56
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57
|
|
58
|
float[] getCuts(int numLayers)
|
59
|
{
|
60
|
return new float[] { -0.5f , 0.5f };
|
61
|
}
|
62
|
|
63
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64
|
|
65
|
float[][] getCubitPositions(int numLayers)
|
66
|
{
|
67
|
return CORNERS;
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71
|
|
72
|
float getScreenRatio()
|
73
|
{
|
74
|
return 1.00f;
|
75
|
}
|
76
|
|
77
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78
|
|
79
|
private int getQuat(int cubit)
|
80
|
{
|
81
|
return ( cubit>=0 && cubit<20 ) ? QUAT_CORNER_INDICES[cubit] : 0;
|
82
|
}
|
83
|
|
84
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
85
|
|
86
|
MeshBase createCubitMesh(int cubit, int numLayers)
|
87
|
{
|
88
|
if( mMesh==null ) mMesh = FactoryCubit.getInstance().createKilominxCornerMesh();
|
89
|
MeshBase mesh = mMesh.copy(true);
|
90
|
|
91
|
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[getQuat(cubit)], new Static3D(0,0,0) );
|
92
|
mesh.apply(quat,0xffffffff,0);
|
93
|
|
94
|
return mesh;
|
95
|
}
|
96
|
|
97
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98
|
|
99
|
int getFaceColor(int cubit, int cubitface, int numLayers)
|
100
|
{
|
101
|
return cubitface>=0 && cubitface<3 ? mCornerFaceMap[cubit][cubitface] : NUM_TEXTURES*NUM_FACES;
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
|
106
|
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
|
107
|
{
|
108
|
float S = 0.07f;
|
109
|
float R = 0.09f;
|
110
|
|
111
|
float A = 0.86f;
|
112
|
float X1= (SQ5+1)/8;
|
113
|
float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
|
114
|
float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
|
115
|
|
116
|
float[] vertices = { -X1, Y2, 0, -A*Y1, X1, Y2, 0, Y1 };
|
117
|
|
118
|
FactorySticker factory = FactorySticker.getInstance();
|
119
|
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
120
|
|
121
|
float MID = TEXTURE_HEIGHT*0.5f;
|
122
|
float WID = TEXTURE_HEIGHT*0.1f;
|
123
|
float HEI = TEXTURE_HEIGHT*(0.47f+Y1);
|
124
|
canvas.drawLine(left+MID-WID,top+HEI,left+MID+WID,top+HEI,paint);
|
125
|
}
|
126
|
|
127
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
128
|
// PUBLIC API
|
129
|
// The Kilominx is solved if and only if:
|
130
|
//
|
131
|
// All cubits are rotated with the same quat.
|
132
|
|
133
|
public boolean isSolved()
|
134
|
{
|
135
|
int q = CUBITS[0].mQuatIndex;
|
136
|
|
137
|
for(int i=0; i<NUM_CUBITS; i++)
|
138
|
{
|
139
|
if( CUBITS[i].mQuatIndex != q ) return false;
|
140
|
}
|
141
|
|
142
|
return true;
|
143
|
}
|
144
|
|
145
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
146
|
|
147
|
public int getObjectName(int numLayers)
|
148
|
{
|
149
|
return R.string.minx2;
|
150
|
}
|
151
|
|
152
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
153
|
|
154
|
public int getInventor(int numLayers)
|
155
|
{
|
156
|
return R.string.minx2_inventor;
|
157
|
}
|
158
|
|
159
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
160
|
|
161
|
public int getComplexity(int numLayers)
|
162
|
{
|
163
|
return 3;
|
164
|
}
|
165
|
}
|