Revision e71dd7fb
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/library/mesh/MeshCubes.java | ||
---|---|---|
57 | 57 |
private int mCols, mRows, mSlices; |
58 | 58 |
private int[][] mCubes; |
59 | 59 |
private byte[][] mInflateX, mInflateY; |
60 |
private float mInfCorr; |
|
61 | 60 |
private ArrayList<Edge> mEdges = new ArrayList<>(); |
62 | 61 |
|
63 | 62 |
private int currVert; |
... | ... | |
191 | 190 |
mCols = cols; |
192 | 191 |
mRows = desc.length()/cols; |
193 | 192 |
|
194 |
mInfCorr = mRows>mCols ? mRows:mCols; |
|
195 |
mInfCorr = mSlices>mInfCorr ? mSlices : mInfCorr; |
|
196 |
|
|
197 | 193 |
mCubes = new int[mRows][mCols]; |
198 | 194 |
mInflateX = new byte[mRows+1][mCols+1]; |
199 | 195 |
mInflateY = new byte[mRows+1][mCols+1]; |
... | ... | |
230 | 226 |
mInflateX = new byte[mRows+1][mCols+1]; |
231 | 227 |
mInflateY = new byte[mRows+1][mCols+1]; |
232 | 228 |
|
233 |
mInfCorr = mRows>mCols ? mRows:mCols; |
|
234 |
mInfCorr = mSlices>mInfCorr ? mSlices : mInfCorr; |
|
235 |
|
|
236 | 229 |
for(int col=0; col<mCols; col++) |
237 | 230 |
for(int row=0; row<mRows; row++) |
238 | 231 |
mCubes[row][col] = 1; |
... | ... | |
663 | 656 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = mNormalY[index]; |
664 | 657 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = mNormalZ[index]; |
665 | 658 |
|
666 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInfCorr*mInflateX[row][col]/2.0f;
|
|
667 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
|
|
668 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*vectZ;
|
|
659 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInflateX[row][col]/2.0f; |
|
660 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f; |
|
661 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = vectZ; |
|
669 | 662 |
|
670 | 663 |
attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB ] = x; |
671 | 664 |
attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB+1] = 1.0f-y; |
... | ... | |
697 | 690 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = 1.0f; |
698 | 691 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
699 | 692 |
|
700 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInfCorr*mInflateX[row][col]/2.0f;
|
|
701 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
|
|
702 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
|
|
693 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInflateX[row][col]/2.0f; |
|
694 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f; |
|
695 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z; |
|
703 | 696 |
|
704 | 697 |
texY = (mRows-row+slice)%(2*mRows); |
705 | 698 |
if( texY>mRows ) texY = 2*mRows-texY; |
... | ... | |
722 | 715 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] =-1.0f; |
723 | 716 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
724 | 717 |
|
725 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInfCorr*mInflateX[row][col]/2.0f;
|
|
726 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
|
|
727 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
|
|
718 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInflateX[row][col]/2.0f; |
|
719 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f; |
|
720 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z; |
|
728 | 721 |
|
729 | 722 |
texY = (mRows-row+slice)%(2*mRows); |
730 | 723 |
if( texY>mRows ) texY = 2*mRows-texY; |
... | ... | |
747 | 740 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = side==WEST ? 0.0f : (side==NORTH?-R:R); |
748 | 741 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
749 | 742 |
|
750 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInfCorr*mInflateX[row][col]/2.0f;
|
|
751 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
|
|
752 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
|
|
743 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInflateX[row][col]/2.0f; |
|
744 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f; |
|
745 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z; |
|
753 | 746 |
|
754 | 747 |
texX = (col+slice)%(2*mCols); |
755 | 748 |
if( texX>mCols ) texX = 2*mCols-texX; |
... | ... | |
772 | 765 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = side==EAST ? 0.0f : (side==SOUTH?-R:R); |
773 | 766 |
attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) ); |
774 | 767 |
|
775 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInfCorr*mInflateX[row][col]/2.0f;
|
|
776 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
|
|
777 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
|
|
768 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB ] = mInflateX[row][col]/2.0f; |
|
769 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f; |
|
770 |
attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z; |
|
778 | 771 |
|
779 | 772 |
texX = (col+slice)%(2*mCols); |
780 | 773 |
if( texX>mCols ) texX = 2*mCols-texX; |
Also available in: Unified diff
Improve computation of the thickness of the postprocessing halo - should be independent of the size of underlying object now.
Still it is not completely ok, it appears to depend on the ModelView matrix (use the Effects3D app to rotate the object around Z-axis to see this)