I have to say I can't read DAT files properly. Vertex data look
quite promising, but polygon data look absolutely wrong.
I could not find vertices count anywhere, so I though that verts
end when vert coords are zero. But looks like its not it.
Here are structs and code I use:
struct s_FF8_dat_3poly {
short vi[3]; //vertex indexes
char texcoords1[4];
short u1;
char texcoords2[2];
short aa;
} poly3;
struct s_FF8_dat_4poly {
short vi[4]; //vertex indexes
char texcoords1[2];
short u1;
char texcoords2[2];
short aa;
char texcoords3[4];
} poly4;
for( i=0; i<polys3_count; i++ ) {
cfin->Read( 16, &poly3 );
ula[ 0 ] = poly3.vi[ 0 ] &= 0x7FFF;
ula[ 1 ] = poly3.vi[ 1 ];
ula[ 2 ] = poly3.vi[ 2 ];
StorePolygon( 3, ula );
SetPolygonMaterial( polygons_count-1, 0 );
SetPointTexCoords( GetPolygonPoint( polygons_count-1, 0 ),
(double) poly3.texcoords1[ 0 ] / 127, (double) poly3.texcoords1[ 1 ] / 127 );
SetPointTexCoords( GetPolygonPoint( polygons_count-1, 1 ),
(double) poly3.texcoords2[ 0 ] / 127, (double) poly3.texcoords2[ 1 ] / 127 );
SetPointTexCoords( GetPolygonPoint( polygons_count-1, 2 ),
(double) poly3.texcoords2[ 2 ] / 127, (double) poly3.texcoords2[ 3 ] / 127 );
}
for( i=0; i<polys4_count; i++ ) {
cfin->Read( 20, &poly4 );
ula[ 0 ] = poly4.vi[ 0 ] &= 0x7FFF;
ula[ 1 ] = poly4.vi[ 1 ];
ula[ 2 ] = poly4.vi[ 2 ];
ula[ 3 ] = poly4.vi[ 3 ];
StorePolygon( 4, ula );
SetPolygonMaterial( polygons_count-1, 0 );
SetPointTexCoords( GetPolygonPoint( polygons_count-1, 0 ),
(double) poly4.texcoords1[ 0 ] / 127, (double) poly4.texcoords1[ 1 ] / 127 );
SetPointTexCoords( GetPolygonPoint( polygons_count-1, 1 ),
(double) poly4.texcoords2[ 0 ] / 127, (double) poly4.texcoords2[ 1 ] / 127 );
SetPointTexCoords( GetPolygonPoint( polygons_count-1, 2 ),
(double) poly4.texcoords3[ 0 ] / 127, (double) poly4.texcoords3[ 1 ] / 127 );
SetPointTexCoords( GetPolygonPoint( polygons_count-1, 3 ),
(double) poly4.texcoords3[ 2 ] / 127, (double) poly4.texcoords3[ 3 ] / 127 );
}
If you want to read MCH files I can put here some code too.