34 |
34 |
import org.distorted.library.mesh.MeshJoined;
|
35 |
35 |
import org.distorted.library.mesh.MeshPolygon;
|
36 |
36 |
import org.distorted.library.mesh.MeshSquare;
|
|
37 |
import org.distorted.library.mesh.MeshTriangle;
|
37 |
38 |
import org.distorted.library.type.Static1D;
|
38 |
39 |
import org.distorted.library.type.Static3D;
|
39 |
40 |
import org.distorted.library.type.Static4D;
|
... | ... | |
160 |
161 |
private static final int[][] mFaceMap = new int[][]
|
161 |
162 |
{
|
162 |
163 |
{ 4,2,0, 6,6,6 },
|
163 |
|
{ 2,5,0, 6,6,6 },
|
164 |
|
{ 3,4,0, 6,6,6 },
|
|
164 |
{ 0,2,5, 6,6,6 },
|
|
165 |
{ 4,0,3, 6,6,6 },
|
165 |
166 |
{ 5,3,0, 6,6,6 },
|
166 |
167 |
{ 1,2,4, 6,6,6 },
|
167 |
168 |
{ 5,2,1, 6,6,6 },
|
... | ... | |
199 |
200 |
{ 5 , 6,6,6,6,6 },
|
200 |
201 |
};
|
201 |
202 |
|
|
203 |
private static int[] QUAT_INDICES =
|
|
204 |
{ 0,13,14,1,12,2,3,7,20,6,13,17,7,23,18,12,22,10,8,16,11,21,19,9,3,15,14,0,5,2,1,4 };
|
|
205 |
|
202 |
206 |
private static MeshBase mCornerMesh, mFaceMesh;
|
203 |
207 |
|
204 |
208 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
239 |
243 |
float[] vertices1 = { -F,-1.0f/12, +F,-1.0f/12, 0,1.0f/6 };
|
240 |
244 |
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
241 |
245 |
|
242 |
|
meshes[3] = new MeshPolygon(vertices1,bands1,1,3);
|
|
246 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
243 |
247 |
meshes[3].setEffectAssociation(0,8,0);
|
244 |
248 |
meshes[4] = meshes[3].copy(true);
|
245 |
249 |
meshes[4].setEffectAssociation(0,16,0);
|
... | ... | |
338 |
342 |
|
339 |
343 |
private void createFaceMesh()
|
340 |
344 |
{
|
|
345 |
MeshBase[] meshes = new MeshBase[6];
|
|
346 |
|
341 |
347 |
float D = 0.02f;
|
342 |
348 |
float E = 0.5f;
|
343 |
349 |
float F = SQ2/4;
|
|
350 |
float G = 1.0f/12;
|
344 |
351 |
|
345 |
352 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
346 |
353 |
|
... | ... | |
352 |
359 |
0.30f , D*1.375f,
|
353 |
360 |
0.0f , D*1.4f };
|
354 |
361 |
|
355 |
|
MeshBase[] meshes = new MeshBase[6];
|
356 |
|
|
357 |
362 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
358 |
363 |
meshes[0].setEffectAssociation(0,1,0);
|
359 |
364 |
|
360 |
|
// TODO
|
|
365 |
float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
|
|
366 |
|
|
367 |
float[] bands1 = { 1.0f , 0.0f,
|
|
368 |
0.5f , 0.02f,
|
|
369 |
0.0f , 0.03f };
|
|
370 |
|
|
371 |
meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
|
|
372 |
meshes[1].setEffectAssociation(0,2,0);
|
|
373 |
|
|
374 |
float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
|
|
375 |
|
|
376 |
float[] bands2 = { 1.0f , 0.0f,
|
|
377 |
0.5f , 0.02f,
|
|
378 |
0.0f , 0.03f };
|
|
379 |
|
|
380 |
meshes[2] = new MeshPolygon(vertices2, bands2, 1, 3);
|
|
381 |
meshes[2].setEffectAssociation(0,4,0);
|
|
382 |
meshes[3] = meshes[2].copy(true);
|
|
383 |
meshes[3].setEffectAssociation(0,8,0);
|
|
384 |
meshes[4] = new MeshTriangle(1);
|
|
385 |
meshes[4].setEffectAssociation(0,16,0);
|
|
386 |
meshes[5] = new MeshTriangle(1);
|
|
387 |
meshes[5].setEffectAssociation(0,32,0);
|
|
388 |
|
|
389 |
mFaceMesh = new MeshJoined(meshes);
|
|
390 |
|
|
391 |
Static3D move0 = new Static3D(-1.0f/8, -1.0f/8, 0);
|
|
392 |
Static3D move1 = new Static3D(-(SQ2/24)-1.0f/4, -(SQ2/24)-1.0f/4, 0);
|
|
393 |
Static3D move2 = new Static3D(-E/2, F/3, 0);
|
|
394 |
Static3D move3 = new Static3D(+E/2, F/3, 0);
|
|
395 |
Static3D move4 = new Static3D(+E/3,+E/3, 0);
|
|
396 |
Static1D angle1 = new Static1D(135);
|
|
397 |
Static1D angle2 = new Static1D(90);
|
|
398 |
Static1D angle3 = new Static1D(-90);
|
|
399 |
Static1D angle4 = new Static1D(-135);
|
|
400 |
Static3D axisX = new Static3D(1,0,0);
|
|
401 |
Static3D axisY = new Static3D(0,1,0);
|
|
402 |
Static3D axisZ = new Static3D(0,0,1);
|
|
403 |
Static3D axis1 = new Static3D(1,-1,0);
|
|
404 |
Static3D center = new Static3D(0,0,0);
|
|
405 |
Static3D center1= new Static3D(-0.25f,-0.25f,0);
|
|
406 |
|
|
407 |
float d0 =-0.04f;
|
|
408 |
float d1 =-0.04f;
|
|
409 |
float r0 = 0.15f;
|
|
410 |
float r1 = 0.10f;
|
|
411 |
|
|
412 |
Static3D vec0 = new Static3D(d0*(+SQ3/3),d0*(+SQ3/3),d0*(+SQ3/3));
|
|
413 |
Static3D vec1 = new Static3D(d1*(-SQ3/3),d1*(+SQ3/3),d1*(+SQ3/3));
|
|
414 |
Static3D vec2 = new Static3D(d1*(+SQ3/3),d1*(-SQ3/3),d1*(+SQ3/3));
|
|
415 |
|
|
416 |
Static1D radius = new Static1D(0.5f);
|
|
417 |
|
|
418 |
Static3D cent0 = new Static3D( 0.0f, 0.0f, 0.0f);
|
|
419 |
Static3D cent1 = new Static3D(-0.5f, 0.0f, 0.0f);
|
|
420 |
Static3D cent2 = new Static3D( 0.0f,-0.5f, 0.0f);
|
|
421 |
|
|
422 |
Static4D reg0 = new Static4D(0,0,0,r0);
|
|
423 |
Static4D reg1 = new Static4D(0,0,0,r1);
|
|
424 |
|
|
425 |
VertexEffectMove effect0 = new VertexEffectMove(move0);
|
|
426 |
VertexEffectRotate effect1 = new VertexEffectRotate(angle1, axisZ, center);
|
|
427 |
VertexEffectMove effect2 = new VertexEffectMove(move1);
|
|
428 |
VertexEffectRotate effect3 = new VertexEffectRotate(angle2, axis1, center1);
|
|
429 |
VertexEffectMove effect4 = new VertexEffectMove(move2);
|
|
430 |
VertexEffectMove effect5 = new VertexEffectMove(move3);
|
|
431 |
VertexEffectRotate effect6 = new VertexEffectRotate(angle3, axisZ, center);
|
|
432 |
VertexEffectRotate effect7 = new VertexEffectRotate(angle4, axisX, center);
|
|
433 |
VertexEffectRotate effect8 = new VertexEffectRotate(angle1, axisY, center);
|
|
434 |
VertexEffectScale effect9 = new VertexEffectScale(0);
|
|
435 |
VertexEffectDeform effect10= new VertexEffectDeform(vec0,radius,cent0,reg0);
|
|
436 |
VertexEffectDeform effect11= new VertexEffectDeform(vec1,radius,cent1,reg1);
|
|
437 |
VertexEffectDeform effect12= new VertexEffectDeform(vec2,radius,cent2,reg1);
|
|
438 |
VertexEffectMove effect13= new VertexEffectMove(move4);
|
|
439 |
|
|
440 |
effect0.setMeshAssociation( 1,-1); // mesh 0
|
|
441 |
effect1.setMeshAssociation( 2,-1); // mesh 1
|
|
442 |
effect2.setMeshAssociation( 2,-1); // mesh 1
|
|
443 |
effect3.setMeshAssociation( 2,-1); // mesh 1
|
|
444 |
effect4.setMeshAssociation( 4,-1); // mesh 2
|
|
445 |
effect5.setMeshAssociation( 8,-1); // mesh 3
|
|
446 |
effect6.setMeshAssociation( 8,-1); // mesh 3
|
|
447 |
effect7.setMeshAssociation( 4,-1); // mesh 2
|
|
448 |
effect8.setMeshAssociation( 8,-1); // mesh 3
|
|
449 |
effect9.setMeshAssociation(48,-1); // meshes 4,5
|
|
450 |
effect10.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
451 |
effect11.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
452 |
effect12.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
453 |
effect13.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
454 |
|
|
455 |
mFaceMesh.apply(effect0);
|
|
456 |
mFaceMesh.apply(effect1);
|
|
457 |
mFaceMesh.apply(effect2);
|
|
458 |
mFaceMesh.apply(effect3);
|
|
459 |
mFaceMesh.apply(effect4);
|
|
460 |
mFaceMesh.apply(effect5);
|
|
461 |
mFaceMesh.apply(effect6);
|
|
462 |
mFaceMesh.apply(effect7);
|
|
463 |
mFaceMesh.apply(effect8);
|
|
464 |
mFaceMesh.apply(effect9);
|
|
465 |
mFaceMesh.apply(effect10);
|
|
466 |
mFaceMesh.apply(effect11);
|
|
467 |
mFaceMesh.apply(effect12);
|
|
468 |
mFaceMesh.apply(effect13);
|
361 |
469 |
|
362 |
470 |
mFaceMesh.mergeEffComponents();
|
363 |
471 |
}
|
... | ... | |
366 |
474 |
|
367 |
475 |
float getScreenRatio()
|
368 |
476 |
{
|
369 |
|
return 1.0f;
|
|
477 |
return 2.0f;
|
370 |
478 |
}
|
371 |
479 |
|
372 |
480 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
404 |
512 |
return CENTERS;
|
405 |
513 |
}
|
406 |
514 |
|
407 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
408 |
|
// TODO
|
409 |
|
|
410 |
|
private int getQuatIndex(int cubit)
|
411 |
|
{
|
412 |
|
switch(cubit)
|
413 |
|
{
|
414 |
|
case 0:
|
415 |
|
case 1:
|
416 |
|
case 2:
|
417 |
|
case 3:
|
418 |
|
case 4:
|
419 |
|
case 5:
|
420 |
|
case 6:
|
421 |
|
case 7:
|
422 |
|
case 8:
|
423 |
|
case 9:
|
424 |
|
case 10:
|
425 |
|
case 11:
|
426 |
|
case 12:
|
427 |
|
case 13:
|
428 |
|
case 14:
|
429 |
|
case 15:
|
430 |
|
case 16:
|
431 |
|
case 17:
|
432 |
|
case 18:
|
433 |
|
case 19:
|
434 |
|
case 20:
|
435 |
|
case 21:
|
436 |
|
case 22:
|
437 |
|
case 23:
|
438 |
|
case 24:
|
439 |
|
case 25:
|
440 |
|
case 26:
|
441 |
|
case 27:
|
442 |
|
case 28:
|
443 |
|
case 29:
|
444 |
|
case 30:
|
445 |
|
case 31:
|
446 |
|
}
|
447 |
|
|
448 |
|
return -1;
|
449 |
|
}
|
450 |
|
|
451 |
515 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
452 |
516 |
|
453 |
517 |
MeshBase createCubitMesh(int cubit)
|
... | ... | |
465 |
529 |
mesh = mFaceMesh.copy(true);
|
466 |
530 |
}
|
467 |
531 |
|
468 |
|
int index = getQuatIndex(cubit);
|
|
532 |
int index = QUAT_INDICES[cubit];
|
469 |
533 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[index], new Static3D(0,0,0) );
|
470 |
534 |
mesh.apply(quat,0xffffffff,0);
|
471 |
535 |
|
... | ... | |
556 |
620 |
|
557 |
621 |
public int computeRowFromOffset(float offset)
|
558 |
622 |
{
|
559 |
|
return offset<0.25f ? 0:1;
|
|
623 |
return offset<0.125f ? 0:1;
|
560 |
624 |
}
|
561 |
625 |
|
562 |
626 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
More support for the Helicopter.