| 783 |
783 |
}
|
| 784 |
784 |
|
| 785 |
785 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
786 |
// Return the number of bytes read.
|
| 786 |
787 |
|
| 787 |
|
void read(DataInputStream stream)
|
|
788 |
int read(DataInputStream stream)
|
| 788 |
789 |
{
|
| 789 |
790 |
byte[] buffer = new byte[BYTES_PER_FLOAT*4];
|
| 790 |
791 |
int version, numEff, numTex;
|
| ... | ... | |
| 801 |
802 |
mNumVertices= byteBuf.getInt(4);
|
| 802 |
803 |
numTex = byteBuf.getInt(8);
|
| 803 |
804 |
numEff = byteBuf.getInt(12);
|
| 804 |
|
|
| 805 |
|
// android.util.Log.e("mesh", "version: "+version+" vert: "+mNumVertices+" numTex: "+numTex+" numEff: "+numEff);
|
| 806 |
805 |
}
|
| 807 |
806 |
else
|
| 808 |
807 |
{
|
| 809 |
808 |
android.util.Log.e("mesh", "Error: unknown mesh file version "+String.format("0x%08X", version));
|
| 810 |
|
return;
|
|
809 |
return 0;
|
| 811 |
810 |
}
|
| 812 |
811 |
}
|
| 813 |
812 |
catch(IOException e)
|
| 814 |
813 |
{
|
| 815 |
814 |
android.util.Log.e("mesh", "IOException1 trying to read file: "+e.toString());
|
| 816 |
|
return;
|
|
815 |
return 0;
|
| 817 |
816 |
}
|
| 818 |
817 |
|
| 819 |
818 |
if( mNumVertices>0 && numEff>0 && numTex>0 )
|
| ... | ... | |
| 832 |
831 |
catch(IOException e)
|
| 833 |
832 |
{
|
| 834 |
833 |
android.util.Log.e("mesh", "IOException2 trying to read file: "+e.toString());
|
| 835 |
|
return;
|
|
834 |
return 0;
|
| 836 |
835 |
}
|
| 837 |
836 |
|
| 838 |
|
|
| 839 |
837 |
ByteBuffer byteBuf = ByteBuffer.wrap(buffer);
|
| 840 |
838 |
FloatBuffer floatBuf = byteBuf.asFloatBuffer();
|
| 841 |
839 |
|
| 842 |
840 |
floatBuf.get(tmp,0,size);
|
| 843 |
|
|
| 844 |
|
/*
|
| 845 |
|
for(int f=0; f<size; f++)
|
| 846 |
|
{
|
| 847 |
|
android.util.Log.e("mesh", "tmp "+f+": "+tmp[f]);
|
| 848 |
|
}
|
| 849 |
|
*/
|
| 850 |
|
|
| 851 |
841 |
floatBuf.get(mVertAttribs1, 0, VERT1_ATTRIBS*mNumVertices);
|
| 852 |
842 |
floatBuf.get(mVertAttribs2, 0, VERT2_ATTRIBS*mNumVertices);
|
| 853 |
|
/*
|
| 854 |
|
for(int f=0; f<mNumVertices; f++)
|
| 855 |
|
{
|
| 856 |
|
android.util.Log.e("mesh", "vert "+f+": "+mVertAttribs1[9*f]+" "+mVertAttribs1[9*f+1]+" "+mVertAttribs1[9*f+2]+" "+mVertAttribs1[9*f+3]+" "+mVertAttribs1[9*f+4]+" "+mVertAttribs1[9*f+5]+" "+mVertAttribs1[9*f+6]+" "+mVertAttribs1[9*f+7]+" "+mVertAttribs1[9*f+8]);
|
| 857 |
|
}
|
| 858 |
|
*/
|
|
843 |
|
| 859 |
844 |
TexComponent tex;
|
| 860 |
845 |
int index, texComp;
|
| 861 |
846 |
float x, y, z, w;
|
| ... | ... | |
| 869 |
854 |
z= tmp[TEX_COMP_SIZE*texComp+3];
|
| 870 |
855 |
w= tmp[TEX_COMP_SIZE*texComp+4];
|
| 871 |
856 |
|
| 872 |
|
//android.util.Log.e("mesh", "tex comp "+texComp+" index="+index+" x="+x+" y="+y+" z="+z+" w="+w);
|
| 873 |
|
|
| 874 |
857 |
tex = new TexComponent(index);
|
| 875 |
858 |
tex.setMap(new Static4D(x,y,z,w));
|
| 876 |
859 |
|
| ... | ... | |
| 881 |
864 |
{
|
| 882 |
865 |
index = (int)tmp[TEX_COMP_SIZE*texComp + effComp ];
|
| 883 |
866 |
mEffComponent.add(index);
|
| 884 |
|
|
| 885 |
|
|
| 886 |
|
//android.util.Log.e("mesh", "eff comp "+effComp+" index="+index);
|
| 887 |
|
|
| 888 |
867 |
}
|
| 889 |
868 |
}
|
|
869 |
|
|
870 |
return BYTES_PER_FLOAT*( 4 + numEff+TEX_COMP_SIZE*numTex + VERT1_ATTRIBS*mNumVertices + VERT2_ATTRIBS*mNumVertices );
|
| 890 |
871 |
}
|
| 891 |
872 |
|
| 892 |
873 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Progress with the MeshFile app.