1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.objectlib.touchcontrol;
|
11
|
|
12
|
import org.distorted.library.type.Static3D;
|
13
|
import org.distorted.objectlib.main.TwistyObject;
|
14
|
|
15
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
16
|
// Cuboids
|
17
|
|
18
|
public class TouchControlCuboids extends TouchControlShapeConstant
|
19
|
{
|
20
|
private final float[] mDist3D;
|
21
|
|
22
|
public static final Static3D[] FACE_AXIS = new Static3D[]
|
23
|
{
|
24
|
new Static3D(1,0,0), new Static3D(-1,0,0),
|
25
|
new Static3D(0,1,0), new Static3D(0,-1,0),
|
26
|
new Static3D(0,0,1), new Static3D(0,0,-1)
|
27
|
};
|
28
|
|
29
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
30
|
|
31
|
public TouchControlCuboids(TwistyObject object, float[] dist3D)
|
32
|
{
|
33
|
super(object,dist3D,FACE_AXIS);
|
34
|
mDist3D = dist3D;
|
35
|
}
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
int returnPart(int type, int face, float[] touchPoint)
|
40
|
{
|
41
|
return 0;
|
42
|
}
|
43
|
|
44
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45
|
|
46
|
public float returnRotationFactor(int[] numLayers, int row)
|
47
|
{
|
48
|
return 1.0f;
|
49
|
}
|
50
|
|
51
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52
|
|
53
|
boolean isInsideFace(int face, float[] p)
|
54
|
{
|
55
|
switch(face/2)
|
56
|
{
|
57
|
case 0: return ( p[0]<=mDist3D[4] && p[0]>=-mDist3D[4] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
|
58
|
case 1: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[4] && p[1]>=-mDist3D[4] );
|
59
|
case 2: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
|
60
|
}
|
61
|
return false;
|
62
|
}
|
63
|
}
|