Project

General

Profile

« Previous | Next » 

Revision 985ea9c5

Added by Leszek Koltunski over 7 years ago

Finally fix the 'when rendering though an FBO, the other side of triangles is visible'

View differences:

src/main/java/org/distorted/library/DistortedCubesGrid.java
36 36
   private static final int EAST  = 2;
37 37
   private static final int SOUTH = 3;
38 38

  
39
   private static final int NW = 0;
40
   private static final int NE = 1;
41
   private static final int SW = 2;
42
   private static final int SE = 3;
43

  
44 39
   private static final boolean BACK  = true;
45 40
   private static final boolean FRONT = false;
46 41
   private static final boolean UPPER = false;
......
427 422
     normal[3*vertex+1]   = mNormalY[index];
428 423
     normal[3*vertex+2]   = mNormalZ[index];
429 424
     texture[2*vertex  ]  = x;
430
     texture[2*vertex+1]  = y;
425
     texture[2*vertex+1]  = 1.0f-y;
431 426

  
432 427
     return vertex+1;
433 428
     }
......
655 650

  
656 651
     remainingVert--;
657 652

  
658
     float centerX = curr.col-(mCols-1.0f)/2.0f;
659
     float centerY = (mRows-1.0f)/2.0f-curr.row;
660
  
653
     float x, y;
654

  
661 655
     switch(curr.side)
662 656
       {
663
       case NORTH: position[3*vertex  ] = (back ? (centerX-0.5f) : (centerX+0.5f))/mCols;
664
                   position[3*vertex+1] = (centerY+0.5f)/mRows;
657
       case NORTH: x = (float)(back ? (curr.col  ):(curr.col+1))/mCols;
658

  
659
                   position[3*vertex  ] = x - 0.5f;
660
                   position[3*vertex+1] = 0.5f - (float)curr.row/mRows;
665 661
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;
666 662

  
667 663
                   normal[3*vertex  ]   = side==NORTH ? 0.0f : (side==WEST?-R:R);
668 664
                   normal[3*vertex+1]   = 1.0f;
669 665
                   normal[3*vertex+2]   = lower ? -R:R;
670 666

  
671
                   texture[2*vertex  ]  = (float)(back ? (curr.col  ):(curr.col+1))/mCols;
672
                   texture[2*vertex+1]  = (float)(lower? (curr.row-1):(curr.row  ))/mRows;  
667
                   texture[2*vertex  ]  = x;
668
                   texture[2*vertex+1]  = 1.0f-(float)(lower? (curr.row-1):(curr.row  ))/mRows;
673 669
                   break;
674
       case SOUTH: position[3*vertex  ] = (back ? (centerX+0.5f) : (centerX-0.5f))/mCols;
675
                   position[3*vertex+1] = (centerY-0.5f)/mRows;
670
       case SOUTH: x = (float)(back ? (curr.col+1):(curr.col  ))/mCols;
671

  
672
                   position[3*vertex  ] = x - 0.5f;
673
                   position[3*vertex+1] = 0.5f - (float)(curr.row+1)/mRows;
676 674
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;  
677 675
            
678 676
                   normal[3*vertex  ]   = side==SOUTH ? 0.0f: (side==EAST?-R:R);
679 677
                   normal[3*vertex+1]   =-1.0f;
680 678
                   normal[3*vertex+2]   = lower ? -R:R;
681 679

  
682
                   texture[2*vertex  ]  = (float)(back ? (curr.col+1):(curr.col  ))/mCols;
683
                   texture[2*vertex+1]  = (float)(lower? (curr.row+2):(curr.row+1))/mRows;
680
                   texture[2*vertex  ]  = x;
681
                   texture[2*vertex+1]  = 1.0f-(float)(lower? (curr.row+2):(curr.row+1))/mRows;
684 682
                   break;
685
       case WEST : position[3*vertex  ] = (centerX-0.5f)/mCols;
686
                   position[3*vertex+1] = (back ? (centerY-0.5f):(centerY+0.5f))/mRows;
683
       case WEST : y = (float)(back  ? (curr.row+1):(curr.row))/mRows;
684

  
685
                   position[3*vertex  ] = (float)curr.col/mCols -0.5f;
686
                   position[3*vertex+1] = 0.5f - y;
687 687
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;
688 688

  
689 689
                   normal[3*vertex  ]   =-1.0f;
......
691 691
                   normal[3*vertex+2]   = lower ? -R:R;
692 692
 
693 693
                   texture[2*vertex  ]  = (float)(lower ? (curr.col-1):(curr.col  ))/mCols;
694
                   texture[2*vertex+1]  = (float)(back  ? (curr.row+1):(curr.row  ))/mRows;
694
                   texture[2*vertex+1]  = 1.0f - y;
695 695
                   break;
696
       case EAST : position[3*vertex  ] = (centerX+0.5f)/mCols;
697
                   position[3*vertex+1] = (back ? (centerY+0.5f):(centerY-0.5f))/mRows;
696
       case EAST : y = (float)(back  ? (curr.row):(curr.row+1))/mRows;
697

  
698
                   position[3*vertex  ] = (float)(curr.col+1)/mCols -0.5f;
699
                   position[3*vertex+1] = 0.5f - y;
698 700
                   position[3*vertex+2] = lower ? BACKZ : FRONTZ;
699 701

  
700 702
                   normal[3*vertex  ]   = 1.0f;
......
702 704
                   normal[3*vertex+2]   = lower ? -R:R; 
703 705

  
704 706
                   texture[2*vertex  ]  = (float)(lower ? (curr.col+2):(curr.col+1))/mCols;
705
                   texture[2*vertex+1]  = (float)(back  ? (curr.row  ):(curr.row+1))/mRows;
707
                   texture[2*vertex+1]  = 1.0f - y;
706 708
                   break;
707 709
       }
708 710
     

Also available in: Unified diff