From f5d2048f7c479f997734efddb9b81fcc242a6443 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 24 Aug 2012 16:39:19 +0200 Subject: [PATCH] Added: #1440 Extended parser for CTrackViewNode --HG-- branch : build_pipeline_v3 --- .../pipeline/max/builtin/reference_maker.cpp | 38 ++++++++- .../pipeline/max/builtin/reference_maker.h | 4 + .../pipeline/max/builtin/track_view_node.cpp | 85 +++++++++++++++++-- .../pipeline/max/builtin/track_view_node.h | 5 +- code/nel/tools/pipeline/max_dump/main.cpp | 4 +- 5 files changed, 123 insertions(+), 13 deletions(-) diff --git a/code/nel/tools/pipeline/max/builtin/reference_maker.cpp b/code/nel/tools/pipeline/max/builtin/reference_maker.cpp index 965a60c3a..11e834bee 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_maker.cpp +++ b/code/nel/tools/pipeline/max/builtin/reference_maker.cpp @@ -59,12 +59,15 @@ namespace BUILTIN { #define PMB_REFERENCES_2034_CHUNK_ID 0x2034 #define PMB_REFERENCES_2035_CHUNK_ID 0x2035 #define PMB_204B_EQUALS_2E_CHUNK_ID 0x204B +#define PMB_UNKNOWN2045_CHUNK_ID 0x2045 +#define PMB_UNKNOWN2047_CHUNK_ID 0x2047 +#define PMB_UNKNOWN21B0_CHUNK_ID 0x21B0 //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -CReferenceMaker::CReferenceMaker(CScene *scene) : CAnimatable(scene), m_ReferenceMap(false), m_References2035Value0(0) +CReferenceMaker::CReferenceMaker(CScene *scene) : CAnimatable(scene), m_ReferenceMap(false), m_204B_Equals_2E(NULL), m_References2035Value0(0), m_Unknown2045(NULL), m_Unknown2047(NULL), m_Unknown21B0(NULL) { } @@ -75,6 +78,12 @@ CReferenceMaker::~CReferenceMaker() { delete m_204B_Equals_2E; m_204B_Equals_2E = NULL; + delete m_Unknown2045; + m_Unknown2045 = NULL; + delete m_Unknown2047; + m_Unknown2047 = NULL; + delete m_Unknown21B0; + m_Unknown21B0 = NULL; } } @@ -132,6 +141,10 @@ void CReferenceMaker::parse(uint16 version) setReference(index, referenceMaker); } } + + m_Unknown2045 = static_cast(getChunk(PMB_UNKNOWN2045_CHUNK_ID)); // not sure if this is part of maker or target + m_Unknown2047 = static_cast(getChunk(PMB_UNKNOWN2047_CHUNK_ID)); // not sure if this is part of maker or target + m_Unknown21B0 = static_cast(getChunk(PMB_UNKNOWN21B0_CHUNK_ID)); // not sure if this is part of maker or target } } @@ -178,6 +191,9 @@ void CReferenceMaker::build(uint16 version) m_ArchivedChunks.push_back(references2035); } if (m_204B_Equals_2E) putChunk(PMB_204B_EQUALS_2E_CHUNK_ID, m_204B_Equals_2E); + if (m_Unknown2045) putChunk(PMB_UNKNOWN2045_CHUNK_ID, m_Unknown2045); + if (m_Unknown2047) putChunk(PMB_UNKNOWN2047_CHUNK_ID, m_Unknown2047); + if (m_Unknown21B0) putChunk(PMB_UNKNOWN21B0_CHUNK_ID, m_Unknown21B0); } void CReferenceMaker::disown() @@ -186,6 +202,9 @@ void CReferenceMaker::disown() m_ReferenceMap = false; m_References2035Value0 = 0; m_204B_Equals_2E = NULL; + m_Unknown2045 = NULL; + m_Unknown2047 = NULL; + m_Unknown21B0 = NULL; CAnimatable::disown(); } @@ -240,6 +259,21 @@ void CReferenceMaker::toStringLocal(std::ostream &ostream, const std::string &pa ostream << "\n" << pad << "0x204B Equals 0x2E (46): "; m_204B_Equals_2E->toString(ostream, pad + "\t"); } + if (m_Unknown2045) + { + ostream << "\n" << pad << "Unknown 0x2045: "; + m_Unknown2045->toString(ostream, pad + "\t"); + } + if (m_Unknown2047) + { + ostream << "\n" << pad << "Unknown 0x2047: "; + m_Unknown2047->toString(ostream, pad + "\t"); + } + if (m_Unknown21B0) + { + ostream << "\n" << pad << "Unknown 0x21B0: "; + m_Unknown21B0->toString(ostream, pad + "\t"); + } } CReferenceMaker *CReferenceMaker::getReference(uint index) const @@ -269,6 +303,8 @@ IStorageObject *CReferenceMaker::createChunkById(uint16 id, bool container) return new CStorageArray(); case PMB_204B_EQUALS_2E_CHUNK_ID: return new CStorageValue(); + case PMB_UNKNOWN21B0_CHUNK_ID: + return new CStorageRaw(); } return CAnimatable::createChunkById(id, container); } diff --git a/code/nel/tools/pipeline/max/builtin/reference_maker.h b/code/nel/tools/pipeline/max/builtin/reference_maker.h index 5dad15167..de934cf90 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_maker.h +++ b/code/nel/tools/pipeline/max/builtin/reference_maker.h @@ -90,6 +90,10 @@ private: /// Unknown value uint32 m_References2035Value0; + CStorageRaw *m_Unknown2045; + CStorageRaw *m_Unknown2047; + CStorageRaw *m_Unknown21B0; + }; /* class CReferenceMaker */ typedef CSceneClassDesc CReferenceMakerClassDesc; diff --git a/code/nel/tools/pipeline/max/builtin/track_view_node.cpp b/code/nel/tools/pipeline/max/builtin/track_view_node.cpp index ca1c5a99f..b0d431b8b 100644 --- a/code/nel/tools/pipeline/max/builtin/track_view_node.cpp +++ b/code/nel/tools/pipeline/max/builtin/track_view_node.cpp @@ -29,6 +29,7 @@ #include "track_view_node.h" // STL includes +#include // NeL includes // #include @@ -49,7 +50,7 @@ namespace BUILTIN { #define PMB_TVNODE_IDENTIFIER_CHUNK_ID 0x0120 #define PMB_TVNODE_INTEGER0130_CHUNK_ID 0x0130 /* type? */ -CTrackViewNode::CTrackViewNode(CScene *scene) : CReferenceTarget(scene) +CTrackViewNode::CTrackViewNode(CScene *scene) : CReferenceTarget(scene), m_Empty0140(NULL), m_Empty0150(NULL) { } @@ -68,6 +69,33 @@ const CTrackViewNodeClassDesc TrackViewNodeClassDesc(&DllPluginDescBuiltin); void CTrackViewNode::parse(uint16 version) { CReferenceTarget::parse(version); + if (!m_ChunksOwnsPointers) + { + // Read unknown chunks + m_Empty0140 = static_cast(getChunk(PMB_TVNODE_EMPTY0140_CHUNK_ID)); + if (m_Empty0140) nlassert(m_Empty0140->Value.empty()); + m_Empty0150 = static_cast(getChunk(PMB_TVNODE_EMPTY0150_CHUNK_ID)); + if (m_Empty0150) nlassert(m_Empty0140->Value.empty()); + + // Read child nodes + for (std::vector::size_type i = 0; i < m_Children.size(); ++i) + { + CStorageValue *displayName = static_cast *>(getChunk(PMB_TVNODE_DISPLAYNAME_CHUNK_ID)); + nlassert(displayName); + m_ArchivedChunks.push_back(displayName); + m_Children[i].DisplayName = displayName->Value; + + CStorageValue *identifier = static_cast *>(getChunk(PMB_TVNODE_IDENTIFIER_CHUNK_ID)); + nlassert(identifier); + m_ArchivedChunks.push_back(identifier); + m_Children[i].Identifier = identifier->Value; + + CStorageValue *integer0130 = static_cast *>(getChunk(PMB_TVNODE_INTEGER0130_CHUNK_ID)); + nlassert(integer0130); + m_ArchivedChunks.push_back(integer0130); + m_Children[i].Integer0130 = integer0130->Value; + } + } } void CTrackViewNode::clean() @@ -78,6 +106,29 @@ void CTrackViewNode::clean() void CTrackViewNode::build(uint16 version) { CReferenceTarget::build(version); + + // Write unknown chunks + if (m_Empty0140) putChunk(PMB_TVNODE_EMPTY0140_CHUNK_ID, m_Empty0140); + if (m_Empty0150) putChunk(PMB_TVNODE_EMPTY0150_CHUNK_ID, m_Empty0150); + + // Write child nodes + for (std::vector::size_type i = 0; i < m_Children.size(); ++i) + { + CStorageValue *displayName = new CStorageValue(); + displayName->Value = m_Children[i].DisplayName; + m_ArchivedChunks.push_back(displayName); + putChunk(PMB_TVNODE_DISPLAYNAME_CHUNK_ID, displayName); + + CStorageValue *identifier = new CStorageValue(); + identifier->Value = m_Children[i].Identifier; + m_ArchivedChunks.push_back(identifier); + putChunk(PMB_TVNODE_IDENTIFIER_CHUNK_ID, identifier); + + CStorageValue *integer0130 = new CStorageValue(); + integer0130->Value = m_Children[i].Integer0130; + m_ArchivedChunks.push_back(integer0130); + putChunk(PMB_TVNODE_INTEGER0130_CHUNK_ID, integer0130); + } } void CTrackViewNode::disown() @@ -104,25 +155,43 @@ const ISceneClassDesc *CTrackViewNode::classDesc() const void CTrackViewNode::toStringLocal(std::ostream &ostream, const std::string &pad) const { CReferenceTarget::toStringLocal(ostream, pad); + if (m_Empty0140) ostream << "\n" << pad << "Empty 0x0140 "; + if (m_Empty0150) ostream << "\n" << pad << "Empty 0x0150 "; + // std::string padpad = pad + "\t"; + for (std::vector::size_type i = 0; i < m_Children.size(); ++i) + { + CReferenceMaker *referenceMaker = m_Children[i].Reference; + nlassert(referenceMaker); + ostream << "\n" << pad << i << ": "; + ostream << "(" << ucstring(referenceMaker->classDesc()->displayName()).toUtf8() << ", " << referenceMaker->classDesc()->classId().toString() << ") "; + ostream << "(" << m_Children[i].DisplayName.toUtf8() << ", " << m_Children[i].Identifier.toString() << ", " << m_Children[i].Integer0130 << ") "; + } } -/* + CReferenceMaker *CTrackViewNode::getReference(uint index) const { - if (m_References.size() <= index) return NULL; - return m_References[index]; + if (m_Children.size() <= index) return NULL; + return m_Children[index].Reference; } void CTrackViewNode::setReference(uint index, CReferenceMaker *reference) { - if (m_References.size() <= index) m_References.resize(index + 1); - m_References[index] = reference; + if (m_Children.size() <= index) m_Children.resize(index + 1); + m_Children[index].Reference = reference; } uint CTrackViewNode::nbReferences() const { - return m_References.size(); + return m_Children.size(); } -*/ + IStorageObject *CTrackViewNode::createChunkById(uint16 id, bool container) { switch (id) diff --git a/code/nel/tools/pipeline/max/builtin/track_view_node.h b/code/nel/tools/pipeline/max/builtin/track_view_node.h index 578a02b27..9300f4af2 100644 --- a/code/nel/tools/pipeline/max/builtin/track_view_node.h +++ b/code/nel/tools/pipeline/max/builtin/track_view_node.h @@ -51,6 +51,7 @@ class CTrackViewNode : public CReferenceTarget public: struct TChild { + TChild() : Integer0130(0) { } NLMISC::CRefPtr Reference; ucstring DisplayName; NLMISC::CClassId Identifier; @@ -77,9 +78,9 @@ public: virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; // reference maker - /*virtual CReferenceMaker *getReference(uint index) const; + virtual CReferenceMaker *getReference(uint index) const; virtual void setReference(uint index, CReferenceMaker *reference); - virtual uint nbReferences() const;*/ + virtual uint nbReferences() const; // read access inline const std::vector &children() const { return m_Children; } diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index e4df139f1..9a4a12e6f 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -31,8 +31,8 @@ #include "../max/builtin/storage/app_data.h" #include "../max/builtin/builtin.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 = "/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"; //static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max"; static const char *streamname = "Scene";