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.main.DistortedEffects;
|
27
|
import org.distorted.library.main.DistortedTexture;
|
28
|
import org.distorted.library.mesh.MeshBase;
|
29
|
import org.distorted.library.mesh.MeshRectangles;
|
30
|
import org.distorted.library.type.Static3D;
|
31
|
import org.distorted.library.type.Static4D;
|
32
|
|
33
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
|
35
|
public class RubikDino extends RubikObject
|
36
|
{
|
37
|
static final float SQ3 = (float)Math.sqrt(3);
|
38
|
|
39
|
// the four rotation axis of a RubikDino. Must be normalized.
|
40
|
static final Static3D[] AXIS = new Static3D[]
|
41
|
{
|
42
|
new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
|
43
|
new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
|
44
|
new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
|
45
|
new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
|
46
|
};
|
47
|
|
48
|
private static final int[] FACE_COLORS = new int[]
|
49
|
{
|
50
|
0xffffff00, 0xffffffff, // AXIS[0]right (right-YELLOW) AXIS[0]left (left -WHITE)
|
51
|
0xff0000ff, 0xff00ff00, // AXIS[1]right (top -BLUE ) AXIS[1]left (bottom-GREEN)
|
52
|
0xffff0000, 0xffb5651d // AXIS[2]right (front-RED ) AXIS[2]left (back -BROWN)
|
53
|
};
|
54
|
|
55
|
// All legal rotation quats of a RubikDino
|
56
|
private static final Static4D[] QUATS = new Static4D[]
|
57
|
{
|
58
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
59
|
new Static4D( 0.5f, 0.5f, 0.5f, 0.5f ),
|
60
|
new Static4D( 0.5f, 0.5f, -0.5f, 0.5f ),
|
61
|
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
|
new Static4D( 0.5f, 0.5f, -0.5f, -0.5f ),
|
65
|
new Static4D( 0.5f, -0.5f, 0.5f, -0.5f ),
|
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.0f, 0.0f, 1.0f, 0.0f ),
|
69
|
new Static4D( 0.0f, -1.0f, 0.0f, 0.0f )
|
70
|
};
|
71
|
|
72
|
private static MeshBase[] mMeshes;
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
|
76
|
RubikDino(int size, Static4D quat, DistortedTexture texture,
|
77
|
MeshRectangles mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
78
|
{
|
79
|
super(size, 60, quat, texture, mesh, effects, moves, RubikObjectList.DINO, res, scrWidth);
|
80
|
}
|
81
|
|
82
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83
|
|
84
|
float getScreenRatio()
|
85
|
{
|
86
|
return 0.5f;
|
87
|
}
|
88
|
|
89
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90
|
|
91
|
Static4D[] getQuats()
|
92
|
{
|
93
|
return QUATS;
|
94
|
}
|
95
|
|
96
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97
|
|
98
|
int getNumFaces()
|
99
|
{
|
100
|
return FACE_COLORS.length;
|
101
|
}
|
102
|
|
103
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
104
|
|
105
|
Static3D[] getCubitPositions(int size)
|
106
|
{
|
107
|
// TODO
|
108
|
|
109
|
return null;
|
110
|
}
|
111
|
|
112
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113
|
|
114
|
MeshBase createCubitMesh(int cubit)
|
115
|
{
|
116
|
// TODO
|
117
|
|
118
|
return null;
|
119
|
}
|
120
|
|
121
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122
|
|
123
|
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side)
|
124
|
{
|
125
|
float STROKE = 0.06f*side;
|
126
|
float OFF = STROKE/2 -1;
|
127
|
float OFF2 = 0.5f*side + OFF;
|
128
|
float HEIGHT = side - OFF;
|
129
|
float RADIUS = side/12.0f;
|
130
|
float ARC1_H = 0.2f*side;
|
131
|
float ARC1_W = side*0.5f;
|
132
|
float ARC2_W = 0.153f*side;
|
133
|
float ARC2_H = 0.905f*side;
|
134
|
float ARC3_W = side-ARC2_W;
|
135
|
|
136
|
paint.setAntiAlias(true);
|
137
|
paint.setStrokeWidth(STROKE);
|
138
|
paint.setColor(FACE_COLORS[face]);
|
139
|
paint.setStyle(Paint.Style.FILL);
|
140
|
|
141
|
canvas.drawRect(left,top,left+side,top+side,paint);
|
142
|
|
143
|
paint.setColor(INTERIOR_COLOR);
|
144
|
paint.setStyle(Paint.Style.STROKE);
|
145
|
|
146
|
canvas.drawLine( left, HEIGHT, side +left, HEIGHT, paint);
|
147
|
canvas.drawLine( OFF +left, side , OFF2 +left, 0, paint);
|
148
|
canvas.drawLine((side-OFF)+left, side , (side-OFF2) +left, 0, paint);
|
149
|
|
150
|
canvas.drawArc( ARC1_W-RADIUS+left, ARC1_H-RADIUS, ARC1_W+RADIUS+left, ARC1_H+RADIUS, 225, 90, false, paint);
|
151
|
canvas.drawArc( ARC2_W-RADIUS+left, ARC2_H-RADIUS, ARC2_W+RADIUS+left, ARC2_H+RADIUS, 105, 90, false, paint);
|
152
|
canvas.drawArc( ARC3_W-RADIUS+left, ARC2_H-RADIUS, ARC3_W+RADIUS+left, ARC2_H+RADIUS, 345, 90, false, paint);
|
153
|
}
|
154
|
|
155
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
156
|
// PUBLIC API
|
157
|
|
158
|
public Static3D[] getRotationAxis()
|
159
|
{
|
160
|
return AXIS;
|
161
|
}
|
162
|
|
163
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
164
|
|
165
|
public int getBasicAngle()
|
166
|
{
|
167
|
return 3;
|
168
|
}
|
169
|
|
170
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
171
|
|
172
|
public float returnMultiplier()
|
173
|
{
|
174
|
// TODO
|
175
|
|
176
|
return 0;
|
177
|
}
|
178
|
|
179
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
180
|
|
181
|
public float returnRotationFactor(float offset)
|
182
|
{
|
183
|
return 1.0f;
|
184
|
}
|
185
|
|
186
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
187
|
|
188
|
public float[] getRowChances()
|
189
|
{
|
190
|
int size = getSize();
|
191
|
float[] chances = new float[size];
|
192
|
|
193
|
for(int i=0; i<size; i++)
|
194
|
{
|
195
|
chances[i] = (i+1.0f) / size;
|
196
|
}
|
197
|
|
198
|
return chances;
|
199
|
}
|
200
|
|
201
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
202
|
// TODO (only needed for solvers - there are no Dino solvers ATM)
|
203
|
|
204
|
public String retObjectString()
|
205
|
{
|
206
|
return "";
|
207
|
}
|
208
|
|
209
|
}
|