Project

General

Profile

« Previous | Next » 

Revision 8d3cfe99

Added by Leszek Koltunski about 4 years ago

New API for the library: add an empty texture component to a Mesh.
Use this in thr Magic Cube to add empty texture components to some types of cubits.

View differences:

src/main/java/org/distorted/objects/CubitFactory.java
298 298

  
299 299
  MeshBase createSkewbFaceMesh()
300 300
    {
301
    int association = 1;
302

  
303 301
    float D = 0.03f;
304 302
    float E = SQ2/4;
305 303
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
......
312 310
                       0.30f   , D*1.60f,
313 311
                       0.0f    , D*1.70f };
314 312

  
315
    MeshBase[] meshes = new MeshBase[6];
313
    MeshBase[] meshes = new MeshBase[5];
316 314
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
317
    meshes[0].setEffectAssociation(0,association,0);
318

  
319
    association <<= 1;
315
    meshes[0].setEffectAssociation(0,1,0);
320 316

  
321 317
    float[] vertices1 = { -E,-SQ3*E, +E,-SQ3*E, 0,0 };
322 318
    float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
323 319

  
324 320
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
325
    meshes[1].setEffectAssociation(0,association,0);
326

  
327
    for(int i=2; i<5; i++)
328
      {
329
      association <<= 1;
330
      meshes[i] = meshes[1].copy(true);
331
      meshes[i].setEffectAssociation(0,association,0);
332
      }
333

  
334
    association <<= 1;
335
    meshes[5] = new MeshTriangle(1);                  // empty triangle so that
336
    meshes[5].setEffectAssociation(0,association,0);  // all cubits have 6 faces
321
    meshes[1].setEffectAssociation(0,2,0);
322
    meshes[2] = meshes[1].copy(true);
323
    meshes[2].setEffectAssociation(0,4,0);
324
    meshes[3] = meshes[1].copy(true);
325
    meshes[3].setEffectAssociation(0,8,0);
326
    meshes[4] = meshes[1].copy(true);
327
    meshes[4].setEffectAssociation(0,16,0);
337 328

  
338 329
    MeshBase mesh = new MeshJoined(meshes);
339 330

  
......
348 339
    VertexEffect effect3 = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
349 340
    VertexEffect effect4 = new VertexEffectRotate( new Static1D( -135), axisZ, center);
350 341
    VertexEffect effect5 = new VertexEffectMove( new Static3D(0,0,-0.5f) );
351
    VertexEffect effect6 = new VertexEffectScale(0);
352 342

  
353 343
    effect0.setMeshAssociation(30,-1);  // meshes 1,2,3,4
354 344
    effect1.setMeshAssociation( 2,-1);  // mesh 1
......
356 346
    effect3.setMeshAssociation( 8,-1);  // mesh 3
357 347
    effect4.setMeshAssociation(16,-1);  // mesh 4
358 348
    effect5.setMeshAssociation(30,-1);  // meshes 1,2,3,4
359
    effect6.setMeshAssociation(32,-1); // mesh 5
360 349

  
361 350
    mesh.apply(effect0);
362 351
    mesh.apply(effect1);
......
364 353
    mesh.apply(effect3);
365 354
    mesh.apply(effect4);
366 355
    mesh.apply(effect5);
367
    mesh.apply(effect6);
368 356

  
369 357
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
370 358

  
......
376 364
    roundCorners(mesh,roundingCenter,vertices,0.10f,0.10f);
377 365

  
378 366
    mesh.mergeEffComponents();
367
    mesh.addEmptyTexComponent();
379 368

  
380 369
    return mesh;
381 370
    }
......
467 456

  
468 457
  MeshBase createTetraMesh()
469 458
    {
470
    MeshBase[] meshes = new MeshBase[8];
459
    MeshBase[] meshes = new MeshBase[4];
471 460
    int association = 1;
472 461

  
473 462
    float C = 0.06f;
......
494 483
      meshes[i].setEffectAssociation(0,association,0);
495 484
      }
496 485

  
497
    for(int i=4; i<8; i++)
498
      {
499
      association <<= 1;
500
      meshes[i] = new MeshTriangle(1);
501
      meshes[i].setEffectAssociation(0,association,0);
502
      }
503

  
504 486
    MeshBase mesh = new MeshJoined(meshes);
505 487

  
506 488
    Static3D flipZ = new Static3D( 1, 1,-1);
......
523 505
    VertexEffect effect3 = new VertexEffectScale(flipZ);
