// For reading the face-data chunk static bool ReadFaceData(OpenedFile& OFile, int32 ParentChunkEnd) { uint8 NFBuffer[2]; uint16 NumFaces; if (!OFile.Read(2,NFBuffer)) { logError1("ERROR reading number of faces in %s",Path); return false; } uint8 *S = NFBuffer; StreamToValue(S,NumFaces); int32 DataSize = 4*sizeof(uint16)*int(NumFaces); SetChunkBufferSize(DataSize); if (!OFile.Read(DataSize,ChunkBufferBase())) { logError1("ERROR reading face-chunk contents in %s",Path); return false; } S = ChunkBufferBase(); ModelPtr->VertIndices.resize(3*NumFaces); for (int k=0; k<NumFaces; k++) { uint16 *CurrPoly = ModelPtr->VIBase() + 3*k; uint16 Flags; StreamToList(S,CurrPoly,3); StreamToValue(S,Flags); } int32 Location = 0; OFile.GetPosition(Location); while(Location < ParentChunkEnd) { ChunkHeaderData ChunkHeader; if (!ReadChunkHeader(OFile,ChunkHeader)) return false; switch(ChunkHeader.ID) { /* case OBJECT: if (!ReadContainer(OFile,ChunkHeader,ReadObject)) return false; break; */ default: if (!SkipChunk(OFile,ChunkHeader)) return false; } // Where are we now? OFile.GetPosition(Location); } if (Location > ParentChunkEnd) { logError3("ERROR: Overran parent chunk: %d > %d in %s",Location,ParentChunkEnd,Path); return false; } return true; }
// For reading the editor-data chunk static bool ReadEditor(OpenedFile& OFile, int32 ParentChunkEnd) { int32 Location = 0; OFile.GetPosition(Location); while(Location < ParentChunkEnd) { ChunkHeaderData ChunkHeader; if (!ReadChunkHeader(OFile,ChunkHeader)) return false; switch(ChunkHeader.ID) { case OBJECT: if (!ReadContainer(OFile,ChunkHeader,ReadObject)) return false; break; default: if (!SkipChunk(OFile,ChunkHeader)) return false; } // Where are we now? OFile.GetPosition(Location); } if (Location > ParentChunkEnd) { logError3("ERROR: Overran parent chunk: %d > %d in %s",Location,ParentChunkEnd,Path); return false; } return true; }
// For reading the triangle-mesh-data chunk static bool ReadTrimesh(OpenedFile& OFile, int32 ParentChunkEnd) { int32 Location = 0; OFile.GetPosition(Location); assert(ModelPtr); while(Location < ParentChunkEnd) { ChunkHeaderData ChunkHeader; if (!ReadChunkHeader(OFile,ChunkHeader)) return false; switch(ChunkHeader.ID) { case VERTICES: if (!LoadChunk(OFile,ChunkHeader)) return false; LoadVertices(); break; case TXTR_COORDS: if (!LoadChunk(OFile,ChunkHeader)) return false; LoadTextureCoordinates(); break; case FACE_DATA: if (!ReadContainer(OFile,ChunkHeader,ReadFaceData)) return false; break; default: if (!SkipChunk(OFile,ChunkHeader)) return false; } // Where are we now? OFile.GetPosition(Location); } if (Location > ParentChunkEnd) { logError3("ERROR: Overran parent chunk: %d > %d in %s",Location,ParentChunkEnd,Path); return false; } return true; }
// For reading the object-data chunk static bool ReadObject(OpenedFile& OFile, int32 ParentChunkEnd) { // Read the name char c; do { if (!OFile.Read(1,&c)) { logError1("ERROR when reading name in %s",Path); return false; } } while(c != 0); int32 Location = 0; OFile.GetPosition(Location); while(Location < ParentChunkEnd) { ChunkHeaderData ChunkHeader; if (!ReadChunkHeader(OFile,ChunkHeader)) return false; switch(ChunkHeader.ID) { case TRIMESH: if (!ReadContainer(OFile,ChunkHeader,ReadTrimesh)) return false; break; default: if (!SkipChunk(OFile,ChunkHeader)) return false; } // Where are we now? OFile.GetPosition(Location); } if (Location > ParentChunkEnd) { logError3("ERROR: Overran parent chunk: %d > %d in %s",Location,ParentChunkEnd,Path); return false; } return true; }
void PluginLoader::ReportParseError(const char* ErrorString, int LineNumber) { logError3("XML parsing error: %s at line %d in %s Plugin.xml", ErrorString, LineNumber, m_name.c_str()); }