Game Development Reference
In-Depth Information
if (!ReadShort(fp, numverts)) return 0;
numverts &= 0x3FF; //Mask high 6 bits
//Update Polygon storage
ply = new POLYGON[numpolygons + 1];
if (!ply) return 0;
if (plys){
memcpy(ply, plys, sizeof(POLYGON) * numpolygons);
delete [] plys;
plys = ply;
ply = &ply[numpolygons];
for (j=0;j<numverts;j++){
if (!ReadShort(fp,s)) return 0;
if (j<4) ply->p[j]=(int)s;
ply->numverts = (numverts<5)?numverts:4;
ply->srfID = 0;
return numverts * 2 + 2; //Size of polygon
Notice that we zero the index for the surface when creating a polygon.
The actual value for the surface ID is found from the PTAG chunk. This
chunk can store several features of a polygon; in this stripped down
application we use only one, the SURF section. In the SURF section of a
PTAG chunk we read a polygon index and the surface index that this
polygon uses. The actual index points to the string variable we stored
from the TAGS chunk. To find the actual surface we load a surface and
check its name against the TAG chunk.
For example:
Search Nedrilad ::

Custom Search