Changed: #1440 Also make it work with certain irregular format differences

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent a26ec41392
commit 45cca62041

@ -141,6 +141,13 @@ void CStorageContainer::serial(NLMISC::IStream &stream)
}
}
void CStorageContainer::serial(NLMISC::IStream &stream, uint size)
{
CStorageChunks chunks(stream, size);
serial(chunks);
return;
}
void CStorageContainer::toString(std::ostream &ostream, const std::string &pad) const
{
// note: only use pad when multi-lining

@ -110,6 +110,9 @@ public:
virtual void serial(NLMISC::IStream &stream); // only used to wrap a container inside another stream
virtual void toString(std::ostream &ostream, const std::string &pad = "") const;
// utility
void serial(NLMISC::IStream &stream, uint size); // without wrapping, known size
// virtual
// Parse this class with given version and parse level filter
virtual void parse(uint16 version, uint filter = 0);

@ -71,7 +71,7 @@ bool ReplacePaths = true;
bool ReplaceMapExt = true;
bool WriteModified = true;
bool WriteDummy = true;
bool WriteDummy = false;
bool HaltOnIssue = false;
@ -1068,10 +1068,33 @@ void handleFile(const std::string &path)
mapExtenderIndex = i;
mapExtender = derivedObject->getReference(i);
bool deleteDerivedGeom = false;
CStorageContainer *derivedData = dynamic_cast<CStorageContainer *>(derivedObject->findStorageObject(0x2500, mapExtenderIndex));
nlassert(derivedData);
CStorageContainer *derivedGeom = dynamic_cast<CStorageContainer *>(derivedData->findStorageObject(0x2512));
nlassert(derivedGeom);
if (!derivedGeom)
{
CStorageRaw *derivedGeomRaw = dynamic_cast<CStorageRaw *>(derivedData->findStorageObject(0x2512));
if (derivedGeomRaw)
{
nlwarning("Derived geometry raw instead of as container");
NLMISC::CMemStream memGeom;
derivedGeomRaw->serial(memGeom);
uint size = memGeom.getPos();
memGeom.invert();
derivedGeom = new CStorageContainer();
deleteDerivedGeom = true;
derivedGeom->serial(memGeom, size);
}
else
{
derivedData->toString(std::cout);
nlwarning("derived geometry missing!!!");
std::string x;
std::cin >> x;
continue;
}
}
CStorageRaw *derivedVertices = dynamic_cast<CStorageRaw *>(derivedGeom->findStorageObject(0x03e9));
nlassert(derivedVertices);
CStorageRaw *derivedIndices = dynamic_cast<CStorageRaw *>(derivedGeom->findStorageObject(0x03eb));
@ -1127,6 +1150,9 @@ void handleFile(const std::string &path)
chunkGeomPoints->serial(memGeomPoints);
mapChunks.push_back(CStorageContainer::TStorageObjectWithId(0x0330, chunkGeomPoints));
if (deleteDerivedGeom)
delete derivedGeom;
// /*break;*/
nldebug("Converted!");
}
@ -1373,6 +1399,7 @@ int main(int argc, char **argv)
//handleFile(nativeDatabasePath("w:\\database\\stuff\\generique\\agents\\accessories\\ge_zo_wea_trib_masse1m.max"));
//handleFile(nativeDatabasePath("w:\\database\\stuff\\generique\\agents\\accessories\\ge_fy_wea_trib_grand_bouclier.max"));
//handleFile(nativeDatabasePath("w:\\database\\stuff\\generique\\agents\\accessories\\ge_mission_entrepot.max"));
//handleFile(nativeDatabasePath("w:\\database\\stuff\\generique\\agents\\accessories\\mesh_wip\\all_trib_weapons.max"));
//handleFile("/home/kaetemi/3dsMax/scenes/test_clear_add_uvw.max");
//runScanner();

Loading…
Cancel
Save