Project

General

Profile

« Previous | Next » 

Revision d1a396b2

Added by Leszek Koltunski almost 7 years ago

Progress with any depth MeshCubes.

View differences:

src/main/java/org/distorted/library/MeshCubes.java
84 84
///////////////////////////////////////////////////////////////////////////////////////////////////
85 85
// return the number of vertices our grid will contain
86 86

  
87
   private int computeDataLength(int slices)
87
   private int computeDataLength()
88 88
      {
89 89
      int frontWalls=0, frontSegments=0, triangleShifts=0, windingShifts=0;
90 90
      int shiftCol = (mCols-1)/2;
......
111 111

  
112 112
      int frontVert = 2*( frontWalls + 2*frontSegments - 1) +2*triangleShifts + windingShifts;
113 113
      int sideVert  = 2*( mSideWalls + mSideBends + mEdgeNum -1);
114
      int firstWinding= (slices>0 && (frontVert+1)%2==1 ) ? 1:0;
115
      int dataL = slices==0 ? frontVert : (frontVert+1) +firstWinding+ (1+sideVert+1) + (1+frontVert);
114
      int firstWinding= (mSlices>0 && (frontVert+1)%2==1 ) ? 1:0;
115
      int dataL = mSlices==0 ? frontVert : (frontVert+1) +firstWinding+ (1+sideVert+1) + (1+frontVert);
116 116
/*
117 117
      android.util.Log.e("CUBES","triangleShifts="+triangleShifts+" windingShifts="+windingShifts+" winding1="+firstWinding+" frontVert="+frontVert+" sideVert="+sideVert);
118 118
      android.util.Log.e("CUBES", "frontW="+frontWalls+" fSegments="+frontSegments+" sWalls="+mSideWalls+" sSegments="+mEdgeNum+" sideBends="+mSideBends+" dataLen="+dataL );
......
188 188
       //android.util.Log.d("cubes", "VERT STRING:"+debug(mBoundingVert,3));
189 189

  
190 190
       markRegions();
191
       numVertices = computeDataLength(slices);
191
       numVertices = computeDataLength();
192 192

  
193 193
       remainingVert = numVertices;
194 194
       }
......
213 213
           mCubes[i][j] = 1;
214 214

  
215 215
       markRegions();
216
       numVertices = computeDataLength(slices);
216
       numVertices = computeDataLength();
217 217

  
218 218
       remainingVert = numVertices;
219 219
       }
......
482 482
   
483 483
///////////////////////////////////////////////////////////////////////////////////////////////////
484 484

  
485
  private int buildSideGrid(int vertex, int slices, float[] attribs)
485
  private int buildSideGrid(int vertex, float[] attribs)
486 486
     {
487 487
     //android.util.Log.d("CUBES", "buildSide");
488 488

  
489 489
     for(int i=0; i<mEdgeNum; i++)
490 490
       {
491
       vertex = buildIthSide(mEdges.get(i), vertex, slices, attribs);
491
       vertex = buildIthSide(mEdges.get(i), vertex, attribs);
492 492
       } 
493 493
      
494 494
     return vertex;
......
496 496

  
497 497
///////////////////////////////////////////////////////////////////////////////////////////////////
498 498

  
499
  private int buildIthSide(Edge curr, int vertex, int slices, float[] attribs)
499
  private int buildIthSide(Edge curr, int vertex, float[] attribs)
500 500
     {
501 501
     Edge prev; 
502 502
     
......
504 504
       {
505 505
       prev = new Edge(WEST,curr.row,curr.col);
506 506
       }
507
     else                   // land outside; we need to move forward one link because we are going in opposite direction and we need to start from a bend.
508
       {
507
     else                   // land outside; we need to move forward one link because we are
508
       {                    // going in opposite direction and we need to start from a bend.
509 509
       prev = curr;
510 510
       curr = new Edge(EAST,curr.row+1,curr.col-1);
511 511
       }
......
680 680

  
681 681
///////////////////////////////////////////////////////////////////////////////////////////////////
682 682

  
683
  private void build(int slices)
683
  private void build()
684 684
     {
685 685
     int vertSoFar=0;
686 686
     float[] attribs= new float[(POS_DATA_SIZE+NOR_DATA_SIZE+TEX_DATA_SIZE)*numVertices];
......
689 689

  
690 690
     vertSoFar = buildFrontBackGrid(true, vertSoFar,attribs);
691 691

  
692
     if( slices>0 )
692
     if( mSlices>0 )
693 693
       {
694 694
       vertSoFar = repeatLast(vertSoFar,attribs);
695 695
       if( vertSoFar%2==1 )
......
701 701

  
702 702
       //android.util.Log.d("MeshCubes","building side grid...");
703 703

  
704
       vertSoFar = buildSideGrid (vertSoFar,slices,attribs);
704
       vertSoFar = buildSideGrid (vertSoFar,attribs);
705 705

  
706 706
       //android.util.Log.d("MeshCubes","building back grid...");
707 707

  
......
753 753
   {
754 754
   super( (float)slices/cols);
755 755
   prepareDataStructures(cols,desc,slices);
756
   build(slices);
756
   build();
757 757
   }
758 758

  
759 759
///////////////////////////////////////////////////////////////////////////////////////////////////
......
768 768
   {
769 769
   super( (float)slices/cols);
770 770
   prepareDataStructures(cols,rows,slices);
771
   build(slices);
771
   build();
772 772
   }
773 773
 }

Also available in: Unified diff