Revision 3a1efb32
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeChanging.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 | 28 |
|
29 |
public abstract class TouchControlShapeChanging extends TouchControl
|
|
29 |
public class TouchControlShapeChanging extends TouchControl |
|
30 | 30 |
{ |
31 | 31 |
private static final float NOT_TOUCHED = -1000000.0f; |
32 | 32 |
private static final float[] mTmp = new float[4]; |
... | ... | |
49 | 49 |
|
50 | 50 |
// assuming the first three vertices are linearly independent |
51 | 51 |
float a1 = vertices[0][0] - vertices[1][0]; |
52 |
float a2 = vertices[0][1] - vertices[1][2];
|
|
53 |
float a3 = vertices[0][2] - vertices[1][3];
|
|
52 |
float a2 = vertices[0][1] - vertices[1][1];
|
|
53 |
float a3 = vertices[0][2] - vertices[1][2];
|
|
54 | 54 |
float b1 = vertices[1][0] - vertices[2][0]; |
55 |
float b2 = vertices[1][1] - vertices[2][2];
|
|
56 |
float b3 = vertices[1][2] - vertices[2][3];
|
|
55 |
float b2 = vertices[1][1] - vertices[2][1];
|
|
56 |
float b3 = vertices[1][2] - vertices[2][2];
|
|
57 | 57 |
|
58 | 58 |
float vx = a2*b3-a3*b2; |
59 | 59 |
float vy = a3*b1-a1*b3; |
... | ... | |
92 | 92 |
private boolean mPreparationDone; |
93 | 93 |
private FaceInfo[][] mInfos; |
94 | 94 |
private int mTouchedCubit; |
95 |
private int mTouchedSide;
|
|
95 |
private int mTouchedFace;
|
|
96 | 96 |
|
97 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
98 | 98 |
|
99 |
TouchControlShapeChanging(TwistyObject object) |
|
99 |
public TouchControlShapeChanging(TwistyObject object)
|
|
100 | 100 |
{ |
101 | 101 |
mPoint = new float[3]; |
102 | 102 |
mCamera= new float[3]; |
... | ... | |
133 | 133 |
for(int i=0; i<numFaces; i++) |
134 | 134 |
{ |
135 | 135 |
int numVerts = indices[i].length; |
136 |
float[][] verts = new float[numVerts][3];
|
|
136 |
float[][] verts = new float[numVerts][4];
|
|
137 | 137 |
|
138 |
for(int j=0; j<numFaces; j++)
|
|
138 |
for(int j=0; j<numVerts; j++)
|
|
139 | 139 |
{ |
140 | 140 |
int index = indices[i][j]; |
141 | 141 |
float x = vertices[index][0]; |
... | ... | |
148 | 148 |
verts[j][0] = tmp.get0() + avgX; |
149 | 149 |
verts[j][1] = tmp.get1() + avgY; |
150 | 150 |
verts[j][2] = tmp.get2() + avgZ; |
151 |
verts[j][3] = 1.0f; |
|
151 | 152 |
} |
152 | 153 |
|
153 | 154 |
infos[i] = new FaceInfo(verts); |
... | ... | |
351 | 352 |
|
352 | 353 |
float closestSoFar = NOT_TOUCHED; |
353 | 354 |
mTouchedCubit = -1; |
354 |
mTouchedSide = -1;
|
|
355 |
mTouchedFace = -1;
|
|
355 | 356 |
|
356 | 357 |
for(int i=0; i<mNumCubits; i++) |
357 | 358 |
{ |
... | ... | |
364 | 365 |
if( dist!=NOT_TOUCHED ) |
365 | 366 |
{ |
366 | 367 |
mTouchedCubit = i; |
367 |
mTouchedSide = j;
|
|
368 |
mTouchedFace = j;
|
|
368 | 369 |
} |
369 | 370 |
closestSoFar = dist; |
370 | 371 |
} |
371 | 372 |
} |
372 | 373 |
|
374 |
if( closestSoFar!=NOT_TOUCHED ) |
|
375 |
{ |
|
376 |
android.util.Log.e("D", "cubit="+mTouchedCubit+" face="+mTouchedFace); |
|
377 |
} |
|
378 |
|
|
373 | 379 |
return closestSoFar!=NOT_TOUCHED; |
374 | 380 |
} |
375 | 381 |
|
... | ... | |
411 | 417 |
{ |
412 | 418 |
return null; |
413 | 419 |
} |
420 |
|
|
421 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
422 |
|
|
423 |
public float returnRotationFactor(int[] numLayers, int row) |
|
424 |
{ |
|
425 |
return 1.0f; |
|
426 |
} |
|
414 | 427 |
} |
Also available in: Unified diff
Bugfixes for the ShapeChanging touch control.
Still doesn't work but doesn't crash anymore :)