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 org.distorted.library.type.Static3D;
|
23
|
|
24
|
import static org.distorted.objects.TwistyJing.F;
|
25
|
|
26
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
27
|
|
28
|
class MovementJing extends Movement
|
29
|
{
|
30
|
static final float DIST3D = SQ6/24;
|
31
|
static final float DIST2D = SQ3/12;
|
32
|
|
33
|
static final Static3D[] FACE_AXIS = new Static3D[]
|
34
|
{
|
35
|
new Static3D( 0,+SQ3/3,+SQ6/3),
|
36
|
new Static3D( 0,+SQ3/3,-SQ6/3),
|
37
|
new Static3D(-SQ6/3,-SQ3/3, 0),
|
38
|
new Static3D(+SQ6/3,-SQ3/3, 0),
|
39
|
};
|
40
|
|
41
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42
|
|
43
|
MovementJing()
|
44
|
{
|
45
|
super(TwistyJing.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
|
51
|
{
|
52
|
return offset < (SQ3/4)*F ? 0:1;
|
53
|
}
|
54
|
|
55
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
|
57
|
public float returnRotationFactor(int numLayers, int row)
|
58
|
{
|
59
|
return 1.0f;
|
60
|
}
|
61
|
|
62
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63
|
|
64
|
boolean isInsideFace(int face, float[] p)
|
65
|
{
|
66
|
float y = (face > 1 ? p[1] : -p[1]);
|
67
|
float x = p[0];
|
68
|
return (y >= -DIST2D) && (y <= 2*DIST2D-SQ3*x) && (y <= 2*DIST2D+SQ3*x);
|
69
|
}
|
70
|
|
71
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72
|
|
73
|
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
|
74
|
{
|
75
|
enabled[0] = 3;
|
76
|
|
77
|
switch(face)
|
78
|
{
|
79
|
case 0: enabled[1]=1; enabled[2]=2; enabled[3]=3; break;
|
80
|
case 1: enabled[1]=0; enabled[2]=2; enabled[3]=3; break;
|
81
|
case 2: enabled[1]=0; enabled[2]=1; enabled[3]=3; break;
|
82
|
case 3: enabled[1]=0; enabled[2]=1; enabled[3]=2; break;
|
83
|
}
|
84
|
}
|
85
|
}
|