if ( sectors != NULL) delete sectors;
numSectors = directory [ij.size / sizeof ( Sector); sectors = new Sector [numSectors];
Iseek (file, directory [ij.offset, SEEK_SET ); read (file, sectors, directory [ij.size );
}
else
if (Istrnicmp ( directory [ij.name, "SSECTORS", 8 )) {
if(subSectors!=NULL) delete subSectors;
numSubSectors = directory [ij.size / sizeof (SSector);

13. Элементы виртуальной реальност

subSectors = new SSector [numSubSectors];
Iseek (file, directory [ij.offset, SEEKJSET ); read (file, subSectors, directory [ij.size );
}
else
if (Istrnicmp ( directory [ij.name, "NODES", 8 ))
{
if (nodes != NULL) delete nodes;
numNodes = directory [ij.size / sizeof ( Node ); nodes = new Node [numNodes];
Iseek (file, directory [ij.offset, SEEK_SET ); read (file, nodes, directory [i].size );
}
else
if (Istrnicmp (directory [i].name, "THINGS", 8 ))
{
if (things != NULL) delete things;
numThings = directory [ij.size / sizeof (Thing ); things = new Thing [numThings];
Iseek (file, directory [ij.offset, SEEK_SET ); read (file, things, directory [ij.size );
}
else
return;
}
}
void WadFile :: loadPlayPal () {
int index = locateResource ("PLAYPAL");
if (index > -1 ) {
Iseek (file, directory [index].offset, SEEK_SET ); read (file, playPal, sizeof ( playPal));
}
}
void WadFile :: loadColorMap () {
int index = locateResource ("COLORMAP");
if (index > -1 ) {
Iseek (file, directory [index].offset, SEEK_SET ); read (file, colorMap, sizeof ( colorMap ));
}
}
int" WadFile :: locateResource ( const char * name ) {

Компьютерная графика. Полигональные модели

for (register int i = 0; i < hdr.dirEntries; i++ )
if (Istrnicmp ( directory [i].name, name, 8 )) return i;
return -1;
}
Pic * WadFile :: loadPic ( const char * picName ) {
int index = locateResource ( picName );
if (index < 0 ) // not found
return NULL;
// allocate space for resource char * data = (char *) malloc ( directory [index].size ); PicHeader * picHdr = (PicHeader *) data;

⇐ Предыдущая| |Следующая ⇒