Revision 333ecf1b
Added by Leszek Koltunski over 2 years ago
| src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeConstant.java | ||
|---|---|---|
| 26 | 26 |
private final float[] mPoint2D, mMove2D; |
| 27 | 27 |
private final int[] mEnabledRotAxis; |
| 28 | 28 |
private final float[] mDistanceCenterFace3D; |
| 29 |
private final Static3D[] mFaceAxis; |
|
| 29 |
private final Static3D[] mFaceAxis, mRotAxis;
|
|
| 30 | 30 |
|
| 31 | 31 |
private int mLastTouchedFace; |
| 32 | 32 |
private float[][][] mCastedRotAxis; |
| ... | ... | |
| 51 | 51 |
float[][] cuts = object.getCuts(numLayers); |
| 52 | 52 |
boolean[][] rotatable = object.getLayerRotatable(numLayers); |
| 53 | 53 |
float size = object.getSize(); |
| 54 |
Static3D[] rotAxis = object.getRotationAxis();
|
|
| 54 |
mRotAxis = object.getRotationAxis();
|
|
| 55 | 55 |
|
| 56 | 56 |
mPoint = new float[3]; |
| 57 | 57 |
mCamera= new float[3]; |
| ... | ... | |
| 65 | 65 |
mFaceAxis = faceAxis; |
| 66 | 66 |
mNumFaceAxis= mFaceAxis.length; |
| 67 | 67 |
|
| 68 |
mEnabledRotAxis = new int[rotAxis.length+1];
|
|
| 68 |
mEnabledRotAxis = new int[mRotAxis.length+1];
|
|
| 69 | 69 |
|
| 70 | 70 |
mDistanceCenterFace3D = distance3D; // distance from the center of the object to each of its faces |
| 71 | 71 |
|
| 72 |
computeCastedAxis(rotAxis);
|
|
| 72 |
computeCastedAxis(mRotAxis);
|
|
| 73 | 73 |
computeBorders(cuts,rotatable,size); |
| 74 |
computeLinear(rotAxis,faceAxis);
|
|
| 74 |
computeLinear(mRotAxis,faceAxis);
|
|
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 303 | 303 |
} |
| 304 | 304 |
else |
| 305 | 305 |
{
|
| 306 |
// poor hack for CoinTetrahedron where 0 happens to the the correct value. |
|
| 307 |
// in this case we have the rotAxis normal to the face, i.e. A here is 0. |
|
| 308 |
// we want to be rotating the central 'coin' where which happens to be row 0. |
|
| 309 |
return 0; |
|
| 306 |
// this must mean that we are rotating along an axis that is normal to the currently |
|
| 307 |
// touched face. So the offset passed here as param is incorrect (and equal to 0). |
|
| 308 |
// recompute it and return the row (no need to translate!) |
|
| 309 |
Static3D ax = mRotAxis[axisIndex]; |
|
| 310 |
offset = mTouch[0]*ax.get0() + mTouch[1]*ax.get1() + mTouch[2]*ax.get2(); |
|
| 311 |
|
|
| 312 |
for(int i=0; i<len; i++) |
|
| 313 |
if( offset<borders[i] ) return i; |
|
| 310 | 314 |
} |
| 311 | 315 |
|
| 312 | 316 |
return len; |
Also available in: Unified diff
Beginnings of support for touch-control of pieces which we rotate along an axs which is normal to the currently touched face (think Coin Tetrahedron!)