Added: #1440 Parse INode

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent f5d2048f7c
commit 15f52ccfac

@ -29,6 +29,7 @@
#include "i_node.h" #include "i_node.h"
// STL includes // STL includes
#include <iomanip>
// NeL includes // NeL includes
// #include <nel/misc/debug.h> // #include <nel/misc/debug.h>
@ -99,7 +100,33 @@ const ISceneClassDesc *INode::classDesc() const
void INode::toStringLocal(std::ostream &ostream, const std::string &pad) const void INode::toStringLocal(std::ostream &ostream, const std::string &pad) const
{ {
CReferenceTarget::toStringLocal(ostream, pad); 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<NLMISC::CRefPtr<INode> >::iterator it = m_Children.begin(), end = m_Children.end(); it != end; ++it)
{
INode *node = (*it);
nlassert(node);
if (node)
{
ostream << "\n" << pad << "\t" << i << ": <ptr=0x";
{
std::stringstream ss;
ss << std::hex << std::setfill('0');
ss << std::setw(16) << (uint64)(void *)node;
ostream << ss.str();
}
ostream << "> ";
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() INode *INode::parent()
@ -123,6 +150,12 @@ void INode::removeChild(INode *node)
m_Children.erase(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) IStorageObject *INode::createChunkById(uint16 id, bool container)
{ {
return CReferenceTarget::createChunkById(id, container); return CReferenceTarget::createChunkById(id, container);

@ -74,15 +74,16 @@ public:
virtual void setParent(INode *node); virtual void setParent(INode *node);
virtual void addChild(INode *node); virtual void addChild(INode *node);
virtual void removeChild(INode *node); // does not delete 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 /// The children that are linked to this node by the parent tag
inline const std::set<INode *> &children() const { return m_Children; } inline const std::set<NLMISC::CRefPtr<INode> > &children() const { return m_Children; }
protected: protected:
// inherited // inherited
virtual IStorageObject *createChunkById(uint16 id, bool container); virtual IStorageObject *createChunkById(uint16 id, bool container);
protected: protected:
std::set<INode *> m_Children; std::set<NLMISC::CRefPtr<INode> > m_Children;
}; /* class INode */ }; /* class INode */

@ -29,6 +29,7 @@
#include "node_impl.h" #include "node_impl.h"
// STL includes // STL includes
#include <iomanip>
// NeL includes // NeL includes
// #include <nel/misc/debug.h> // #include <nel/misc/debug.h>
@ -42,7 +43,11 @@ namespace PIPELINE {
namespace MAX { namespace MAX {
namespace BUILTIN { 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) void CNodeImpl::parse(uint16 version)
{ {
INode::parse(version); INode::parse(version);
if (!m_ChunksOwnsPointers)
{
CStorageValue<uint32> *nodeVersion = static_cast<CStorageValue<uint32> *>(getChunk(PMB_NODE_VERSION_CHUNK_ID));
nlassert(nodeVersion);
m_NodeVersion = nodeVersion->Value;
m_ArchivedChunks.push_back(nodeVersion);
CStorageArray<uint32> *parent = static_cast<CStorageArray<uint32> *>(getChunk(PMB_NODE_PARENT_CHUNK_ID));
nlassert(parent);
nlassert(parent->Value.size() == 2);
setParent(dynamic_cast<INode *>(container()->getByStorageIndex((sint32)parent->Value[0])));
nlassert(m_Parent);
m_ParentFlags = parent->Value[1];
m_ArchivedChunks.push_back(parent);
CStorageValue<ucstring> *userName = static_cast<CStorageValue<ucstring> *>(getChunk(PMB_NODE_NAME_CHUNK_ID));
nlassert(userName);
m_UserName = userName->Value;
m_ArchivedChunks.push_back(userName);
}
} }
void CNodeImpl::clean() void CNodeImpl::clean()
@ -71,10 +96,32 @@ void CNodeImpl::clean()
void CNodeImpl::build(uint16 version) void CNodeImpl::build(uint16 version)
{ {
INode::build(version); INode::build(version);
CStorageValue<uint32> *nodeVersion = new CStorageValue<uint32>();
nodeVersion->Value = m_NodeVersion;
m_ArchivedChunks.push_back(nodeVersion);
putChunk(PMB_NODE_VERSION_CHUNK_ID, nodeVersion);
CStorageArray<uint32> *parent = new CStorageArray<uint32>();
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<ucstring> *userName = new CStorageValue<ucstring>();
userName->Value = m_UserName;
m_ArchivedChunks.push_back(userName);
putChunk(PMB_NODE_NAME_CHUNK_ID, userName);
} }
void CNodeImpl::disown() void CNodeImpl::disown()
{ {
m_NodeVersion = 0;
setParent(NULL);
m_ParentFlags = 0;
m_UserName = ucstring("Untitled Node");
INode::disown(); INode::disown();
} }
@ -97,10 +144,59 @@ const ISceneClassDesc *CNodeImpl::classDesc() const
void CNodeImpl::toStringLocal(std::ostream &ostream, const std::string &pad) const void CNodeImpl::toStringLocal(std::ostream &ostream, const std::string &pad) const
{ {
INode::toStringLocal(ostream, pad); INode::toStringLocal(ostream, pad);
ostream << "\n" << pad << "NodeVersion: " << m_NodeVersion;
ostream << "\n" << pad << "Parent: ";
INode *parent = m_Parent;
nlassert(parent);
if (parent)
{
ostream << "<ptr=0x";
{
std::stringstream ss;
ss << std::hex << std::setfill('0');
ss << std::setw(16) << (uint64)(void *)parent;
ostream << ss.str();
}
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) IStorageObject *CNodeImpl::createChunkById(uint16 id, bool container)
{ {
switch (id)
{
case PMB_NODE_VERSION_CHUNK_ID:
return new CStorageValue<uint32>();
case PMB_NODE_PARENT_CHUNK_ID:
return new CStorageArray<uint32>();
case PMB_NODE_NAME_CHUNK_ID:
return new CStorageValue<ucstring>();
}
return INode::createChunkById(id, container); return INode::createChunkById(id, container);
} }

@ -68,10 +68,26 @@ public:
virtual const ISceneClassDesc *classDesc() const; virtual const ISceneClassDesc *classDesc() const;
virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") 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: protected:
// inherited // inherited
virtual IStorageObject *createChunkById(uint16 id, bool container); virtual IStorageObject *createChunkById(uint16 id, bool container);
private:
uint32 m_NodeVersion;
NLMISC::CRefPtr<INode> m_Parent;
uint32 m_ParentFlags;
ucstring m_UserName;
}; /* class CNodeImpl */ }; /* class CNodeImpl */
typedef CSceneClassDesc<CNodeImpl> CNodeImplClassDesc; typedef CSceneClassDesc<CNodeImpl> CNodeImplClassDesc;

@ -99,6 +99,12 @@ void CRootNode::toStringLocal(std::ostream &ostream, const std::string &pad) con
INode::toStringLocal(ostream, pad); 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) IStorageObject *CRootNode::createChunkById(uint16 id, bool container)
{ {
return INode::createChunkById(id, container); return INode::createChunkById(id, container);

@ -68,6 +68,9 @@ public:
virtual const ISceneClassDesc *classDesc() const; virtual const ISceneClassDesc *classDesc() const;
virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const;
// node interface
virtual const ucstring &userName() const;
protected: protected:
// inherited // inherited
virtual IStorageObject *createChunkById(uint16 id, bool container); virtual IStorageObject *createChunkById(uint16 id, bool container);

@ -326,7 +326,7 @@ void CClassEntry::toString(std::ostream &ostream, const std::string &pad) const
ostream << "\n" << pad << "Header: "; ostream << "\n" << pad << "Header: ";
m_Header->toString(ostream, padpad); m_Header->toString(ostream, padpad);
ostream << "\n" << pad << "Name: " << m_Name->Value.toUtf8(); ostream << "\n" << pad << "Name: " << m_Name->Value.toUtf8();
ostream << "} "; ostream << " } ";
} }
else else
{ {

@ -31,8 +31,8 @@
#include "../max/builtin/storage/app_data.h" #include "../max/builtin/storage/app_data.h"
#include "../max/builtin/builtin.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 = "/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";
//static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max"; //static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max";
static const char *streamname = "Scene"; static const char *streamname = "Scene";

Loading…
Cancel
Save