Revision 8da6b1c9
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/main/Movement.java | ||
---|---|---|
105 | 105 |
|
106 | 106 |
for( int face=0; face<mNumFaceAxis; face++) |
107 | 107 |
{ |
108 |
convertTo2Dcoords( mPoint, mFaceAxis[face], mCastedRotAxis[face][casted]);
|
|
108 |
convertTo2Dcoords( mPoint, face, mCastedRotAxis[face][casted]);
|
|
109 | 109 |
normalize2D(mCastedRotAxis[face][casted]); |
110 | 110 |
|
111 | 111 |
fx = mFaceAxis[face].get0(); |
... | ... | |
176 | 176 |
|
177 | 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
178 | 178 |
|
179 |
private boolean faceIsVisible(Static3D faceAxis)
|
|
179 |
private boolean faceIsVisible(int index)
|
|
180 | 180 |
{ |
181 |
Static3D faceAxis = mFaceAxis[index]; |
|
181 | 182 |
float castCameraOnAxis = mCamera[0]*faceAxis.get0() + mCamera[1]*faceAxis.get1() + mCamera[2]*faceAxis.get2(); |
182 | 183 |
return castCameraOnAxis > mDistanceCenterFace3D; |
183 | 184 |
} |
... | ... | |
190 | 191 |
// |
191 | 192 |
// output = camera + alpha*(point-camera), where alpha = [dist-axis*camera] / [axis*(point-camera)] |
192 | 193 |
|
193 |
private void castTouchPointOntoFace(Static3D faceAxis, float[] output)
|
|
194 |
private void castTouchPointOntoFace(int index, float[] output)
|
|
194 | 195 |
{ |
196 |
Static3D faceAxis = mFaceAxis[index]; |
|
197 |
|
|
195 | 198 |
float d0 = mPoint[0]-mCamera[0]; |
196 | 199 |
float d1 = mPoint[1]-mCamera[1]; |
197 | 200 |
float d2 = mPoint[2]-mCamera[2]; |
... | ... | |
222 | 225 |
// mean that the distance between the center of the Object and its faces is 0) - then we arbitrarily |
223 | 226 |
// decide that 2D Y = (0,0,-1) in the North Pole and (0,0,1) in the South Pole) |
224 | 227 |
|
225 |
private void convertTo2Dcoords(float[] point3D, Static3D faceAxis, float[] output)
|
|
228 |
private void convertTo2Dcoords(float[] point3D, int index , float[] output)
|
|
226 | 229 |
{ |
230 |
Static3D faceAxis = mFaceAxis[index]; |
|
231 |
|
|
227 | 232 |
float y0,y1,y2; // base Y vector of the 2D coord system |
228 | 233 |
float a0 = faceAxis.get0(); |
229 | 234 |
float a1 = faceAxis.get1(); |
... | ... | |
421 | 426 |
|
422 | 427 |
for( mLastTouchedFace=0; mLastTouchedFace<mNumFaceAxis; mLastTouchedFace++) |
423 | 428 |
{ |
424 |
if( faceIsVisible(mFaceAxis[mLastTouchedFace]) )
|
|
429 |
if( faceIsVisible(mLastTouchedFace) )
|
|
425 | 430 |
{ |
426 |
castTouchPointOntoFace(mFaceAxis[mLastTouchedFace], mTouch);
|
|
427 |
convertTo2Dcoords(mTouch, mFaceAxis[mLastTouchedFace], mPoint2D);
|
|
431 |
castTouchPointOntoFace(mLastTouchedFace, mTouch);
|
|
432 |
convertTo2Dcoords(mTouch, mLastTouchedFace, mPoint2D);
|
|
428 | 433 |
if( isInsideFace(mLastTouchedFace,mPoint2D) ) return true; |
429 | 434 |
} |
430 | 435 |
} |
... | ... | |
440 | 445 |
mPoint[1] = rotatedTouchPoint.get1()/objectRatio; |
441 | 446 |
mPoint[2] = rotatedTouchPoint.get2()/objectRatio; |
442 | 447 |
|
443 |
castTouchPointOntoFace(mFaceAxis[mLastTouchedFace], mTouch);
|
|
444 |
convertTo2Dcoords(mTouch, mFaceAxis[mLastTouchedFace], mMove2D);
|
|
448 |
castTouchPointOntoFace(mLastTouchedFace, mTouch);
|
|
449 |
convertTo2Dcoords(mTouch, mLastTouchedFace, mMove2D);
|
|
445 | 450 |
|
446 | 451 |
mMove2D[0] -= mPoint2D[0]; |
447 | 452 |
mMove2D[1] -= mPoint2D[1]; |
Also available in: Unified diff
Changes to the Cube cubits; new cube meshes.