Revision 2289cab1
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/helpers/ObjectShape.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.helpers; |
21 | 21 |
|
22 |
import org.distorted.objectlib.main.ObjectControl; |
|
23 |
|
|
22 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
23 | 25 |
|
24 | 26 |
public class ObjectShape |
25 | 27 |
{ |
26 | 28 |
private final double[][] mVertices; |
27 | 29 |
private final int[][] mVertIndices; |
28 |
private final float[][] mBands; |
|
29 | 30 |
private final int[] mBandIndices; |
30 | 31 |
private final float[][] mCorners; |
31 | 32 |
private final int[] mCornerIndices; |
... | ... | |
34 | 35 |
private final int mNumComponents; |
35 | 36 |
private final float[] mConvexityCenter; |
36 | 37 |
|
38 |
private float[][] mBands; |
|
39 |
|
|
37 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
38 | 41 |
|
39 | 42 |
public ObjectShape(double[][] vertices, int[][] vertIndices, float[][] bands, int[] bandIndices, |
... | ... | |
50 | 53 |
mCenterIndices = centIndices; |
51 | 54 |
mNumComponents = numComponents; |
52 | 55 |
mConvexityCenter = convexityCenter; |
56 |
|
|
57 |
if( ObjectControl.isInIconMode() ) |
|
58 |
{ |
|
59 |
int len = bands.length; |
|
60 |
mBands = new float[len][]; |
|
61 |
|
|
62 |
for(int i=0; i<len; i++) |
|
63 |
{ |
|
64 |
int l = bands[i].length; |
|
65 |
mBands[i] = new float[l]; |
|
66 |
mBands[i][0] = 0.01f; |
|
67 |
if (l>=1) System.arraycopy(bands[i], 1, mBands[i], 1, l-1); |
|
68 |
} |
|
69 |
} |
|
53 | 70 |
} |
54 | 71 |
|
55 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/main/ObjectControl.java | ||
---|---|---|
80 | 80 |
private static final Static4D mQuat= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
81 | 81 |
private static final Static4D mTemp= new Static4D(0,0,0,1); |
82 | 82 |
|
83 |
private static boolean mForcedIconMode; |
|
84 |
|
|
83 | 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
84 | 86 |
// cast the 3D axis we are currently rotating along (which is already casted to the surface of the |
85 | 87 |
// currently touched face AND converted into a 4D vector - fourth 0) to a 2D in-screen-surface axis |
... | ... | |
504 | 506 |
return mInterface; |
505 | 507 |
} |
506 | 508 |
|
509 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
510 |
|
|
511 |
public static void setIconMode() |
|
512 |
{ |
|
513 |
mForcedIconMode = true; |
|
514 |
} |
|
515 |
|
|
516 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
517 |
|
|
518 |
public static boolean isInIconMode() |
|
519 |
{ |
|
520 |
return mForcedIconMode; |
|
521 |
} |
|
522 |
|
|
507 | 523 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
508 | 524 |
// PUBLIC API |
509 | 525 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
511 | 527 |
public ObjectControl(Activity act, ObjectLibInterface actioner) |
512 | 528 |
{ |
513 | 529 |
mIsAutomatic = false; |
530 |
mForcedIconMode = false; |
|
514 | 531 |
|
515 | 532 |
mLastCubitColor = -1; |
516 | 533 |
mCurrRotSpeed = 0.0f; |
... | ... | |
569 | 586 |
BlockController.onResume(); |
570 | 587 |
} |
571 | 588 |
|
589 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
590 |
|
|
591 |
public void rotateNow(Static4D quat) |
|
592 |
{ |
|
593 |
mTemp.set(quat); |
|
594 |
mQuat.set(mTemp); |
|
595 |
} |
|
596 |
|
|
572 | 597 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
573 | 598 |
|
574 | 599 |
public void setQuat() |
src/main/java/org/distorted/objectlib/main/Twisty12.java | ||
---|---|---|
61 | 61 |
|
62 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 63 |
|
64 |
protected int getColor(int face)
|
|
64 |
public final int getNumFaces()
|
|
65 | 65 |
{ |
66 |
return FACE_COLORS[face];
|
|
66 |
return 12;
|
|
67 | 67 |
} |
68 | 68 |
|
69 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
73 | 73 |
return 12; |
74 | 74 |
} |
75 | 75 |
|
76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
77 |
|
|
78 |
protected int getColor(int face) |
|
79 |
{ |
|
80 |
return FACE_COLORS[face]; |
|
81 |
} |
|
82 |
|
|
76 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 84 |
|
78 | 85 |
protected int getFOV() |
src/main/java/org/distorted/objectlib/main/Twisty4.java | ||
---|---|---|
47 | 47 |
|
48 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
49 | 49 |
|
50 |
protected int getColor(int face)
|
|
50 |
public final int getNumFaces()
|
|
51 | 51 |
{ |
52 |
return FACE_COLORS[face];
|
|
52 |
return 4;
|
|
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
59 | 59 |
return 4; |
60 | 60 |
} |
61 | 61 |
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
|
64 |
protected int getColor(int face) |
|
65 |
{ |
|
66 |
return FACE_COLORS[face]; |
|
67 |
} |
|
68 |
|
|
62 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 70 |
|
64 | 71 |
protected int getFOV() |
src/main/java/org/distorted/objectlib/main/Twisty6.java | ||
---|---|---|
48 | 48 |
|
49 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 50 |
|
51 |
protected int getColor(int face)
|
|
51 |
public final int getNumFaces()
|
|
52 | 52 |
{ |
53 |
return FACE_COLORS[face];
|
|
53 |
return 6;
|
|
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
60 | 60 |
return 6; |
61 | 61 |
} |
62 | 62 |
|
63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
64 |
|
|
65 |
protected int getColor(int face) |
|
66 |
{ |
|
67 |
return FACE_COLORS[face]; |
|
68 |
} |
|
69 |
|
|
63 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
64 | 71 |
|
65 | 72 |
protected int getFOV() |
src/main/java/org/distorted/objectlib/main/Twisty8.java | ||
---|---|---|
49 | 49 |
|
50 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
51 | 51 |
|
52 |
protected int getColor(int face)
|
|
52 |
public final int getNumFaces()
|
|
53 | 53 |
{ |
54 |
return FACE_COLORS[face];
|
|
54 |
return 8;
|
|
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
61 | 61 |
return 8; |
62 | 62 |
} |
63 | 63 |
|
64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
65 |
|
|
66 |
protected int getColor(int face) |
|
67 |
{ |
|
68 |
return FACE_COLORS[face]; |
|
69 |
} |
|
70 |
|
|
64 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
65 | 72 |
|
66 | 73 |
protected int getFOV() |
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
277 | 277 |
{ |
278 | 278 |
int resourceID= getResource(mNumLayers); |
279 | 279 |
|
280 |
if( resourceID!=0 ) |
|
280 |
if( resourceID!=0 && !ObjectControl.isInIconMode() )
|
|
281 | 281 |
{ |
282 | 282 |
InputStream is = res.openRawResource(resourceID); |
283 | 283 |
DataInputStream dos = new DataInputStream(is); |
... | ... | |
1341 | 1341 |
|
1342 | 1342 |
public abstract Static3D[] getRotationAxis(); |
1343 | 1343 |
public abstract int[] getBasicAngle(); |
1344 |
public abstract int getNumFaces(); |
|
1344 | 1345 |
public abstract int getObjectName(int numLayers); |
1345 | 1346 |
public abstract int getInventor(int numLayers); |
1346 | 1347 |
public abstract int getComplexity(int numLayers); |
src/main/java/org/distorted/objectlib/objects/TwistyHelicopter.java | ||
---|---|---|
212 | 212 |
|
213 | 213 |
protected int getNumCubitFaces() |
214 | 214 |
{ |
215 |
return 4;
|
|
215 |
return 6;
|
|
216 | 216 |
} |
217 | 217 |
|
218 | 218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyJing.java | ||
---|---|---|
291 | 291 |
{4,7,6,5} |
292 | 292 |
}; |
293 | 293 |
|
294 |
float[][] bands = new float[][] { {0.015f,35,0.3f*F,0.6f*F,5,1,1},{0.001f,35,0.3f*F,0.6f*F,5,1,1} };
|
|
294 |
float[][] bands = new float[][] { {0.015f,35,0.25f*F,0.5f*F,5,1,1},{0.001f,35,0.25f*F,0.5f*F,5,1,1} };
|
|
295 | 295 |
int[] bandIndices = new int[] { 0,0,0,1,1,1 }; |
296 | 296 |
float[][] corners = new float[][] { {0.08f,0.20f*F},{0.07f,0.20f*F} }; |
297 | 297 |
int[] cornerIndices = new int[] { 0,1,1,-1,1,-1,-1,-1 }; |
Also available in: Unified diff
New 'IconMode' and some APIs to support it.