524 506
    VertexEffect effect4 = new VertexEffectRotate(angle1, axisY, cent0);
525 507
    VertexEffect effect5 = new VertexEffectRotate(angle2, axisZ, cent0);
526
    VertexEffect effect6 = new VertexEffectScale(0);
527 508

  
528 509
    effect0.setMeshAssociation(15,-1); // meshes 0,1,2,3
529 510
    effect1.setMeshAssociation(15,-1); // meshes 0,1,2,3
......
531 512
    effect3.setMeshAssociation(10,-1); // meshes 1 & 3
532 513
    effect4.setMeshAssociation(12,-1); // meshes 2 & 3
533 514
    effect5.setMeshAssociation(12,-1); // meshes 2 & 3
534
    effect6.setMeshAssociation(240,-1);// meshes 4,5,6,7
535 515

  
536 516
    mesh.apply(effect0);
537 517
    mesh.apply(effect1);
......
539 519
    mesh.apply(effect3);
540 520
    mesh.apply(effect4);
541 521
    mesh.apply(effect5);
542
    mesh.apply(effect6);
543 522

  
544 523
    Static3D[] verticesRound = new Static3D[4];
545 524
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
......
549 528
    roundCorners(mesh,cent0,verticesRound,0.08f,0.15f);
550 529

  
551 530
    mesh.mergeEffComponents();
531
    mesh.addEmptyTexComponent();
532
    mesh.addEmptyTexComponent();
533
    mesh.addEmptyTexComponent();
534
    mesh.addEmptyTexComponent();
552 535

  
553 536
    return mesh;
554 537
    }
......
761 744

  
762 745
  MeshBase createHelicopterFaceMesh()
763 746
    {
764
    MeshBase[] meshes = new MeshBase[6];
747
    MeshBase[] meshes = new MeshBase[4];
765 748

  
766 749
    float D = 0.02f;
767 750
    float E = 0.5f;
......
800 783
    meshes[2].setEffectAssociation(0,4,0);
801 784
    meshes[3] = meshes[2].copy(true);
802 785
    meshes[3].setEffectAssociation(0,8,0);
803
    meshes[4] = new MeshTriangle(1);
804
    meshes[4].setEffectAssociation(0,16,0);
805
    meshes[5] = new MeshTriangle(1);
806
    meshes[5].setEffectAssociation(0,32,0);
807 786

  
808 787
    MeshBase mesh = new MeshJoined(meshes);
809 788

  
......
833 812
    VertexEffect effect7 = new VertexEffectRotate(angle4, axisX, center);
834 813
    VertexEffect effect8 = new VertexEffectRotate(angle1, axisY, center);
835 814
    VertexEffect effect9 = new VertexEffectMove(move4);
836
    VertexEffect effect10= new VertexEffectScale(0);
837 815

  
838 816
    effect0.setMeshAssociation( 1,-1);  // mesh 0
839 817
    effect1.setMeshAssociation( 2,-1);  // mesh 1
......
845 823
    effect7.setMeshAssociation( 4,-1);  // mesh 2
846 824
    effect8.setMeshAssociation( 8,-1);  // mesh 3
847 825
    effect9.setMeshAssociation(15,-1);  // meshes 0,1,2,3
848
    effect10.setMeshAssociation(48,-1); // meshes 4,5
849 826

  
850 827
    mesh.apply(effect0);
851 828
    mesh.apply(effect1);
......
857 834
    mesh.apply(effect7);
858 835
    mesh.apply(effect8);
859 836
    mesh.apply(effect9);
860
    mesh.apply(effect10);
861 837

  
862 838
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
863 839

  
......
871 847
    roundCorners(mesh,roundingCenter,verticesType2,0.10f,0.20f);
872 848

  
873 849
    mesh.mergeEffComponents();
850
    mesh.addEmptyTexComponent();
851
    mesh.addEmptyTexComponent();
874 852

  
875 853
    return mesh;
876 854
    }
src/main/java/org/distorted/objects/TwistyObject.java
69 69
  private static final float MAX_SIZE_CHANGE = 1.35f;
70 70
  private static final float MIN_SIZE_CHANGE = 0.8f;
71 71

  
72
  private static boolean mCreateFromDMesh = true;
72
  private static boolean mCreateFromDMesh = false;
73 73

  
74 74
  private static final Static3D CENTER = new Static3D(0,0,0);
75 75
  private static final int POST_ROTATION_MILLISEC = 500;

Also available in: Unified diff