Revision 596d62a4
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
88 | 88 |
{-1.5f, 0.0f,-1.5f } |
89 | 89 |
}; |
90 | 90 |
|
91 |
private final double[][] VERTICES = new double[][] |
|
91 |
private static final double[][] VERTICES = new double[][]
|
|
92 | 92 |
{ |
93 |
{-0.5, 0.0, 0.0},
|
|
94 |
{ 0.5, 0.0, 0.0},
|
|
95 |
{ 0.0,-0.5, 0.0},
|
|
96 |
{ 0.0, 0.0,-0.5}
|
|
93 |
{-1.5, 0.0, 0.0},
|
|
94 |
{ 1.5, 0.0, 0.0},
|
|
95 |
{ 0.0,-1.5, 0.0},
|
|
96 |
{ 0.0, 0.0,-1.5}
|
|
97 | 97 |
}; |
98 | 98 |
|
99 |
private final int[][] VERT_INDEXES = new int[][] |
|
99 |
private static final int[][] VERT_INDEXES = new int[][]
|
|
100 | 100 |
{ |
101 | 101 |
{2,1,0}, // counterclockwise! |
102 |
{3,0,1}, |
|
102 | 103 |
{2,3,1}, |
103 | 104 |
{3,2,0}, |
104 |
{3,0,1} |
|
105 | 105 |
}; |
106 | 106 |
|
107 |
private static MeshBase mMesh; |
|
107 |
private static final float[][] STICKERS = new float[][] |
|
108 |
{ |
|
109 |
{ 0.0f, -1.0f/3, 0.5f, 1.0f/6, -0.5f, 1.0f/6 } |
|
110 |
}; |
|
111 |
|
|
112 |
private static MeshBase[] mMeshes; |
|
108 | 113 |
|
109 | 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
110 | 115 |
|
... | ... | |
207 | 212 |
|
208 | 213 |
int getNumStickerTypes(int numLayers) |
209 | 214 |
{ |
210 |
return 1;
|
|
215 |
return STICKERS.length;
|
|
211 | 216 |
} |
212 | 217 |
|
213 | 218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
228 | 233 |
|
229 | 234 |
MeshBase createCubitMesh(int cubit, int numLayers) |
230 | 235 |
{ |
231 |
if( mMesh==null ) mMesh = FactoryCubit.getInstance().createDinoMesh(); |
|
236 |
if( mMeshes==null ) |
|
237 |
{ |
|
238 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
239 |
factory.clear(); |
|
240 |
mMeshes = new MeshBase[1]; |
|
241 |
} |
|
242 |
|
|
243 |
if( mMeshes[0]==null ) |
|
244 |
{ |
|
245 |
float[][] bands= new float[][] |
|
246 |
{ |
|
247 |
{0.035f,30,0.16f,0.8f,7,2,5}, |
|
248 |
{0.020f,45,0.16f,0.2f,3,1,2} |
|
249 |
}; |
|
250 |
int[] bandIndexes = new int[] { 0,0,1,1 }; |
|
251 |
float[][] corners = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} }; |
|
252 |
int[] cornerIndexes = new int[] { 0,0,1,1 }; |
|
253 |
|
|
254 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
255 |
|
|
256 |
factory.createNewFaceTransform(VERTICES,VERT_INDEXES); |
|
257 |
mMeshes[0] = factory.createRoundedSolid(VERTICES, VERT_INDEXES, |
|
258 |
bands, bandIndexes, |
|
259 |
corners, cornerIndexes, |
|
260 |
getNumCubitFaces() ); |
|
261 |
} |
|
232 | 262 |
|
233 |
MeshBase mesh = mMesh.copy(true); |
|
263 |
MeshBase mesh = mMeshes[0].copy(true);
|
|
234 | 264 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[cubit], new Static3D(0,0,0) ); |
235 | 265 |
mesh.apply(quat,0xffffffff,0); |
236 | 266 |
|
... | ... | |
241 | 271 |
|
242 | 272 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top) |
243 | 273 |
{ |
244 |
float F = 0.5f; |
|
245 | 274 |
float R = 0.025f; |
246 | 275 |
float S = 0.05f; |
247 |
float[] vertices = { -F,F/3, 0,-2*F/3, +F,F/3 }; |
|
248 | 276 |
|
249 | 277 |
FactorySticker factory = FactorySticker.getInstance(); |
250 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
|
|
278 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], S, FACE_COLORS[face], R);
|
|
251 | 279 |
} |
252 | 280 |
|
253 | 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert the Dino and one of the Skewb's cubits to the new engine.