Revision 6b2f62c9
Added by Leszek Koltunski 7 months ago
src/main/java/org/distorted/objectlib/main/TwistyObjectControllable.java | ||
---|---|---|
310 | 310 |
mRotationAngle.removeAll(); |
311 | 311 |
|
312 | 312 |
int nonGhostAngle= (int)angle; |
313 |
if( (nonGhostAngle%mGhostBasicDeg)!=0 ) |
|
313 |
if( mGhostAngle!=0 && (nonGhostAngle%mGhostBasicDeg)!=0 )
|
|
314 | 314 |
{ |
315 | 315 |
if( ((nonGhostAngle-mGhostAngle)%mGhostBasicDeg==0 ) ) nonGhostAngle -= mGhostAngle; |
316 | 316 |
else if( ((nonGhostAngle+mGhostAngle)%mGhostBasicDeg==0 ) ) nonGhostAngle += mGhostAngle; |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControl.java | ||
---|---|---|
10 | 10 |
package org.distorted.objectlib.touchcontrol; |
11 | 11 |
|
12 | 12 |
import org.distorted.library.helpers.QuatHelper; |
13 |
import org.distorted.library.type.Static3D; |
|
13 | 14 |
import org.distorted.library.type.Static4D; |
14 | 15 |
import org.distorted.objectlib.main.TwistyObjectControllable; |
15 | 16 |
|
... | ... | |
46 | 47 |
float[][] mTouchBorders; |
47 | 48 |
private final float[][] mRotationFactor; |
48 | 49 |
|
50 |
protected final float[][] mCuts; |
|
51 |
protected final boolean[][] mRotatable; |
|
52 |
protected final float mSize; |
|
53 |
protected final Static3D[] mRotAxis; |
|
54 |
protected final int[][][] mEnabled; |
|
55 |
protected final float[] mPoint, mCamera, mTouch, mMove2D; |
|
56 |
|
|
49 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 58 |
|
51 | 59 |
public TouchControl(TwistyObjectControllable object) |
52 | 60 |
{ |
53 | 61 |
mRotationFactor = object.returnRotationFactor(); |
62 |
mCuts = object.getCuts(); |
|
63 |
mRotatable = object.getLayerRotatable(); |
|
64 |
mSize = object.getSize(); |
|
65 |
mRotAxis = object.getRotationAxis(); |
|
66 |
mEnabled = object.getEnabled(); |
|
67 |
|
|
68 |
mMove2D = new float[2]; |
|
69 |
mPoint = new float[3]; |
|
70 |
mCamera = new float[3]; |
|
71 |
mTouch = new float[3]; |
|
54 | 72 |
} |
55 | 73 |
|
56 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlBall.java | ||
---|---|---|
24 | 24 |
private static final float MIN_LEN = 0.35f; |
25 | 25 |
private static final float[] mTmp = new float[4]; |
26 | 26 |
|
27 |
private final Static3D[] mRotAxis; |
|
28 |
private final float[] mPoint, mCamera, mTouch; |
|
29 | 27 |
private final int[] mEnabledRotAxis; |
30 |
private final int[][][] mEnabled; |
|
31 |
private final float[] mMove2D; |
|
32 | 28 |
private final float[][] mCastedRotAxis; |
33 | 29 |
private float[][] mTouchBorders; |
34 |
|
|
35 | 30 |
private float mLongitude, mLatitude; |
36 | 31 |
private float mX, mY, mZ; |
37 | 32 |
|
38 | 33 |
private static final float X = (float)Math.sqrt( (2-SQ2)/(6+SQ2) ); |
39 | 34 |
private static final float Y = (float)Math.sqrt( (2+SQ2)/(6+SQ2) ); |
35 |
private static final float PI= (float)Math.PI; |
|
40 | 36 |
|
41 | 37 |
public static final Static3D[] FACE_AXIS = new Static3D[] |
42 | 38 |
{ |
... | ... | |
64 | 60 |
{ |
65 | 61 |
super(object); |
66 | 62 |
|
67 |
float[][] cuts = object.getCuts(); |
|
68 |
boolean[][] rot = object.getLayerRotatable(); |
|
69 |
float size = object.getSize(); |
|
70 |
mRotAxis = object.getRotationAxis(); |
|
71 |
mEnabled = object.getEnabled(); |
|
72 |
|
|
73 |
mMove2D = new float[2]; |
|
74 |
|
|
75 |
mPoint = new float[3]; |
|
76 |
mCamera= new float[3]; |
|
77 |
mTouch = new float[3]; |
|
78 |
|
|
79 | 63 |
int numRotAxis = mRotAxis.length; |
80 | 64 |
mEnabledRotAxis = new int[numRotAxis+1]; |
81 | 65 |
mCastedRotAxis = new float[numRotAxis][2]; |
82 |
|
|
83 |
computeBorders(cuts,rot,size); |
|
66 |
computeBorders(mCuts,mRotatable,mSize); |
|
84 | 67 |
} |
85 | 68 |
|
86 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
176 | 159 |
mLongitude = mZ==0 ? 0 : (float)Math.atan(mX/mZ); |
177 | 160 |
mLatitude = (float)Math.asin(2*mY); |
178 | 161 |
|
179 |
if( mZ<0 ) mLongitude += Math.PI;
|
|
180 |
else if( mX<0 ) mLongitude += 2*Math.PI;
|
|
162 |
if( mZ<0 ) mLongitude += PI; |
|
163 |
else if( mX<0 ) mLongitude += 2*PI; |
|
181 | 164 |
} |
182 | 165 |
|
183 | 166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
185 | 168 |
|
186 | 169 |
private int returnTouchedFace() |
187 | 170 |
{ |
188 |
float t = (float)(mLongitude + Math.PI/8);
|
|
189 |
if( t>2*Math.PI ) t-=(2*Math.PI);
|
|
190 |
int ret = (int)(t/(Math.PI/4));
|
|
171 |
float t = mLongitude+PI/8;
|
|
172 |
if( t>2*PI ) t-=(2*PI);
|
|
173 |
int ret = (int)(t/(PI/4)); |
|
191 | 174 |
return ret<8 ? ret : 7; |
192 | 175 |
} |
193 | 176 |
|
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlBarrel.java | ||
---|---|---|
39 | 39 |
private static final float MIN_LEN = 0.35f; |
40 | 40 |
private static final float[] mTmp = new float[4]; |
41 | 41 |
|
42 |
private final Static3D[] mRotAxis; |
|
43 |
private final float[] mPoint, mCamera, mTouch; |
|
44 | 42 |
private final int[] mEnabledRotAxis; |
45 |
private final int[][][] mEnabled; |
|
46 |
private final float[] mMove2D; |
|
47 | 43 |
private final float[][] mCastedRotAxis; |
48 | 44 |
private float[][] mTouchBorders; |
49 | 45 |
|
... | ... | |
58 | 54 |
{ |
59 | 55 |
super(object); |
60 | 56 |
|
61 |
float[][] cuts = object.getCuts(); |
|
62 |
boolean[][] rot = object.getLayerRotatable(); |
|
63 |
float size = object.getSize(); |
|
64 |
float[] dist3D = object.getDist3D(); |
|
65 |
mRotAxis = object.getRotationAxis(); |
|
66 |
mEnabled = object.getEnabled(); |
|
67 |
|
|
68 |
mMove2D= new float[2]; |
|
69 |
mPoint = new float[3]; |
|
70 |
mCamera= new float[3]; |
|
71 |
mTouch = new float[3]; |
|
72 |
|
|
57 |
float[] dist3D = object.getDist3D(); |
|
73 | 58 |
int numRotAxis = mRotAxis.length; |
74 | 59 |
int numSideAxis= numRotAxis - 1; |
75 | 60 |
|
... | ... | |
85 | 70 |
mEnabledRotAxis= new int[numRotAxis+1]; |
86 | 71 |
mCastedRotAxis = new float[numRotAxis][2]; |
87 | 72 |
|
88 |
computeBorders(cuts,rot,size);
|
|
73 |
computeBorders(mCuts,mRotatable,mSize);
|
|
89 | 74 |
} |
90 | 75 |
|
91 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeChanging.java | ||
---|---|---|
96 | 96 |
//////////////////////////////////////////////////////////// |
97 | 97 |
// end FaceInfo |
98 | 98 |
|
99 |
private final float[] mTouch, mLastT;
|
|
99 |
private final float[] mLastT; |
|
100 | 100 |
private int mNumCubits; |
101 | 101 |
private int[] mNumFaces; |
102 | 102 |
private boolean mPreparationDone; |
103 |
private final boolean[][] mRotatable; |
|
104 |
private final float[][] mCuts; |
|
105 | 103 |
|
106 |
final float[] mCamera, mPoint; |
|
107 |
final Static3D[] mRotAxis; |
|
108 | 104 |
final TwistyObjectControllable mObject; |
109 | 105 |
int mTouchedCubit, mTouchedCubitFace, mNumAxis; |
110 | 106 |
FaceInfo[][] mInfos; |
... | ... | |
116 | 112 |
{ |
117 | 113 |
super(object); |
118 | 114 |
|
119 |
mPoint = new float[3]; |
|
120 |
mCamera= new float[3]; |
|
121 |
mTouch = new float[3]; |
|
122 | 115 |
mLastT = new float[3]; |
123 | 116 |
mObject= object; |
124 | 117 |
mPreparationDone = false; |
118 |
mNumAxis = mRotAxis.length; |
|
125 | 119 |
|
126 |
mRotAxis = object.getRotationAxis() ; |
|
127 |
mNumAxis = mRotAxis.length; |
|
128 |
mRotatable = object.getLayerRotatable(); |
|
129 |
mCuts = object.getCuts(); |
|
130 |
float size = object.getSize(); |
|
131 |
computeBorders(mCuts,mRotatable,size); |
|
120 |
computeBorders(mCuts,mRotatable,mSize); |
|
132 | 121 |
} |
133 | 122 |
|
134 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeConstant.java | ||
---|---|---|
23 | 23 |
protected final float[] mDistanceCenterFace3D; |
24 | 24 |
|
25 | 25 |
private final int mNumFaceAxis; |
26 |
private final float[] mPoint, mCamera, mTouch; |
|
27 |
private final float[] mPoint2D, mMove2D; |
|
26 |
private final float[] mPoint2D; |
|
28 | 27 |
private final int[] mEnabledRotAxis; |
29 |
private final Static3D[] mFaceAxis, mRotAxis;
|
|
28 |
private final Static3D[] mFaceAxis; |
|
30 | 29 |
|
31 | 30 |
private int mLastTouchedFace; |
32 | 31 |
private float[][][] mCastedRotAxis; |
33 | 32 |
private Static4D[][] mCastedRotAxis4D; |
34 | 33 |
private float[][] mA, mB; |
35 |
|
|
36 | 34 |
private final int mSplit; |
37 |
private final int[][][] mEnabled; |
|
38 | 35 |
|
39 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 37 |
|
... | ... | |
47 | 44 |
{ |
48 | 45 |
super(object); |
49 | 46 |
|
50 |
float[][] cuts = object.getCuts(); |
|
51 |
boolean[][] rot = object.getLayerRotatable(); |
|
52 |
float size = object.getSize(); |
|
53 |
mRotAxis = object.getRotationAxis(); |
|
54 |
mSplit = object.getTouchControlSplit(); |
|
55 |
mEnabled = object.getEnabled(); |
|
56 |
mFaceAxis = faceAxis; |
|
57 |
mNumFaceAxis = mFaceAxis.length; |
|
58 |
|
|
59 |
mPoint = new float[3]; |
|
60 |
mCamera = new float[3]; |
|
61 |
mTouch = new float[3]; |
|
62 |
mPoint2D= new float[2]; |
|
63 |
mMove2D = new float[2]; |
|
47 |
mSplit = object.getTouchControlSplit(); |
|
48 |
mFaceAxis = faceAxis; |
|
49 |
mNumFaceAxis= mFaceAxis.length; |
|
50 |
mPoint2D = new float[2]; |
|
64 | 51 |
|
65 | 52 |
mEnabledRotAxis = new int[mRotAxis.length+1]; |
66 | 53 |
mDistanceCenterFace3D = distance3D; // distance from the center of the object to each of its faces |
67 | 54 |
|
68 | 55 |
computeCastedAxis(mRotAxis); |
69 |
computeBorders(cuts,rot,size);
|
|
56 |
computeBorders(mCuts,mRotatable,mSize);
|
|
70 | 57 |
computeLinear(mRotAxis,faceAxis); |
71 | 58 |
} |
72 | 59 |
|
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapemod.java | ||
---|---|---|
34 | 34 |
for(int axis=0; axis<mNumAxis; axis++) |
35 | 35 |
{ |
36 | 36 |
float x = mRotAxis[axis].get0(); |
37 |
float y = mRotAxis[axis].get1();
|
|
37 |
float y = mRotAxis[axis].get1(); |
|
38 | 38 |
float z = mRotAxis[axis].get2(); |
39 | 39 |
float w = 0.0f; |
40 | 40 |
|
Also available in: Unified diff
unify TouchControl