1 |
ab31cf6f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
71f8a172
|
Leszek Koltunski
|
// 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 |
ab31cf6f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
c9c71c3f
|
Leszek Koltunski
|
package org.distorted.objectlib.touchcontrol;
|
11 |
ab31cf6f
|
Leszek Koltunski
|
|
12 |
|
|
import org.distorted.library.type.Static3D;
|
13 |
57ef6378
|
Leszek Koltunski
|
import org.distorted.objectlib.main.TwistyObject;
|
14 |
ab31cf6f
|
Leszek Koltunski
|
|
15 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
16 |
|
|
// Cuboids
|
17 |
|
|
|
18 |
c9c71c3f
|
Leszek Koltunski
|
public class TouchControlCuboids extends TouchControlShapeConstant
|
19 |
ab31cf6f
|
Leszek Koltunski
|
{
|
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 |
57ef6378
|
Leszek Koltunski
|
public TouchControlCuboids(TwistyObject object, float[] dist3D)
|
32 |
ab31cf6f
|
Leszek Koltunski
|
{
|
33 |
57ef6378
|
Leszek Koltunski
|
super(object,dist3D,FACE_AXIS);
|
34 |
ab31cf6f
|
Leszek Koltunski
|
mDist3D = dist3D;
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
|
|
int returnPart(int type, int face, float[] touchPoint)
|
40 |
|
|
{
|
41 |
|
|
return 0;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45 |
|
|
|
46 |
|
|
boolean isInsideFace(int face, float[] p)
|
47 |
|
|
{
|
48 |
|
|
switch(face/2)
|
49 |
|
|
{
|
50 |
|
|
case 0: return ( p[0]<=mDist3D[4] && p[0]>=-mDist3D[4] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
|
51 |
|
|
case 1: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[4] && p[1]>=-mDist3D[4] );
|
52 |
|
|
case 2: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
|
53 |
|
|
}
|
54 |
|
|
return false;
|
55 |
|
|
}
|
56 |
|
|
}
|