Revision a2a4df1b
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/objects/TwistyHelicopter.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; |
... | ... | |
302 | 303 |
return CENTERS; |
303 | 304 |
} |
304 | 305 |
|
306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
307 |
|
|
308 |
ObjectShape getObjectShape(int cubit, int numLayers) |
|
309 |
{ |
|
310 |
int variant = getCubitVariant(cubit,numLayers); |
|
311 |
|
|
312 |
if( variant==0 ) |
|
313 |
{ |
|
314 |
float[][] bands= new float[][] { {0.028f,35,0.16f,0.7f,7,3,3}, {0.000f, 0,1.00f,0.0f,3,1,5} }; |
|
315 |
int[] bandIndices = new int[] { 0,0,0,1,1,1 }; |
|
316 |
float[][] corners = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} }; |
|
317 |
int[] cornerIndices = new int[] { 1,1,1,0,0 }; |
|
318 |
float[][] centers = new float[][] { {-0.25f, -0.25f, -0.25f} }; |
|
319 |
int[] centerIndices = new int[] { 0,0,0,-1,0 }; |
|
320 |
return new ObjectShape(VERTICES_CORNER,VERT_INDEXES_CORNER,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
321 |
} |
|
322 |
else |
|
323 |
{ |
|
324 |
float[][] bands= new float[][] { {0.028f,35,0.16f,0.7f,7,3,3}, {0.000f, 0,1.00f,0.0f,3,1,3} }; |
|
325 |
int[] bandIndices = new int[] { 0,1,1,1 }; |
|
326 |
float[][] corners = new float[][] { {0.06f,0.15f}, {0.06f,0.20f} }; |
|
327 |
int[] cornerIndices = new int[] { 0,1,1,-1 }; |
|
328 |
float[][] centers = new float[][] { {-1.0f/12, -1.0f/12, -1.0f/4} }; |
|
329 |
int[] centerIndices = new int[] { 0,0,0,-1 }; |
|
330 |
return new ObjectShape(VERTICES_FACE,VERT_INDEXES_FACE,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
331 |
} |
|
332 |
} |
|
333 |
|
|
334 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
335 |
|
|
336 |
private Static4D getQuat(int cubit, int numLayers) |
|
337 |
{ |
|
338 |
return QUATS[QUAT_INDICES[cubit]]; |
|
339 |
} |
|
340 |
|
|
341 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
342 |
|
|
343 |
private int getNumCubitVariants(int numLayers) |
|
344 |
{ |
|
345 |
return 2; |
|
346 |
} |
|
347 |
|
|
348 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
349 |
|
|
350 |
int getCubitVariant(int cubit, int numLayers) |
|
351 |
{ |
|
352 |
return cubit<8 ? 0:1; |
|
353 |
} |
|
354 |
|
|
305 | 355 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
306 | 356 |
|
307 | 357 |
MeshBase createCubitMesh(int cubit, int numLayers) |
308 | 358 |
{ |
359 |
int variant = getCubitVariant(cubit,numLayers); |
|
360 |
|
|
309 | 361 |
if( mMeshes==null ) |
310 | 362 |
{ |
311 | 363 |
FactoryCubit factory = FactoryCubit.getInstance(); |
312 | 364 |
factory.clear(); |
313 |
mMeshes = new MeshBase[2];
|
|
365 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
|
|
314 | 366 |
} |
315 | 367 |
|
316 |
MeshBase mesh; |
|
317 |
|
|
318 |
if( cubit<8 ) |
|
319 |
{ |
|
320 |
if( mMeshes[0]==null ) |
|
321 |
{ |
|
322 |
float[][] bands= new float[][] |
|
323 |
{ |
|
324 |
{0.028f,35,0.16f,0.7f,7,3,3}, |
|
325 |
{0.000f, 0,1.00f,0.0f,3,1,5} |
|
326 |
}; |
|
327 |
int[] bandIndexes = new int[] { 0,0,0,1,1,1 }; |
|
328 |
float[][] corners = new float[][] { {0.08f,0.15f}, {0.08f,0.20f} }; |
|
329 |
int[] cornerIndexes = new int[] { 1,1,1,0,0 }; |
|
330 |
float[][] centers = new float[][] { {-0.25f, -0.25f, -0.25f} }; |
|
331 |
int[] centerIndexes = new int[] { 0,0,0,-1,0 }; |
|
332 |
|
|
333 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
334 |
factory.createNewFaceTransform(VERTICES_CORNER,VERT_INDEXES_CORNER); |
|
335 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_CORNER, VERT_INDEXES_CORNER, |
|
336 |
bands, bandIndexes, |
|
337 |
corners, cornerIndexes, |
|
338 |
centers, centerIndexes, |
|
339 |
getNumCubitFaces(), null ); |
|
340 |
} |
|
341 |
mesh = mMeshes[0].copy(true); |
|
342 |
} |
|
343 |
else |
|
368 |
if( mMeshes[variant]==null ) |
|
344 | 369 |
{ |
345 |
if( mMeshes[1]==null ) |
|
346 |
{ |
|
347 |
float[][] bands= new float[][] |
|
348 |
{ |
|
349 |
{0.028f,35,0.16f,0.7f,7,3,3}, |
|
350 |
{0.000f, 0,1.00f,0.0f,3,1,3} |
|
351 |
}; |
|
352 |
int[] bandIndexes = new int[] { 0,1,1,1 }; |
|
353 |
float[][] corners = new float[][] { {0.06f,0.15f}, {0.06f,0.20f} }; |
|
354 |
int[] cornerIndexes = new int[] { 0,1,1,-1 }; |
|
355 |
float[][] centers = new float[][] { {-1.0f/12, -1.0f/12, -1.0f/4} }; |
|
356 |
int[] centerIndexes = new int[] { 0,0,0,-1 }; |
|
357 |
|
|
358 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
359 |
factory.createNewFaceTransform(VERTICES_FACE,VERT_INDEXES_FACE); |
|
360 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_FACE, VERT_INDEXES_FACE, |
|
361 |
bands, bandIndexes, |
|
362 |
corners, cornerIndexes, |
|
363 |
centers, centerIndexes, |
|
364 |
getNumCubitFaces(), null ); |
|
365 |
} |
|
366 |
mesh = mMeshes[1].copy(true); |
|
370 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
371 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
372 |
factory.createNewFaceTransform(shape); |
|
373 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
367 | 374 |
} |
368 | 375 |
|
369 |
int index = QUAT_INDICES[cubit];
|
|
370 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[index], new Static3D(0,0,0) );
|
|
376 |
MeshBase mesh = mMeshes[variant].copy(true);
|
|
377 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
|
|
371 | 378 |
mesh.apply(quat,0xffffffff,0); |
372 | 379 |
|
373 | 380 |
return mesh; |
Also available in: Unified diff
Move 1) Helicopter 2) Ivy to the new cubit creation scheme.