Revision 2077dd18
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
26 | 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
27 | 28 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
274 | 275 |
|
275 | 276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
276 | 277 |
|
277 |
private Static4D getQuat(int cubit) |
|
278 |
ObjectShape getObjectShape(int cubit, int numLayers) |
|
279 |
{ |
|
280 |
int variant = getCubitVariant(cubit,numLayers); |
|
281 |
|
|
282 |
if( variant==0 ) |
|
283 |
{ |
|
284 |
float[][] bands= new float[][] |
|
285 |
{ |
|
286 |
{0.06f,35,0.5f,0.7f,5,2,2}, |
|
287 |
{0.01f,35,0.2f,0.4f,5,2,2} |
|
288 |
}; |
|
289 |
int[] bandIndices = new int[] { 0,0,0,1,1,1,1,1,1 }; |
|
290 |
float[][] corners = new float[][] { {0.06f,0.12f} }; |
|
291 |
int[] cornerIndices = new int[] { -1,0,-1,0,0,0,-1,-1 }; |
|
292 |
float[][] centers = new float[][] { { 0.0f, 0.0f, 0.0f} }; |
|
293 |
int[] centerIndices = new int[] { -1,0,-1,0,0,0,-1,-1 }; |
|
294 |
|
|
295 |
return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
296 |
} |
|
297 |
else |
|
298 |
{ |
|
299 |
float[][] bands= new float[][] |
|
300 |
{ |
|
301 |
{0.038f,35,0.250f,0.7f, 7,2,2}, |
|
302 |
{0.020f,35,0.125f,0.2f, 3,1,2}, |
|
303 |
{0.020f,35,0.125f,0.2f, 3,1,1} |
|
304 |
}; |
|
305 |
int[] bandIndices = new int[] { 0,0,1,1,2,2 }; |
|
306 |
float[][] corners = new float[][] { {0.06f,0.20f} }; |
|
307 |
int[] cornerIndices = new int[] { 0,0,-1,-1,-1,-1,-1,-1 }; |
|
308 |
float[][] centers = new float[][] { { 0.0f,-0.75f,-0.75f} }; |
|
309 |
int[] centerIndices = new int[] { 0,0,-1,-1,-1,-1,-1,-1 }; |
|
310 |
|
|
311 |
return new ObjectShape(VERTICES_EDGE,VERT_INDEXES_EDGE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
312 |
} |
|
313 |
} |
|
314 |
|
|
315 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
316 |
|
|
317 |
private Static4D getQuat(int cubit, int numLayers) |
|
278 | 318 |
{ |
279 | 319 |
switch(cubit) |
280 | 320 |
{ |
... | ... | |
304 | 344 |
return null; |
305 | 345 |
} |
306 | 346 |
|
347 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
348 |
|
|
349 |
private int getNumCubitVariants(int numLayers) |
|
350 |
{ |
|
351 |
return 2; |
|
352 |
} |
|
353 |
|
|
354 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
355 |
|
|
356 |
int getCubitVariant(int cubit, int numLayers) |
|
357 |
{ |
|
358 |
return cubit<8 ? 0:1; |
|
359 |
} |
|
360 |
|
|
307 | 361 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
308 | 362 |
|
309 | 363 |
MeshBase createCubitMesh(int cubit, int numLayers) |
310 | 364 |
{ |
365 |
int variant = getCubitVariant(cubit,numLayers); |
|
366 |
|
|
311 | 367 |
if( mMeshes==null ) |
312 | 368 |
{ |
313 | 369 |
FactoryCubit factory = FactoryCubit.getInstance(); |
314 | 370 |
factory.clear(); |
315 |
mMeshes = new MeshBase[2];
|
|
371 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
|
|
316 | 372 |
} |
317 | 373 |
|
318 |
MeshBase mesh; |
|
319 |
|
|
320 |
if( cubit<8 ) |
|
374 |
if( mMeshes[variant]==null ) |
|
321 | 375 |
{ |
322 |
if( mMeshes[0]==null ) |
|
323 |
{ |
|
324 |
float[][] bands= new float[][] |
|
325 |
{ |
|
326 |
{0.06f,35,0.5f,0.7f,5,2,2}, |
|
327 |
{0.01f,35,0.2f,0.4f,5,2,2} |
|
328 |
}; |
|
329 |
int[] bandIndexes = new int[] { 0,0,0,1,1,1,1,1,1 }; |
|
330 |
float[][] corners = new float[][] { {0.06f,0.12f} }; |
|
331 |
int[] cornerIndexes = new int[] { -1,0,-1,0,0,0,-1,-1 }; |
|
332 |
float[][] centers = new float[][] { { 0.0f, 0.0f, 0.0f} }; |
|
333 |
int[] centerIndexes = new int[] { -1,0,-1,0,0,0,-1,-1 }; |
|
334 |
|
|
335 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
336 |
factory.createNewFaceTransform(VERTICES_CORNER,VERT_INDEXES_CORNER); |
|
337 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_CORNER, VERT_INDEXES_CORNER, |
|
338 |
bands, bandIndexes, |
|
339 |
corners, cornerIndexes, |
|
340 |
centers, centerIndexes, |
|
341 |
getNumCubitFaces(), null ); |
|
342 |
} |
|
343 |
mesh = mMeshes[0].copy(true); |
|
344 |
} |
|
345 |
else |
|
346 |
{ |
|
347 |
if( mMeshes[1]==null ) |
|
348 |
{ |
|
349 |
float[][] bands= new float[][] |
|
350 |
{ |
|
351 |
{0.038f,35,0.250f,0.7f, 7,2,2}, |
|
352 |
{0.020f,35,0.125f,0.2f, 3,1,2}, |
|
353 |
{0.020f,35,0.125f,0.2f, 3,1,1} |
|
354 |
}; |
|
355 |
int[] bandIndexes = new int[] { 0,0,1,1,2,2 }; |
|
356 |
float[][] corners = new float[][] { {0.06f,0.20f} }; |
|
357 |
int[] cornerIndexes = new int[] { 0,0,-1,-1,-1,-1,-1,-1 }; |
|
358 |
float[][] centers = new float[][] { { 0.0f,-0.75f,-0.75f} }; |
|
359 |
int[] centerIndexes = new int[] { 0,0,-1,-1,-1,-1,-1,-1 }; |
|
360 |
|
|
361 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
362 |
factory.createNewFaceTransform(VERTICES_EDGE,VERT_INDEXES_EDGE); |
|
363 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_EDGE, VERT_INDEXES_EDGE, |
|
364 |
bands, bandIndexes, |
|
365 |
corners, cornerIndexes, |
|
366 |
centers, centerIndexes, |
|
367 |
getNumCubitFaces(), null ); |
|
368 |
} |
|
369 |
mesh = mMeshes[1].copy(true); |
|
376 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
377 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
378 |
factory.createNewFaceTransform(shape); |
|
379 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
370 | 380 |
} |
371 | 381 |
|
372 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit), new Static3D(0,0,0) ); |
|
382 |
MeshBase mesh = mMeshes[variant].copy(true); |
|
383 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) ); |
|
373 | 384 |
mesh.apply(quat,0xffffffff,0); |
374 | 385 |
|
375 | 386 |
return mesh; |
Also available in: Unified diff
Convert Redi Cube to the new scheme.