Project

General

Profile

« Previous | Next » 

Revision 596d62a4

Added by Leszek Koltunski about 3 years ago

Convert the Dino and one of the Skewb's cubits to the new engine.

View differences:

src/main/java/org/distorted/helpers/FactoryCubit.java
298 298
    return new MeshJoined(meshes);
299 299
    }
300 300

  
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302

  
303
  MeshBase createFacesDino()
304
    {
305
    MeshBase[] meshes = new MeshPolygon[4];
306

  
307
    float E = 0.5f*SQ2;
308
    float F = 0.5f;
309
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
310
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
311

  
312
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
313
    meshes[0].setEffectAssociation(0,1,0);
314
    meshes[1] = meshes[0].copy(true);
315
    meshes[1].setEffectAssociation(0,2,0);
316

  
317
    float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
318
    float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
319

  
320
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
321
    meshes[2].setEffectAssociation(0,4,0);
322
    meshes[3] = meshes[2].copy(true);
323
    meshes[3].setEffectAssociation(0,8,0);
324

  
325
    return new MeshJoined(meshes);
326
    }
327

  
328 301
///////////////////////////////////////////////////////////////////////////////////////////////////
329 302

  
330 303
  MeshBase createFacesHelicopterCorner()
......
918 891
    return effect;
919 892
    }
920 893

  
921
///////////////////////////////////////////////////////////////////////////////////////////////////
922

  
923
  VertexEffect[] createVertexEffectsDino()
924
    {
925
    float E = 0.5f*SQ2;
926
    float F = 0.5f;
927
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
928

  
929
    Static1D angle1 = new Static1D(-ANGLE);
930
    Static1D angle2 = new Static1D(+ANGLE);
931
    Static3D axisX  = new Static3D(1,0,0);
932
    Static3D axisY  = new Static3D(0,1,0);
933
    Static3D axisZ  = new Static3D(0,-1,1);
934
    Static3D center0= new Static3D(0,0,0);
935
    Static3D center1= new Static3D(0,-3*F,0);
936

  
937
    VertexEffect[] effect = new VertexEffect[10];
938

  
939
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
940
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
941
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
942
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
943
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
944
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
945
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
946
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
947
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
948
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
949

  
950
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
951
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
952
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
953
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
954
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
955
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
956
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
957
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
958
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
959
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
960

  
961
    return effect;
962
    }
963

  
964 894
///////////////////////////////////////////////////////////////////////////////////////////////////
965 895

  
966 896
  VertexEffect[] createVertexEffectsHelicopterCorner()
......
1588 1518
    return mesh;
1589 1519
    }
1590 1520

  
1591
///////////////////////////////////////////////////////////////////////////////////////////////////
1592
// DINO
1593

  
1594
  public MeshBase createDinoMesh()
1595
    {
1596
    MeshBase mesh = createFacesDino();
1597
    VertexEffect[] effects = createVertexEffectsDino();
1598
    for( VertexEffect effect : effects ) mesh.apply(effect);
1599

  
1600
    float F = 0.5f;
1601
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1602
    Static3D[] verticesRound = new Static3D[4];
1603
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1604
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1605
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1606
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1607
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1608

  
1609
    mesh.mergeEffComponents();
1610

  
1611
    return mesh;
1612
    }
1613

  
1614 1521
///////////////////////////////////////////////////////////////////////////////////////////////////
1615 1522
// Helicopter
1616 1523

  

Also available in: Unified diff