Added: #1440 Test for AppData, which works

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent c8f3d2cb9b
commit 49aff3b7d7

@ -237,7 +237,7 @@ const uint8 *CAppData::read(NLMISC::CClassId classId, TSClassId superClassId, ui
if (ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; } if (ChunksOwnsPointers) { nlwarning("Not parsed"); return NULL; }
TKey key(classId, superClassId, subId); TKey key(classId, superClassId, subId);
TMap::const_iterator it = m_Entries.find(key); 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(); size = it->second->value()->Value.size();
return &it->second->value()->Value[0]; 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; } if (ChunksOwnsPointers) { nlwarning("Not parsed"); return; }
TKey key(classId, superClassId, subId); TKey key(classId, superClassId, subId);
TMap::const_iterator it = m_Entries.find(key); 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); m_Entries.erase(key);
} }

@ -54,7 +54,7 @@ class CAppDataEntry;
*/ */
class CAppData : public CStorageContainer class CAppData : public CStorageContainer
{ {
private: public:
struct TKey struct TKey
{ {
TKey(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId); TKey(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId);
@ -95,6 +95,10 @@ public:
/// Erases an appdata chunk. /// Erases an appdata chunk.
void erase(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId); 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: protected:
virtual IStorageObject *createChunkById(uint16 id, bool container); virtual IStorageObject *createChunkById(uint16 id, bool container);

@ -91,6 +91,7 @@ public:
// public data // public data
typedef std::pair<uint16, IStorageObject *> TStorageObjectWithId; typedef std::pair<uint16, IStorageObject *> TStorageObjectWithId;
typedef std::list<TStorageObjectWithId> TStorageObjectContainer; typedef std::list<TStorageObjectWithId> TStorageObjectContainer;
typedef TStorageObjectContainer::iterator TStorageObjectIterator;
TStorageObjectContainer Chunks; TStorageObjectContainer Chunks;
protected: protected:

@ -27,6 +27,9 @@
#include "../max/scene.h" #include "../max/scene.h"
#include "../max/scene_class_registry.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 = "/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/source/minimax/GE_Acc_MikotoBaniere.max";
//static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max"; //static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max";
@ -162,6 +165,32 @@ int main(int argc, char **argv)
//std::cout << "\n"; //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<PIPELINE::MAX::CStorageContainer *>(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<PIPELINE::MAX::CAppData *>(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); GsfInput *input = gsf_infile_child_by_name(infile, streamname);

Loading…
Cancel
Save