diff --git a/code/nel/tools/pipeline/max/builtin/app_data.cpp b/code/nel/tools/pipeline/max/builtin/app_data.cpp index 931b2c33c..53ee427fd 100644 --- a/code/nel/tools/pipeline/max/builtin/app_data.cpp +++ b/code/nel/tools/pipeline/max/builtin/app_data.cpp @@ -237,7 +237,7 @@ const uint8 *CAppData::read(NLMISC::CClassId classId, TSClassId superClassId, ui if (ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; } TKey key(classId, superClassId, subId); TMap::const_iterator it = m_Entries.find(key); - if (it == m_Entries.end()) { return NULL; } + if (it == m_Entries.end()) { nldebug("Trying to read non-existant key, this is allowed, returning NULL"); return NULL; } size = it->second->value()->Value.size(); return &it->second->value()->Value[0]; } @@ -291,7 +291,7 @@ void CAppData::erase(NLMISC::CClassId classId, TSClassId superClassId, uint32 su if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; } TKey key(classId, superClassId, subId); TMap::const_iterator it = m_Entries.find(key); - if (it == m_Entries.end()) { nldebug("Erasing non-existant key, this is allowed, doing nothing"); return; } + if (it == m_Entries.end()) { nldebug("Trying to erase non-existant key, this is allowed, doing nothing"); return; } m_Entries.erase(key); } diff --git a/code/nel/tools/pipeline/max/builtin/app_data.h b/code/nel/tools/pipeline/max/builtin/app_data.h index a1caace9d..6b4a48664 100644 --- a/code/nel/tools/pipeline/max/builtin/app_data.h +++ b/code/nel/tools/pipeline/max/builtin/app_data.h @@ -54,7 +54,7 @@ class CAppDataEntry; */ class CAppData : public CStorageContainer { -private: +public: struct TKey { TKey(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId); @@ -95,6 +95,10 @@ public: /// Erases an appdata chunk. void erase(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId); + // read access + /// Return the entries map, do not modify directly + inline const TMap &entries() const { return m_Entries; } + protected: virtual IStorageObject *createChunkById(uint16 id, bool container); diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index 4363b20da..e14b886c4 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -91,6 +91,7 @@ public: // public data typedef std::pair TStorageObjectWithId; typedef std::list TStorageObjectContainer; + typedef TStorageObjectContainer::iterator TStorageObjectIterator; TStorageObjectContainer Chunks; protected: diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 9c874106e..1ab6a3b05 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -27,6 +27,9 @@ #include "../max/scene.h" #include "../max/scene_class_registry.h" +// Testing +#include "../max/builtin/app_data.h" + //static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max"; static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max"; //static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max"; @@ -162,6 +165,32 @@ int main(int argc, char **argv) //std::cout << "\n"; + // TEST APP DATA + +#define MAXSCRIPT_UTILITY_CLASS_ID (NLMISC::CClassId(0x04d64858, 0x16d1751d)) +#define UTILITY_CLASS_ID (4128) +#define NEL3D_APPDATA_ENV_FX (84682543) + + PIPELINE::MAX::CSceneClassContainer *ssc = scene.container(); + for (PIPELINE::MAX::CStorageContainer::TStorageObjectIterator it = ssc->Chunks.begin(), end = ssc->Chunks.end(); it != end; ++it) + { + PIPELINE::MAX::CStorageContainer *subc = static_cast(it->second); + for (PIPELINE::MAX::CStorageContainer::TStorageObjectIterator subit = subc->Chunks.begin(), subend = subc->Chunks.end(); subit != subend; ++subit) + { + PIPELINE::MAX::IStorageObject *storageChunk = subit->second; + PIPELINE::MAX::CAppData *appData = dynamic_cast(storageChunk); + if (appData) + { + nlinfo("Found AppData"); + uint32 size; + const uint8 *buffer = appData->read(MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_ENV_FX, size); + if (buffer) + { + nlinfo("Found NEL3D_APPDATA_ENV_FX, size %i", size); + } + } + } + } /* GsfInput *input = gsf_infile_child_by_name(infile, streamname);