Revision fb1e9a31
Added by Leszek Koltunski 12 months ago
src/main/java/org/distorted/objectlib/main/ObjectControl.java | ||
---|---|---|
346 | 346 |
|
347 | 347 |
mTouchControl.getCastedRotAxis(mAxis,mQuat,mCurrentAxis); |
348 | 348 |
correctRotationAxis(); |
349 |
mRotationFactor = mTouchControl.returnRotationFactor(numLayers,mCurrentRow);
|
|
349 |
mRotationFactor = mTouchControl.returnRotationFactor(mCurrentAxis,mCurrentRow);
|
|
350 | 350 |
if( mRotAxisType != ROT_AXIS_NOT_NORMAL ) mNormalRotAngle = computeNormalRotAngle(mNormalTouchPoint[0]-x,mNormalTouchPoint[1]-y); |
351 | 351 |
|
352 | 352 |
if( object.beginNewRotation( mCurrentAxis, mCurrentRow ) ) |
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
1889 | 1889 |
return mTouchControl; |
1890 | 1890 |
} |
1891 | 1891 |
|
1892 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1893 |
|
|
1894 |
public float[][] returnRotationFactor() |
|
1895 |
{ |
|
1896 |
float[][] factor = new float[mNumAxis][]; |
|
1897 |
|
|
1898 |
for(int ax=0; ax<mNumAxis; ax++) |
|
1899 |
{ |
|
1900 |
int numL = mNumLayers[ax]; |
|
1901 |
factor[ax] = new float[numL]; |
|
1902 |
for(int la=0; la<numL; la++) factor[ax][la] = 1.0f; |
|
1903 |
} |
|
1904 |
|
|
1905 |
return factor; |
|
1906 |
} |
|
1907 |
|
|
1892 | 1908 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1893 | 1909 |
|
1894 | 1910 |
protected void setReader(JsonReader reader) |
src/main/java/org/distorted/objectlib/objects/TwistyPyraminx.java | ||
---|---|---|
50 | 50 |
super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset); |
51 | 51 |
} |
52 | 52 |
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
@Override |
|
56 |
public float[][] returnRotationFactor() |
|
57 |
{ |
|
58 |
int numL= getNumLayers()[0]; |
|
59 |
float[][] factor = new float[4][numL]; |
|
60 |
|
|
61 |
for(int ax=0; ax<4; ax++) |
|
62 |
for(int la=0; la<numL; la++) factor[ax][la] = ((float)numL)/(numL-la); |
|
63 |
|
|
64 |
return factor; |
|
65 |
} |
|
66 |
|
|
53 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 | 68 |
// edge[i] is the state after moving layer i (0 is the largest) |
55 | 69 |
|
src/main/java/org/distorted/objectlib/touchcontrol/TouchControl.java | ||
---|---|---|
10 | 10 |
package org.distorted.objectlib.touchcontrol; |
11 | 11 |
|
12 | 12 |
import org.distorted.library.type.Static4D; |
13 |
import org.distorted.objectlib.main.TwistyObject; |
|
13 | 14 |
|
14 | 15 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
15 | 16 |
|
... | ... | |
42 | 43 |
|
43 | 44 |
float mObjectRatio; |
44 | 45 |
|
46 |
private final float[][] mRotationFactor; |
|
47 |
|
|
45 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 49 |
|
47 |
public TouchControl(float ratio)
|
|
50 |
public TouchControl(TwistyObject object)
|
|
48 | 51 |
{ |
49 |
mObjectRatio = ratio; |
|
52 |
mObjectRatio = (object!=null ? object.getObjectRatio() : 1.0f); |
|
53 |
mRotationFactor = (object!=null ? object.returnRotationFactor() : null); |
|
50 | 54 |
} |
51 | 55 |
|
52 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
130 | 134 |
return minIndex; |
131 | 135 |
} |
132 | 136 |
|
137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
138 |
|
|
139 |
public float returnRotationFactor(int axis, int row) |
|
140 |
{ |
|
141 |
return mRotationFactor==null ? 1.0f : mRotationFactor[axis][row]; |
|
142 |
} |
|
143 |
|
|
133 | 144 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 145 |
|
135 | 146 |
public abstract boolean objectTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera); |
... | ... | |
139 | 150 |
public abstract int getTouchedCubitFace(); |
140 | 151 |
public abstract int getTouchedCubit(); |
141 | 152 |
public abstract float[] getTouchedPuzzleCenter(); |
142 |
public abstract float returnRotationFactor(int[] numLayers, int row); |
|
143 | 153 |
} |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlBall.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
public TouchControlBall(TwistyObject object) |
64 | 64 |
{ |
65 |
super(object.getObjectRatio());
|
|
65 |
super(object); |
|
66 | 66 |
|
67 | 67 |
int[] numLayers = object.getNumLayers(); |
68 | 68 |
float[][] cuts = object.getCuts(numLayers); |
... | ... | |
219 | 219 |
System.arraycopy(mEnabled[face][part], 0, mEnabledRotAxis, 1, num); |
220 | 220 |
} |
221 | 221 |
|
222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
223 |
|
|
224 |
public float returnRotationFactor(int[] numLayers, int row) |
|
225 |
{ |
|
226 |
return 1.0f; |
|
227 |
} |
|
228 |
|
|
229 | 222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
230 | 223 |
|
231 | 224 |
public int getTouchedCubitFace() |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlCuboids.java | ||
---|---|---|
41 | 41 |
return 0; |
42 | 42 |
} |
43 | 43 |
|
44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
45 |
|
|
46 |
public float returnRotationFactor(int[] numLayers, int row) |
|
47 |
{ |
|
48 |
return 1.0f; |
|
49 |
} |
|
50 |
|
|
51 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
52 | 45 |
|
53 | 46 |
boolean isInsideFace(int face, float[] p) |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlDodecahedron.java | ||
---|---|---|
52 | 52 |
super(object,D3D,FACE_AXIS); |
53 | 53 |
} |
54 | 54 |
|
55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
56 |
|
|
57 |
public float returnRotationFactor(int[] numLayers, int row) |
|
58 |
{ |
|
59 |
return 1.0f; |
|
60 |
} |
|
61 |
|
|
62 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 56 |
// return angle (in radians) that the line connecting the center C of the pentagonal face and the |
64 | 57 |
// first vertex of the pentagon makes with a vertical line coming upwards from the center C. |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlHexahedron.java | ||
---|---|---|
77 | 77 |
return 0; |
78 | 78 |
} |
79 | 79 |
|
80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
81 |
|
|
82 |
public float returnRotationFactor(int[] numLayers, int row) |
|
83 |
{ |
|
84 |
return 1.0f; |
|
85 |
} |
|
86 |
|
|
87 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
88 | 81 |
|
89 | 82 |
boolean isInsideFace(int face, float[] p) |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlIcosahedron.java | ||
---|---|---|
123 | 123 |
super(object,D3D,FACE_AXIS); |
124 | 124 |
} |
125 | 125 |
|
126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
127 |
|
|
128 |
public float returnRotationFactor(int[] numLayers, int row) |
|
129 |
{ |
|
130 |
return 1.0f; |
|
131 |
} |
|
132 |
|
|
133 | 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 127 |
|
135 | 128 |
private boolean isFaceInverted(int face) |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlOctahedron.java | ||
---|---|---|
99 | 99 |
return 0; |
100 | 100 |
} |
101 | 101 |
|
102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
103 |
|
|
104 |
public float returnRotationFactor(int[] numLayers, int row) |
|
105 |
{ |
|
106 |
return 1.0f; |
|
107 |
} |
|
108 |
|
|
109 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
110 | 103 |
|
111 | 104 |
boolean isInsideFace(int face, float[] point) |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeChanging.java | ||
---|---|---|
100 | 100 |
|
101 | 101 |
public TouchControlShapeChanging(TwistyObject object) |
102 | 102 |
{ |
103 |
super( object!=null ? object.getObjectRatio() : 1.0f );
|
|
103 |
super(object);
|
|
104 | 104 |
|
105 | 105 |
mPoint = new float[3]; |
106 | 106 |
mCamera= new float[3]; |
... | ... | |
615 | 615 |
{ |
616 | 616 |
return mTouchedCubit; |
617 | 617 |
} |
618 |
|
|
619 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
620 |
|
|
621 |
public float returnRotationFactor(int[] numLayers, int row) |
|
622 |
{ |
|
623 |
return 1.0f; |
|
624 |
} |
|
625 | 618 |
} |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeConstant.java | ||
---|---|---|
45 | 45 |
|
46 | 46 |
TouchControlShapeConstant(TwistyObject object, float[] distance3D, Static3D[] faceAxis) |
47 | 47 |
{ |
48 |
super(object.getObjectRatio());
|
|
48 |
super(object); |
|
49 | 49 |
|
50 | 50 |
int[] numLayers = object.getNumLayers(); |
51 | 51 |
float[][] cuts = object.getCuts(numLayers); |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlTetrahedron.java | ||
---|---|---|
101 | 101 |
return 0; |
102 | 102 |
} |
103 | 103 |
|
104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
105 |
// Jing has nL=2 |
|
106 |
|
|
107 |
public float returnRotationFactor(int[] numLayers, int row) |
|
108 |
{ |
|
109 |
int numL = numLayers[0]; |
|
110 |
return numL==2 ? 1.0f : ((float)numL)/(numL-row); |
|
111 |
} |
|
112 |
|
|
113 | 104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
114 | 105 |
|
115 | 106 |
boolean isInsideFace(int face, float[] point) |
Also available in: Unified diff
move the returnRotationFactor() method from touchControl to TwistyObject (where it can be overridden)