Revision f08b268d
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/MeshCubes.java | ||
---|---|---|
32 | 32 |
public class MeshCubes extends MeshObject |
33 | 33 |
{ |
34 | 34 |
private static final float R = 0.0f;//0.2f; |
35 |
private static final float FRONTZ = 0.5f; |
|
36 |
private static final float BACKZ =-0.5f; |
|
37 |
|
|
35 |
|
|
38 | 36 |
private static final int NORTH = 0; |
39 | 37 |
private static final int WEST = 1; |
40 | 38 |
private static final int EAST = 2; |
41 | 39 |
private static final int SOUTH = 3; |
42 | 40 |
|
43 |
private static final boolean BACK = true; |
|
44 |
private static final boolean FRONT = false; |
|
45 |
private static final boolean UPPER = false; |
|
46 |
private static final boolean LOWER = true; |
|
47 |
|
|
48 | 41 |
private static final float[] mNormalX = new float[4]; |
49 | 42 |
private static final float[] mNormalY = new float[4]; |
50 | 43 |
private static final float[] mNormalZ = new float[4]; |
... | ... | |
391 | 384 |
boolean seenLand=false; |
392 | 385 |
boolean lastBlockIsNE = false; |
393 | 386 |
boolean currentBlockIsNE; |
394 |
float vectZ = front?FRONTZ:BACKZ;
|
|
387 |
float vectZ = (front ? 0.5f : -0.5f);
|
|
395 | 388 |
|
396 | 389 |
//android.util.Log.d("CUBES", "buildFrontBack"); |
397 | 390 |
|
... | ... | |
517 | 510 |
side= curr.side; |
518 | 511 |
next = getNextEdge(curr); |
519 | 512 |
|
520 |
addSideVertex(curr,BACK,i+1,prev.side,vertex++,attribs);
|
|
513 |
addSideVertex(curr,true,i+1,prev.side,vertex++,attribs);
|
|
521 | 514 |
|
522 | 515 |
do |
523 | 516 |
{ |
524 | 517 |
if( prev.side!=curr.side ) |
525 | 518 |
{ |
526 |
addSideVertex(curr,BACK,i+1,prev.side,vertex++,attribs);
|
|
527 |
addSideVertex(curr,BACK,i ,prev.side,vertex++,attribs);
|
|
519 |
addSideVertex(curr,true,i+1,prev.side,vertex++,attribs);
|
|
520 |
addSideVertex(curr,true,i ,prev.side,vertex++,attribs);
|
|
528 | 521 |
} |
529 | 522 |
|
530 |
addSideVertex(curr,FRONT,i+1,next.side,vertex++,attribs);
|
|
531 |
addSideVertex(curr,FRONT,i ,next.side,vertex++,attribs);
|
|
523 |
addSideVertex(curr,false,i+1,next.side,vertex++,attribs);
|
|
524 |
addSideVertex(curr,false,i ,next.side,vertex++,attribs);
|
|
532 | 525 |
|
533 | 526 |
prev = curr; |
534 | 527 |
curr = next; |
... | ... | |
628 | 621 |
|
629 | 622 |
attribs[8*vertex ] = x - 0.5f; |
630 | 623 |
attribs[8*vertex+1] = 0.5f - (float)curr.row/mRows; |
631 |
attribs[8*vertex+2] = FRONTZ + ((BACKZ-FRONTZ)*slice)/mSlices;
|
|
624 |
attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
|
|
632 | 625 |
attribs[8*vertex+3] = side==NORTH ? 0.0f : (side==WEST?-R:R); |
633 | 626 |
attribs[8*vertex+4] = 1.0f; |
634 | 627 |
attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
... | ... | |
639 | 632 |
|
640 | 633 |
attribs[8*vertex ] = x - 0.5f; |
641 | 634 |
attribs[8*vertex+1] = 0.5f - (float)(curr.row+1)/mRows; |
642 |
attribs[8*vertex+2] = FRONTZ + ((BACKZ-FRONTZ)*slice)/mSlices;
|
|
635 |
attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
|
|
643 | 636 |
attribs[8*vertex+3] = side==SOUTH ? 0.0f: (side==EAST?-R:R); |
644 | 637 |
attribs[8*vertex+4] =-1.0f; |
645 | 638 |
attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
... | ... | |
650 | 643 |
|
651 | 644 |
attribs[8*vertex ] = (float)curr.col/mCols -0.5f; |
652 | 645 |
attribs[8*vertex+1] = 0.5f - y; |
653 |
attribs[8*vertex+2] = FRONTZ + ((BACKZ-FRONTZ)*slice)/mSlices;
|
|
646 |
attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
|
|
654 | 647 |
attribs[8*vertex+3] =-1.0f; |
655 | 648 |
attribs[8*vertex+4] = side==WEST ? 0.0f : (side==NORTH?-R:R); |
656 | 649 |
attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
... | ... | |
661 | 654 |
|
662 | 655 |
attribs[8*vertex ] = (float)(curr.col+1)/mCols -0.5f; |
663 | 656 |
attribs[8*vertex+1] = 0.5f - y; |
664 |
attribs[8*vertex+2] = FRONTZ + ((BACKZ-FRONTZ)*slice)/mSlices;
|
|
657 |
attribs[8*vertex+2] = 0.5f - (float)slice/mSlices;
|
|
665 | 658 |
attribs[8*vertex+3] = 1.0f; |
666 | 659 |
attribs[8*vertex+4] = side==EAST ? 0.0f : (side==SOUTH?-R:R); |
667 | 660 |
attribs[8*vertex+5] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
Also available in: Unified diff
minor