Revision 789769bd
Added by Leszek Koltunski 12 months ago
src/main/java/org/distorted/bandaged/BandagedObject.java | ||
---|---|---|
22 | 22 |
{ |
23 | 23 |
private final DistortedScreen mScreen; |
24 | 24 |
private final float[][] mFaceAxis; |
25 |
private final float[] mTmp; |
|
26 | 25 |
private BandagedCubit[] mCubits; |
27 | 26 |
|
28 | 27 |
final int[] mSize; |
... | ... | |
38 | 37 |
mScreen = screen; |
39 | 38 |
mSize = new int[3]; |
40 | 39 |
mDist2D = getDist2D(); |
41 |
mTmp = new float[3]; |
|
42 | 40 |
Static3D[] axis = getFaceAxis(); |
43 | 41 |
int numAxis = axis.length; |
44 | 42 |
mFaceAxis = new float[numAxis][]; |
... | ... | |
55 | 53 |
abstract boolean isAdjacent(float dx, float dy, float dz); |
56 | 54 |
abstract int computeProjectionAngle(); |
57 | 55 |
abstract boolean tryChangeObject(int x, int y, int z); |
58 |
abstract void getTouchedPosition(float[] output, int face, float pointX, float pointY); |
|
59 | 56 |
abstract boolean isInsideFace(int face, float[] p); |
60 | 57 |
abstract TwistyObject createObject(int mode, float scale ); |
61 | 58 |
abstract MeshBase createMesh(int variant, float[] pos, boolean round); |
62 | 59 |
|
63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
64 |
|
|
65 |
int[] getSize() |
|
66 |
{ |
|
67 |
return mSize; |
|
68 |
} |
|
69 |
|
|
70 | 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
71 | 61 |
|
72 | 62 |
void createCubits(Static4D quatT, Static4D quatA, Static3D scale) |
... | ... | |
244 | 234 |
|
245 | 235 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
246 | 236 |
|
247 |
int whichCubitTouched(int face, float pointX, float pointY)
|
|
237 |
int whichCubitTouched(float[] point3D)
|
|
248 | 238 |
{ |
249 |
getTouchedPosition(mTmp, face, pointX, pointY); |
|
239 |
float x = point3D[0]*mMax; |
|
240 |
float y = point3D[1]*mMax; |
|
241 |
float z = point3D[2]*mMax; |
|
242 |
|
|
243 |
int minIndex = -1; |
|
244 |
float minDist = Float.MAX_VALUE; |
|
250 | 245 |
|
251 | 246 |
for(int c=0; c<mNumCubits; c++) |
252 | 247 |
if( mCubits[c].isAttached() ) |
... | ... | |
256 | 251 |
|
257 | 252 |
for(int p=0; p<len; p++) |
258 | 253 |
{ |
259 |
float dx = pos[3*p ]-mTmp[0]; |
|
260 |
float dy = pos[3*p+1]-mTmp[1]; |
|
261 |
float dz = pos[3*p+2]-mTmp[2]; |
|
262 |
|
|
263 |
if( dx*dx + dy*dy + dz*dz < 0.01f ) return c; |
|
254 |
float dx = pos[3*p ]-x; |
|
255 |
float dy = pos[3*p+1]-y; |
|
256 |
float dz = pos[3*p+2]-z; |
|
257 |
float dist = dx*dx + dy*dy + dz*dz; |
|
258 |
|
|
259 |
if( dist<minDist ) |
|
260 |
{ |
|
261 |
minDist = dist; |
|
262 |
minIndex = c; |
|
263 |
} |
|
264 | 264 |
} |
265 | 265 |
} |
266 | 266 |
|
267 |
android.util.Log.e("D", "whichCubitTouched: IMPOSSIBLE!!"); |
|
268 |
return -1; |
|
267 |
return minIndex; |
|
269 | 268 |
} |
270 | 269 |
|
271 | 270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Progress with BandagedObjectPyraminx.