From 45cca62041fccd91026c96825effc86e66646116 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 28 Aug 2012 16:10:10 +0200 Subject: [PATCH] Changed: #1440 Also make it work with certain irregular format differences --HG-- branch : build_pipeline_v3 --- .../nel/tools/pipeline/max/storage_object.cpp | 7 +++++ code/nel/tools/pipeline/max/storage_object.h | 3 ++ .../pipeline/max_rewrite_assets/main.cpp | 31 +++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/pipeline/max/storage_object.cpp b/code/nel/tools/pipeline/max/storage_object.cpp index 7a8eb1834..c580caab4 100644 --- a/code/nel/tools/pipeline/max/storage_object.cpp +++ b/code/nel/tools/pipeline/max/storage_object.cpp @@ -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 diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index d617fbb1b..e05fb755b 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -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); diff --git a/code/nel/tools/pipeline/max_rewrite_assets/main.cpp b/code/nel/tools/pipeline/max_rewrite_assets/main.cpp index 347db14c4..c5ae9d3cb 100644 --- a/code/nel/tools/pipeline/max_rewrite_assets/main.cpp +++ b/code/nel/tools/pipeline/max_rewrite_assets/main.cpp @@ -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(derivedObject->findStorageObject(0x2500, mapExtenderIndex)); nlassert(derivedData); CStorageContainer *derivedGeom = dynamic_cast(derivedData->findStorageObject(0x2512)); - nlassert(derivedGeom); + if (!derivedGeom) + { + CStorageRaw *derivedGeomRaw = dynamic_cast(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(derivedGeom->findStorageObject(0x03e9)); nlassert(derivedVertices); CStorageRaw *derivedIndices = dynamic_cast(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();