Project

General

Profile

« Previous | Next » 

Revision 1c41c4c9

Added by Leszek Koltunski almost 4 years ago

Improve the Ivy mesh.

View differences:

src/main/java/org/distorted/examples/meshfile/FactoryCubit.java
39 39
  private static final float SQ3 = (float)Math.sqrt(3);
40 40
  private static final float SQ6 = (float)Math.sqrt(6);
41 41

  
42
  private static final float IVY_D = 0.10f;
42
  private static final float IVY_D = 0.003f;
43 43
  private static final int   IVY_N = 8;
44
  private static final float IVY_C = 0.59f;
45
  private static final float IVY_M = 0.35f;
44 46

  
45 47
  private static final Static1D RADIUS = new Static1D(1);
46 48

  
......
505 507
    MeshBase[] meshes = new MeshBase[6];
506 508

  
507 509
    final float angle = (float)Math.PI/(2*IVY_N);
508
    final float CORR  = 1.0f - IVY_D*SQ2;
509
    final float DIST  = 0.4f;
510
    final float CORR2 = 0.5f;
511
    float[] vertices = new float[2*(IVY_N+1)+6];
510
    final float CORR  = 1.0f - 2*IVY_D;
511
    final float DIST  = -0.5f*CORR + IVY_D;
512
    float[] vertices  = new float[2*(IVY_N+1)+6];
512 513

  
513
    vertices[0] = (-0.5f+IVY_D-DIST)*CORR2;
514
    vertices[1] = ( 0.5f      -DIST)*CORR2;
515
    vertices[2] = ( 0.5f      -DIST)*CORR2;
516
    vertices[3] = ( 0.5f      -DIST)*CORR2;
517
    vertices[4] = ( 0.5f      -DIST)*CORR2;
518
    vertices[5] = (-0.5f+IVY_D-DIST)*CORR2;
514
    vertices[0] = (0.5f-IVY_M) * IVY_C;
515
    vertices[1] = (DIST-IVY_M) * IVY_C;
516
    vertices[2] = (0.5f-IVY_M) * IVY_C;
517
    vertices[3] = (0.5f-IVY_M) * IVY_C;
518
    vertices[4] = (DIST-IVY_M) * IVY_C;
519
    vertices[5] = (0.5f-IVY_M) * IVY_C;
519 520

  
520 521
    for(int i=0; i<=IVY_N; i++)
521 522
      {
522
      float sin = (float)Math.sin(i*angle);
523
      float cos = (float)Math.cos(i*angle);
523
      float ang = (IVY_N-i)*angle;
524
      float sin = (float)Math.sin(ang);
525
      float cos = (float)Math.cos(ang);
524 526

  
525
      vertices[2*i+6] = (CORR*(cos-0.5f)-DIST)*CORR2;
526
      vertices[2*i+7] = (CORR*(sin-0.5f)-DIST)*CORR2;
527
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
528
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
527 529
      }
528 530

  
529
    float[] bands0 = computeBands(+0.02f,18,0.2f,0.5f,5);
530
    float[] bands1 = computeBands(-0.10f,20,0.2f,0.0f,2);
531
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
532
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
531 533

  
532
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
534
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
533 535
    meshes[0].setEffectAssociation(0,1,0);
534 536
    meshes[1] = meshes[0].copy(true);
535 537
    meshes[1].setEffectAssociation(0,2,0);
536 538
    meshes[2] = meshes[0].copy(true);
537 539
    meshes[2].setEffectAssociation(0,4,0);
538
    meshes[3] = new MeshPolygon(vertices,bands1,0,0);
540
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
539 541
    meshes[3].setEffectAssociation(0,8,0);
540 542
    meshes[4] = meshes[3].copy(true);
541 543
    meshes[4].setEffectAssociation(0,16,0);
......
982 984

  
983 985
  VertexEffect[] createVertexEffectsIvyCorner()
984 986
    {
985
    float DIST=0.1f;
986

  
987 987
    Static3D axisX  = new Static3D(1,0,0);
988 988
    Static3D axisY  = new Static3D(0,1,0);
989 989
    Static1D angle1 = new Static1D(+90);
990 990
    Static1D angle2 = new Static1D(-90);
991 991
    Static3D center = new Static3D(0,0,0);
992
    Static3D move1  = new Static3D(-DIST,-DIST,0);
992
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
993 993

  
994 994
    VertexEffect[] effect = new VertexEffect[5];
995 995

  
996
    effect[0] = new VertexEffectScale(2.0f);
996
    effect[0] = new VertexEffectScale(1/IVY_C);
997 997
    effect[1] = new VertexEffectMove(move1);
998 998
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
999 999
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
......
1268 1268

  
1269 1269
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1270 1270
    Static3D[] vertices = new Static3D[4];
1271
    float DIST = IVY_D-0.5f;
1272
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1273
    vertices[1] = new Static3D( DIST,+0.5f,+0.5f);
1274
    vertices[2] = new Static3D(+0.5f, DIST,+0.5f);
1275
    vertices[3] = new Static3D(+0.5f,+0.5f, DIST);
1271
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1272
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1273
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1274
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1276 1275

  
1277
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1276
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1278 1277

  
1279 1278
    mesh.mergeEffComponents();
1280 1279

  
......
1287 1286
    {
1288 1287
    MeshBase mesh = createFacesIvyFace();
1289 1288

  
1290
    float DIST = SQ2*(0.5f-IVY_D);
1291
    Static3D center = new Static3D(0.0f,0.0f,-0.0f);
1289
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1292 1290
    Static3D[] vertices = new Static3D[2];
1293
    vertices[0] = new Static3D(+DIST,-DIST,+0.0f);
1294
    vertices[1] = new Static3D(-DIST,+DIST,+0.0f);
1291
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1292
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1295 1293

  
1296
    roundCorners(mesh,center,vertices,0.10f,0.30f);
1294
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1297 1295

  
1298 1296
    mesh.mergeEffComponents();
1299 1297
    mesh.addEmptyTexComponent();
src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
330 330

  
331 331
    private void createMesh()
332 332
      {
333
      mMesh = createStaticMesh();
333
      FactoryCubit factory = FactoryCubit.getInstance();
334
      mMesh = factory.createIvyCornerMesh();
335

  
336
      //mMesh = createStaticMesh();
334 337

  
335 338
      int numEff = mMesh.numEffComponents();
336 339

  

Also available in: Unified diff