Revision 680469e6
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
133 | 133 |
{ 7,11,12,12,12,12 }, |
134 | 134 |
}; |
135 | 135 |
|
136 |
private static MeshBase mCornerMesh, mEdgeMesh; |
|
136 |
private static final float G = 0.72f; |
|
137 |
|
|
138 |
private static final double[][] VERTICES_CORNER = new double[][] |
|
139 |
{ |
|
140 |
{ 0.0f, 0.0f, 0.0f }, |
|
141 |
{-0.5f, 0.5f, 0.5f }, |
|
142 |
{-0.5f,-0.5f, 0.5f }, |
|
143 |
{ 0.5f, 0.5f, 0.5f }, |
|
144 |
{ 0.5f,-0.5f, 0.5f }, |
|
145 |
{ 0.5f, 0.5f,-0.5f }, |
|
146 |
{ 0.5f,-0.5f,-0.5f }, |
|
147 |
{-0.5f, 0.5f,-0.5f }, |
|
148 |
|
|
149 |
{-0.5f, 0.5f*G, 0.5f }, |
|
150 |
{-0.5f,-0.5f*G, 0.5f }, |
|
151 |
{-0.5f*G,-0.5f, 0.5f }, |
|
152 |
{ 0.5f*G,-0.5f, 0.5f }, |
|
153 |
{ 0.5f,-0.5f, 0.5f*G }, |
|
154 |
{ 0.5f,-0.5f,-0.5f*G }, |
|
155 |
{ 0.5f,-0.5f*G,-0.5f }, |
|
156 |
{ 0.5f, 0.5f*G,-0.5f }, |
|
157 |
{ 0.5f*G, 0.5f,-0.5f }, |
|
158 |
{-0.5f*G, 0.5f,-0.5f }, |
|
159 |
{-0.5f, 0.5f,-0.5f*G }, |
|
160 |
{-0.5f, 0.5f, 0.5f*G }, |
|
161 |
}; |
|
162 |
|
|
163 |
private static final int[][] VERT_INDEXES_CORNER = new int[][] |
|
164 |
{ |
|
165 |
{ 2,4,3,1 }, |
|
166 |
{ 1,3,5,7 }, |
|
167 |
{ 4,6,5,3 }, |
|
168 |
|
|
169 |
{ 2,10,11,4,0,5,16,17,7,0}, |
|
170 |
{ 4,12,13,6,0,7,18,19,1,0}, |
|
171 |
{ 1, 8, 9,2,0,6,14,15,5,0} |
|
172 |
}; |
|
173 |
|
|
174 |
private static final double[][] VERTICES_EDGE = new double[][] |
|
175 |
{ |
|
176 |
{-0.5f, 0.0f, 0.0f}, |
|
177 |
{ 0.5f, 0.0f, 0.0f}, |
|
178 |
{-0.5f,-1.0f, 0.0f}, |
|
179 |
{ 0.5f,-1.0f, 0.0f}, |
|
180 |
{ 0.0f,-1.5f, 0.0f}, |
|
181 |
{-0.5f, 0.0f,-1.0f}, |
|
182 |
{ 0.5f, 0.0f,-1.0f}, |
|
183 |
{ 0.0f, 0.0f,-1.5f}, |
|
184 |
}; |
|
185 |
|
|
186 |
private static final int[][] VERT_INDEXES_EDGE = new int[][] |
|
187 |
{ |
|
188 |
{ 0,2,4,3,1 }, |
|
189 |
{ 0,1,6,7,5 }, |
|
190 |
{ 1,3,6 }, |
|
191 |
{ 0,2,5 }, |
|
192 |
{ 4,7,6,3 }, |
|
193 |
{ 4,7,5,2 } |
|
194 |
}; |
|
195 |
|
|
196 |
private static final float[][] STICKERS = new float[][] |
|
197 |
{ |
|
198 |
{ -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f }, |
|
199 |
{ -0.3125f, 0.4375f, -0.3125f, -0.1875f, 0.0f, -0.5f, 0.3125f, -0.1875f, 0.3125f, 0.4375f } |
|
200 |
}; |
|
201 |
|
|
202 |
private static MeshBase[] mMeshes; |
|
137 | 203 |
|
138 | 204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
139 | 205 |
|
... | ... | |
144 | 210 |
} |
145 | 211 |
|
146 | 212 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
147 |
// TODO |
|
148 | 213 |
|
149 | 214 |
double[][] getVertices(int cubitType) |
150 | 215 |
{ |
216 |
if( cubitType==0 ) return VERTICES_CORNER; |
|
217 |
if( cubitType==1 ) return VERTICES_EDGE; |
|
151 | 218 |
return null; |
152 | 219 |
} |
153 | 220 |
|
154 | 221 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
155 |
// TODO |
|
156 | 222 |
|
157 | 223 |
int[][] getVertIndexes(int cubitType) |
158 | 224 |
{ |
225 |
if( cubitType==0 ) return VERT_INDEXES_CORNER; |
|
226 |
if( cubitType==1 ) return VERT_INDEXES_EDGE; |
|
159 | 227 |
return null; |
160 | 228 |
} |
161 | 229 |
|
... | ... | |
263 | 331 |
|
264 | 332 |
MeshBase createCubitMesh(int cubit, int numLayers) |
265 | 333 |
{ |
334 |
if( mMeshes==null ) |
|
335 |
{ |
|
336 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
337 |
factory.clear(); |
|
338 |
mMeshes = new MeshBase[2]; |
|
339 |
} |
|
340 |
|
|
266 | 341 |
MeshBase mesh; |
267 | 342 |
|
268 | 343 |
if( cubit<8 ) |
269 | 344 |
{ |
270 |
if( mCornerMesh==null ) mCornerMesh = FactoryCubit.getInstance().createRediCornerMesh(); |
|
271 |
mesh = mCornerMesh.copy(true); |
|
345 |
if( mMeshes[0]==null ) |
|
346 |
{ |
|
347 |
float[][] bands= new float[][] |
|
348 |
{ |
|
349 |
{0.06f,35,0.5f,0.7f,6,2,2}, |
|
350 |
{0.00f, 0,1.0f,0.0f,2,0,0} |
|
351 |
}; |
|
352 |
int[] bandIndexes = new int[] { 0,0,0,1,1,1 }; |
|
353 |
float[][] corners = new float[][] { {0.06f,0.12f} }; |
|
354 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; |
|
355 |
float[][] centers = new float[][] { { 0.0f, 0.0f, 0.0f} }; |
|
356 |
int[] centerIndexes = new int[] { -1,0,-1,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 }; |
|
357 |
|
|
358 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
359 |
factory.createNewFaceTransform(VERTICES_CORNER,VERT_INDEXES_CORNER); |
|
360 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_CORNER, VERT_INDEXES_CORNER, |
|
361 |
bands, bandIndexes, |
|
362 |
corners, cornerIndexes, |
|
363 |
centers, centerIndexes, |
|
364 |
getNumCubitFaces() ); |
|
365 |
} |
|
366 |
mesh = mMeshes[0].copy(true); |
|
272 | 367 |
} |
273 | 368 |
else |
274 | 369 |
{ |
275 |
if( mEdgeMesh==null ) mEdgeMesh = FactoryCubit.getInstance().createRediEdgeMesh(); |
|
276 |
mesh = mEdgeMesh.copy(true); |
|
370 |
if( mMeshes[1]==null ) |
|
371 |
{ |
|
372 |
float[][] bands= new float[][] |
|
373 |
{ |
|
374 |
{0.038f,35,0.250f,0.7f, 7,2,2}, |
|
375 |
{0.020f,35,0.125f,0.2f, 3,1,2}, |
|
376 |
{0.020f,35,0.125f,0.2f, 3,1,1} |
|
377 |
}; |
|
378 |
int[] bandIndexes = new int[] { 0,0,1,1,2,2 }; |
|
379 |
float[][] corners = new float[][] { {0.06f,0.20f} }; |
|
380 |
int[] cornerIndexes = new int[] { 0,0,-1,-1,-1,-1,-1,-1 }; |
|
381 |
float[][] centers = new float[][] { { 0.0f,-0.75f,-0.75f} }; |
|
382 |
int[] centerIndexes = new int[] { 0,0,-1,-1,-1,-1,-1,-1 }; |
|
383 |
|
|
384 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
385 |
factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE); |
|
386 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE, |
|
387 |
bands, bandIndexes, |
|
388 |
corners, cornerIndexes, |
|
389 |
centers, centerIndexes, |
|
390 |
getNumCubitFaces() ); |
|
391 |
} |
|
392 |
mesh = mMeshes[1].copy(true); |
|
277 | 393 |
} |
278 | 394 |
|
279 | 395 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit), new Static3D(0,0,0) ); |
... | ... | |
294 | 410 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top) |
295 | 411 |
{ |
296 | 412 |
int COLORS = FACE_COLORS.length; |
297 |
FactorySticker factory = FactorySticker.getInstance(); |
|
413 |
int stickerType = face/COLORS; |
|
414 |
float R,S; |
|
298 | 415 |
|
299 |
if( face<COLORS )
|
|
416 |
switch(stickerType)
|
|
300 | 417 |
{ |
301 |
float F = 0.5f; |
|
302 |
float R = 0.10f; |
|
303 |
float S = 0.10f; |
|
304 |
float[] vertices = { -F,-F, +F,-F, +F,+F, -F,+F}; |
|
305 |
|
|
306 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R); |
|
418 |
case 0: R = 0.09f; S = 0.09f; break; |
|
419 |
case 1: R = 0.06f; S = 0.06f; break; |
|
420 |
default: R = 0.00f; S = 0.00f; break; |
|
307 | 421 |
} |
308 |
else |
|
309 |
{ |
|
310 |
float F = 0.25f; |
|
311 |
float R = 0.05f; |
|
312 |
float S = 0.05f; |
|
313 |
float[] vertices = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F }; |
|
314 | 422 |
|
315 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face-COLORS], R);
|
|
316 |
}
|
|
423 |
FactorySticker factory = FactorySticker.getInstance();
|
|
424 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], S, FACE_COLORS[face%COLORS], R);
|
|
317 | 425 |
} |
318 | 426 |
|
319 | 427 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert the Redi Cube to the new engine.