From 15f52ccface6c7495986afb0780dcfe28f152323 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 24 Aug 2012 17:57:34 +0200 Subject: [PATCH] Added: #1440 Parse INode --HG-- branch : build_pipeline_v3 --- .../nel/tools/pipeline/max/builtin/i_node.cpp | 35 ++++++- code/nel/tools/pipeline/max/builtin/i_node.h | 5 +- .../tools/pipeline/max/builtin/node_impl.cpp | 98 ++++++++++++++++++- .../tools/pipeline/max/builtin/node_impl.h | 16 +++ .../tools/pipeline/max/builtin/root_node.cpp | 6 ++ .../tools/pipeline/max/builtin/root_node.h | 3 + .../tools/pipeline/max/class_directory_3.cpp | 2 +- code/nel/tools/pipeline/max_dump/main.cpp | 4 +- 8 files changed, 162 insertions(+), 7 deletions(-) diff --git a/code/nel/tools/pipeline/max/builtin/i_node.cpp b/code/nel/tools/pipeline/max/builtin/i_node.cpp index c0ef7c9c1..87f8a4b13 100644 --- a/code/nel/tools/pipeline/max/builtin/i_node.cpp +++ b/code/nel/tools/pipeline/max/builtin/i_node.cpp @@ -29,6 +29,7 @@ #include "i_node.h" // STL includes +#include // NeL includes // #include @@ -99,7 +100,33 @@ const ISceneClassDesc *INode::classDesc() const void INode::toStringLocal(std::ostream &ostream, const std::string &pad) const { CReferenceTarget::toStringLocal(ostream, pad); - // Children: IMPLICIT { } - print the implied connected children + // Print the implied connected children + ostream << "\n" << pad << "Children: IMPLICIT { "; + uint i = 0; + for (std::set >::iterator it = m_Children.begin(), end = m_Children.end(); it != end; ++it) + { + INode *node = (*it); + nlassert(node); + if (node) + { + ostream << "\n" << pad << "\t" << i << ": "; + ostream << "(" << ucstring(node->classDesc()->displayName()).toUtf8() << ", " << node->classDesc()->classId().toString() << ") "; + ostream << node->userName().toUtf8() << " "; + } + else + { + ostream << "\n" << pad << "\t" << i << ": NULL "; + } + ++i; + } + ostream << "} "; } INode *INode::parent() @@ -123,6 +150,12 @@ void INode::removeChild(INode *node) m_Children.erase(node); } +const ucstring &INode::userName() const +{ + static const ucstring v = ucstring("Invalid INode"); + return v; +} + IStorageObject *INode::createChunkById(uint16 id, bool container) { return CReferenceTarget::createChunkById(id, container); diff --git a/code/nel/tools/pipeline/max/builtin/i_node.h b/code/nel/tools/pipeline/max/builtin/i_node.h index 696b40d44..1688f312a 100644 --- a/code/nel/tools/pipeline/max/builtin/i_node.h +++ b/code/nel/tools/pipeline/max/builtin/i_node.h @@ -74,15 +74,16 @@ public: virtual void setParent(INode *node); virtual void addChild(INode *node); virtual void removeChild(INode *node); // does not delete + virtual const ucstring &userName() const; /// The children that are linked to this node by the parent tag - inline const std::set &children() const { return m_Children; } + inline const std::set > &children() const { return m_Children; } protected: // inherited virtual IStorageObject *createChunkById(uint16 id, bool container); protected: - std::set m_Children; + std::set > m_Children; }; /* class INode */ diff --git a/code/nel/tools/pipeline/max/builtin/node_impl.cpp b/code/nel/tools/pipeline/max/builtin/node_impl.cpp index 8ab93fa84..a23024809 100644 --- a/code/nel/tools/pipeline/max/builtin/node_impl.cpp +++ b/code/nel/tools/pipeline/max/builtin/node_impl.cpp @@ -29,6 +29,7 @@ #include "node_impl.h" // STL includes +#include // NeL includes // #include @@ -42,7 +43,11 @@ namespace PIPELINE { namespace MAX { namespace BUILTIN { -CNodeImpl::CNodeImpl(CScene *scene) : INode(scene) +#define PMB_NODE_VERSION_CHUNK_ID 0x09ce +#define PMB_NODE_PARENT_CHUNK_ID 0x0960 +#define PMB_NODE_NAME_CHUNK_ID 0x0962 + +CNodeImpl::CNodeImpl(CScene *scene) : INode(scene), m_NodeVersion(0), m_ParentFlags(0), m_UserName(ucstring("Untitled Node")) { } @@ -61,6 +66,26 @@ const CNodeImplClassDesc NodeImplClassDesc(&DllPluginDescBuiltin); void CNodeImpl::parse(uint16 version) { INode::parse(version); + if (!m_ChunksOwnsPointers) + { + CStorageValue *nodeVersion = static_cast *>(getChunk(PMB_NODE_VERSION_CHUNK_ID)); + nlassert(nodeVersion); + m_NodeVersion = nodeVersion->Value; + m_ArchivedChunks.push_back(nodeVersion); + + CStorageArray *parent = static_cast *>(getChunk(PMB_NODE_PARENT_CHUNK_ID)); + nlassert(parent); + nlassert(parent->Value.size() == 2); + setParent(dynamic_cast(container()->getByStorageIndex((sint32)parent->Value[0]))); + nlassert(m_Parent); + m_ParentFlags = parent->Value[1]; + m_ArchivedChunks.push_back(parent); + + CStorageValue *userName = static_cast *>(getChunk(PMB_NODE_NAME_CHUNK_ID)); + nlassert(userName); + m_UserName = userName->Value; + m_ArchivedChunks.push_back(userName); + } } void CNodeImpl::clean() @@ -71,10 +96,32 @@ void CNodeImpl::clean() void CNodeImpl::build(uint16 version) { INode::build(version); + + CStorageValue *nodeVersion = new CStorageValue(); + nodeVersion->Value = m_NodeVersion; + m_ArchivedChunks.push_back(nodeVersion); + putChunk(PMB_NODE_VERSION_CHUNK_ID, nodeVersion); + + CStorageArray *parent = new CStorageArray(); + parent->Value.resize(2); + parent->Value[0] = container()->getOrCreateStorageIndex(m_Parent); + parent->Value[1] = m_ParentFlags; + m_ArchivedChunks.push_back(parent); + putChunk(PMB_NODE_PARENT_CHUNK_ID, parent); + + CStorageValue *userName = new CStorageValue(); + userName->Value = m_UserName; + m_ArchivedChunks.push_back(userName); + putChunk(PMB_NODE_NAME_CHUNK_ID, userName); } void CNodeImpl::disown() { + m_NodeVersion = 0; + setParent(NULL); + m_ParentFlags = 0; + m_UserName = ucstring("Untitled Node"); + INode::disown(); } @@ -97,10 +144,59 @@ const ISceneClassDesc *CNodeImpl::classDesc() const void CNodeImpl::toStringLocal(std::ostream &ostream, const std::string &pad) const { INode::toStringLocal(ostream, pad); + ostream << "\n" << pad << "NodeVersion: " << m_NodeVersion; + ostream << "\n" << pad << "Parent: "; + INode *parent = m_Parent; + nlassert(parent); + if (parent) + { + ostream << " "; + ostream << "(" << ucstring(parent->classDesc()->displayName()).toUtf8() << ", " << parent->classDesc()->classId().toString() << ") "; + ostream << parent->userName().toUtf8(); + } + else + { + ostream << "NULL"; + } + ostream << "\n" << pad << "ParentFlags: " << m_ParentFlags; + ostream << "\n" << pad << "UserName: " << m_UserName.toUtf8() << " "; +} + +INode *CNodeImpl::parent() +{ + return m_Parent; +} + +void CNodeImpl::setParent(INode *node) +{ + if (m_Parent) m_Parent->removeChild(this); + m_Parent = node; + if (node) node->addChild(this); +} + +const ucstring &CNodeImpl::userName() const +{ + return m_UserName; } IStorageObject *CNodeImpl::createChunkById(uint16 id, bool container) { + switch (id) + { + case PMB_NODE_VERSION_CHUNK_ID: + return new CStorageValue(); + case PMB_NODE_PARENT_CHUNK_ID: + return new CStorageArray(); + case PMB_NODE_NAME_CHUNK_ID: + return new CStorageValue(); + } return INode::createChunkById(id, container); } diff --git a/code/nel/tools/pipeline/max/builtin/node_impl.h b/code/nel/tools/pipeline/max/builtin/node_impl.h index e81dba57d..81b696a88 100644 --- a/code/nel/tools/pipeline/max/builtin/node_impl.h +++ b/code/nel/tools/pipeline/max/builtin/node_impl.h @@ -68,10 +68,26 @@ public: virtual const ISceneClassDesc *classDesc() const; virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; + // node interface + virtual INode *parent(); + virtual void setParent(INode *node); + // virtual void addChild(INode *node); + // virtual void removeChild(INode *node); // does not delete + virtual const ucstring &userName() const; + + // read access + inline uint32 nodeVersion() const { return m_NodeVersion; } + protected: // inherited virtual IStorageObject *createChunkById(uint16 id, bool container); +private: + uint32 m_NodeVersion; + NLMISC::CRefPtr m_Parent; + uint32 m_ParentFlags; + ucstring m_UserName; + }; /* class CNodeImpl */ typedef CSceneClassDesc CNodeImplClassDesc; diff --git a/code/nel/tools/pipeline/max/builtin/root_node.cpp b/code/nel/tools/pipeline/max/builtin/root_node.cpp index bbb972f8d..ba3292b1e 100644 --- a/code/nel/tools/pipeline/max/builtin/root_node.cpp +++ b/code/nel/tools/pipeline/max/builtin/root_node.cpp @@ -99,6 +99,12 @@ void CRootNode::toStringLocal(std::ostream &ostream, const std::string &pad) con INode::toStringLocal(ostream, pad); } +const ucstring &CRootNode::userName() const +{ + static const ucstring v = ucstring("Root Node"); + return v; +} + IStorageObject *CRootNode::createChunkById(uint16 id, bool container) { return INode::createChunkById(id, container); diff --git a/code/nel/tools/pipeline/max/builtin/root_node.h b/code/nel/tools/pipeline/max/builtin/root_node.h index c3f9ac030..ba37b9a7f 100644 --- a/code/nel/tools/pipeline/max/builtin/root_node.h +++ b/code/nel/tools/pipeline/max/builtin/root_node.h @@ -68,6 +68,9 @@ public: virtual const ISceneClassDesc *classDesc() const; virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; + // node interface + virtual const ucstring &userName() const; + protected: // inherited virtual IStorageObject *createChunkById(uint16 id, bool container); diff --git a/code/nel/tools/pipeline/max/class_directory_3.cpp b/code/nel/tools/pipeline/max/class_directory_3.cpp index 8507e8065..e23989d7f 100644 --- a/code/nel/tools/pipeline/max/class_directory_3.cpp +++ b/code/nel/tools/pipeline/max/class_directory_3.cpp @@ -326,7 +326,7 @@ void CClassEntry::toString(std::ostream &ostream, const std::string &pad) const ostream << "\n" << pad << "Header: "; m_Header->toString(ostream, padpad); ostream << "\n" << pad << "Name: " << m_Name->Value.toUtf8(); - ostream << "} "; + ostream << " } "; } else { diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 9a4a12e6f..e4df139f1 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";