Game Development Reference
In-Depth Information
The face list follows a similar pattern to the vertex list. First, the polygon
array is set to zero value then the function enters a 'for' loop reading obj
numpolygons lines from the file. All 3DS polygons are triangles, so the
numverts member is set to 3 and the value of the fourth vertex set to -1.
The polygon order is flipped because Toon3D expects counter-clockwise
polygons to be forward facing and 3DS expects clockwise polygons. The
index of the vertices for the current polygon are read from the file.
BOOL C3DSAscii::ReadFaceList(CStdioFile &file, CToon3DObject *obj)
{
CString line,tmp;
int start,end;
TOKEN tokens[20];
start=file.GetPosition();
end=GetSectionEnd(file);
memset(obj->plys,0,sizeof(POLYGON)*obj->numpolygons);
for (int i=0;i<obj->numpolygons;i++){
if (!FindToken(file,line,"MESH_FACE ",-1,end)) return
FALSE;
if (ParseTokens(line,tokens,20)<17) return FALSE;
//Counter clockwise order
obj->plys[i].p[3] = -1;
obj->plys[i].numverts =3;
obj->plys[i].p[0] = atoi(tokens[3].name);
obj->plys[i].p[2] = atoi(tokens[5].name);
obj->plys[i].p[1] = atoi(tokens[7].name);
obj->plys[i].srf = atoi(tokens[17].name);
}
return TRUE;
}
3DS stores the value of texture coordinates in a special list of texture
vertices. This list is read using the ReadTextureVertices function. Each line
in a MESH_TVERTLIST section contains a MESH_TVERT tag followed by
the index for this texture vertex and three floating-point values. Standard
2D bitmap textures only use the first two floating-point values. The first
value is the u component and the second the v .
*MESH_TVERTLIST {
*MESH_TVERT 0 0.0000 1.0000 0.0000
*MESH_TVERT 1 0.0625 1.0000 0.0000
Search Nedrilad ::




Custom Search