void CSMFile::clear() { header.clear(); cameraData.clear(); u32 x =0; for( x= 0; x < groups.size(); x++) delete groups[x]; groups.clear(); for(x= 0; x < visgroups.size(); x++) delete visgroups[x]; visgroups.clear(); for(x= 0; x < lightmaps.size(); x++) delete lightmaps[x]; lightmaps.clear(); for(x= 0; x < meshes.size(); x++) delete meshes[x]; meshes.clear(); for(x= 0; x < entities.size(); x++) delete entities[x]; entities.clear(); }
void CSMFile::load(BinaryFileReader* pReader) { clear(); header.load(pReader); //groups { s32 count = pReader->readLong(); for (s32 i = 0; i < count; i++) { Group* grp = new Group(); grp->load(pReader); groups.push_back(grp); } } bool bHasVGroups = (header.getVersion() == Header::VERSION_4_1); if (bHasVGroups) { //visgroups s32 count = pReader->readLong(); for (s32 i = 0; i < count; i++) { VisGroup* grp = new VisGroup(); grp->load(pReader); visgroups.push_back(grp); } } //lightmaps { s32 count = pReader->readLong(); for(s32 i = 0; i < count; i++) { LightMap* grp = new LightMap(); grp->load(pReader); lightmaps.push_back(grp); } } //meshes { s32 count = pReader->readLong(); for(s32 i = 0; i < count; i++) { Mesh* grp = new Mesh(); grp->load(pReader,bHasVGroups); meshes.push_back(grp); } } //entities { s32 count = pReader->readLong(); for(s32 i = 0; i < count; i++) { Entity* grp = new Entity(); grp->load(pReader); entities.push_back(grp); } } //camera data cameraData.load(pReader); }
void CSMFile::load(BinaryFileReader* pReader) { clear(); header.load(pReader); //groups { const s32 count = pReader->readLong(); #ifdef _IRR_DEBUG_CSM_LOADER_ os::Printer::log("CSM Version", core::stringc(header.getVersion()).c_str()); os::Printer::log("Loading groups. Count", core::stringc(count)); #endif groups.reallocate(count); for (s32 i = 0; i < count; i++) { Group* grp = new Group(); grp->load(pReader); groups.push_back(grp); } } const bool bHasVGroups = (header.getVersion() == Header::VERSION_4_1); if (bHasVGroups) { //visgroups const s32 count = pReader->readLong(); #ifdef _IRR_DEBUG_CSM_LOADER_ os::Printer::log("Loading visgroups. Count", core::stringc(count)); #endif visgroups.reallocate(count); for (s32 i = 0; i < count; i++) { VisGroup* grp = new VisGroup(); grp->load(pReader); visgroups.push_back(grp); } } //lightmaps { const s32 count = pReader->readLong(); #ifdef _IRR_DEBUG_CSM_LOADER_ os::Printer::log("Loading lightmaps. Count", core::stringc(count)); #endif lightmaps.reallocate(count); for(s32 i = 0; i < count; i++) { LightMap* lm = new LightMap(); lm->load(pReader); lightmaps.push_back(lm); } } //meshes { const s32 count = pReader->readLong(); #ifdef _IRR_DEBUG_CSM_LOADER_ os::Printer::log("Loading meshes. Count", core::stringc(count)); #endif meshes.reallocate(count); for(s32 i = 0; i < count; i++) { Mesh* mesh = new Mesh(); mesh->load(pReader,bHasVGroups); meshes.push_back(mesh); } } //entities { const s32 count = pReader->readLong(); #ifdef _IRR_DEBUG_CSM_LOADER_ os::Printer::log("Loading entitites. Count", core::stringc(count)); #endif entities.reallocate(count); for(s32 i = 0; i < count; i++) { Entity* ent = new Entity(); ent->load(pReader); entities.push_back(ent); } } //camera data #ifdef _IRR_DEBUG_CSM_LOADER_ os::Printer::log("Loading camera data."); #endif cameraData.load(pReader); }