From 6e8e6ab86a40d0723e9bd67ae6836fc87d4c3094 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 25 Aug 2012 10:51:19 +0200 Subject: [PATCH] Added: #1440 Basic export of a TriObject to obj --HG-- branch : build_pipeline_v3 --- .../pipeline/max/builtin/base_object.cpp | 54 +++++++ .../tools/pipeline/max/builtin/base_object.h | 26 ++++ .../tools/pipeline/max/builtin/builtin.cpp | 29 +++- .../pipeline/max/builtin/geom_object.cpp | 70 ++++++++- .../tools/pipeline/max/builtin/geom_object.h | 46 ++++-- .../nel/tools/pipeline/max/builtin/i_node.cpp | 13 ++ code/nel/tools/pipeline/max/builtin/i_node.h | 1 + .../nel/tools/pipeline/max/builtin/object.cpp | 54 +++++++ code/nel/tools/pipeline/max/builtin/object.h | 26 ++++ .../pipeline/max/builtin/storage/app_data.h | 2 +- .../max/builtin/storage/geom_buffers.cpp | 144 ++++++++++++++++++ .../max/builtin/storage/geom_buffers.h | 76 +++++++++ code/nel/tools/pipeline/max/storage_array.h | 3 +- .../nel/tools/pipeline/max/storage_object.cpp | 10 ++ code/nel/tools/pipeline/max/storage_object.h | 1 + code/nel/tools/pipeline/max_dump/main.cpp | 31 +++- 16 files changed, 557 insertions(+), 29 deletions(-) create mode 100644 code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp create mode 100644 code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h diff --git a/code/nel/tools/pipeline/max/builtin/base_object.cpp b/code/nel/tools/pipeline/max/builtin/base_object.cpp index 34f03479c..a86fcb097 100644 --- a/code/nel/tools/pipeline/max/builtin/base_object.cpp +++ b/code/nel/tools/pipeline/max/builtin/base_object.cpp @@ -52,6 +52,60 @@ CBaseObject::~CBaseObject() } +const ucstring CBaseObject::DisplayName = ucstring("BaseObject"); +const char *CBaseObject::InternalName = "BaseObject"; +// const char *CBaseObject::InternalNameUnknown = "BaseObjectUnknown"; +const NLMISC::CClassId CBaseObject::ClassId = NLMISC::CClassId(0x71c8167a, 0x5a9f57b2); /* Not official, please correct */ +const TSClassId CBaseObject::SuperClassId = CReferenceTarget::SuperClassId; +const CBaseObjectClassDesc BaseObjectClassDesc(&DllPluginDescBuiltin); +// const CBaseObjectSuperClassDesc BaseObjectSuperClassDesc(&BaseObjectClassDesc); + +void CBaseObject::parse(uint16 version) +{ + CReferenceTarget::parse(version); +} + +void CBaseObject::clean() +{ + CReferenceTarget::clean(); +} + +void CBaseObject::build(uint16 version) +{ + CReferenceTarget::build(version); +} + +void CBaseObject::disown() +{ + CReferenceTarget::disown(); +} + +void CBaseObject::init() +{ + CReferenceTarget::init(); +} + +bool CBaseObject::inherits(const NLMISC::CClassId classId) const +{ + if (classId == classDesc()->classId()) return true; + return CReferenceTarget::inherits(classId); +} + +const ISceneClassDesc *CBaseObject::classDesc() const +{ + return &BaseObjectClassDesc; +} + +void CBaseObject::toStringLocal(std::ostream &ostream, const std::string &pad) const +{ + CReferenceTarget::toStringLocal(ostream, pad); +} + +IStorageObject *CBaseObject::createChunkById(uint16 id, bool container) +{ + return CReferenceTarget::createChunkById(id, container); +} + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/base_object.h b/code/nel/tools/pipeline/max/builtin/base_object.h index f959642ec..6e60873eb 100644 --- a/code/nel/tools/pipeline/max/builtin/base_object.h +++ b/code/nel/tools/pipeline/max/builtin/base_object.h @@ -52,8 +52,34 @@ public: CBaseObject(CScene *scene); virtual ~CBaseObject(); + // class desc + static const ucstring DisplayName; + static const char *InternalName; + // static const char *InternalNameUnknown; + static const NLMISC::CClassId ClassId; + static const TSClassId SuperClassId; + + // inherited + virtual void parse(uint16 version); + virtual void clean(); + virtual void build(uint16 version); + virtual void disown(); + virtual void init(); + virtual bool inherits(const NLMISC::CClassId classId) const; + virtual const ISceneClassDesc *classDesc() const; + virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; + +protected: + // inherited + virtual IStorageObject *createChunkById(uint16 id, bool container); + }; /* class CBaseObject */ +typedef CSceneClassDesc CBaseObjectClassDesc; +extern const CBaseObjectClassDesc BaseObjectClassDesc; +// typedef CSuperClassDesc CBaseObjectSuperClassDesc; +// extern const CBaseObjectSuperClassDesc BaseObjectSuperClassDesc; + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/builtin.cpp b/code/nel/tools/pipeline/max/builtin/builtin.cpp index c23b1a41c..6c2f25264 100644 --- a/code/nel/tools/pipeline/max/builtin/builtin.cpp +++ b/code/nel/tools/pipeline/max/builtin/builtin.cpp @@ -48,6 +48,10 @@ #include "track_view_node.h" +#include "base_object.h" +#include "object.h" +#include "geom_object.h" + // using namespace std; // using namespace NLMISC; @@ -132,19 +136,19 @@ const COSModifierSuperClassDesc OSModifierSuperClassDesc(&ReferenceTargetClassDe // 0x9010 - master point controller typedef CSuperClassDescUnknown CMasterPointControllerSuperClassDesc; const CMasterPointControllerSuperClassDesc MasterPointControllerSuperClassDesc(&ReferenceTargetClassDesc, "MasterPointControllerSuperClassUnknown"); - +/* // 0x10 - geom object typedef CSuperClassDescUnknown CGeomObjectSuperClassDesc; const CGeomObjectSuperClassDesc GeomObjectSuperClassDesc(&ReferenceTargetClassDesc, "GeomObjectSuperClassUnknown"); - +*/ // 0x10f0 - layer, under reftarget directly typedef CSuperClassDescUnknown CLayerSuperClassDesc; const CLayerSuperClassDesc LayerSuperClassDesc(&ReferenceTargetClassDesc, "LayerSuperClassUnknown"); - +/* // 0x60 - object???, under base object typedef CSuperClassDescUnknown CObjectSuperClassDesc; const CObjectSuperClassDesc ObjectSuperClassDesc(&ReferenceTargetClassDesc, "ObjectSuperClassUnknown"); - +*/ // 0x50 helperobject, under object... typedef CSuperClassDescUnknown CHelperObjectSuperClassDesc; const CHelperObjectSuperClassDesc HelperObjectSuperClassDesc(&ReferenceTargetClassDesc, "HelperObjectSuperClassUnknown"); @@ -228,8 +232,8 @@ void CBuiltin::registerClasses(CSceneClassRegistry *registry) // node (inh ReferenceTarget) registry->add(&NodeSuperClassDesc); + registry->add(&NodeClassDesc); { - registry->add(&NodeClassDesc); registry->add(&NodeImplClassDesc); registry->add(&RootNodeClassDesc); } @@ -237,6 +241,17 @@ void CBuiltin::registerClasses(CSceneClassRegistry *registry) // tvnode (inh ReferenceTarget) registry->add(&TrackViewNodeClassDesc); + // object (inh ReferenceMaker) + registry->add(&BaseObjectClassDesc); + { + registry->add(&ObjectSuperClassDesc); + registry->add(&ObjectClassDesc); + { + registry->add(&GeomObjectSuperClassDesc); + registry->add(&GeomObjectClassDesc); + } + } + // unimplemented registry->add(&ControlFloatSuperClassDesc); registry->add(&ParamBlockSuperClassDesc); @@ -256,9 +271,9 @@ void CBuiltin::registerClasses(CSceneClassRegistry *registry) registry->add(&ControlTransformSuperClassDesc); registry->add(&OSModifierSuperClassDesc); registry->add(&MasterPointControllerSuperClassDesc); - registry->add(&GeomObjectSuperClassDesc); + //registry->add(&GeomObjectSuperClassDesc); registry->add(&LayerSuperClassDesc); - registry->add(&ObjectSuperClassDesc); + //registry->add(&ObjectSuperClassDesc); registry->add(&HelperObjectSuperClassDesc); registry->add(&FilterKernelSuperClassDesc); registry->add(&RendererSuperClassDesc); diff --git a/code/nel/tools/pipeline/max/builtin/geom_object.cpp b/code/nel/tools/pipeline/max/builtin/geom_object.cpp index 1c1ccdaca..1df0d31d7 100644 --- a/code/nel/tools/pipeline/max/builtin/geom_object.cpp +++ b/code/nel/tools/pipeline/max/builtin/geom_object.cpp @@ -1,9 +1,9 @@ /** * \file geom_object.cpp - * \brief CGeomObject + * \brief CGeomGeomObject * \date 2012-08-22 08:58GMT * \author Jan Boon (Kaetemi) - * CGeomObject + * CGeomGeomObject */ /* @@ -34,15 +34,18 @@ // #include // Project includes +#include "storage/geom_buffers.h" -using namespace std; +// using namespace std; // using namespace NLMISC; namespace PIPELINE { namespace MAX { namespace BUILTIN { -CGeomObject::CGeomObject() +#define PMB_GEOM_BUFFERS_CHUNK_ID 0x08fe + +CGeomObject::CGeomObject(CScene *scene) : CObject(scene) { } @@ -52,6 +55,65 @@ CGeomObject::~CGeomObject() } +const ucstring CGeomObject::DisplayName = ucstring("GeomObject"); +const char *CGeomObject::InternalName = "GeomObject"; +const char *CGeomObject::InternalNameUnknown = "GeomObjectUnknown"; +const NLMISC::CClassId CGeomObject::ClassId = NLMISC::CClassId(0x37097c44, 0x38aa3f24); /* Not official, please correct */ +const TSClassId CGeomObject::SuperClassId = 0x00000010; +const CGeomObjectClassDesc GeomObjectClassDesc(&DllPluginDescBuiltin); +const CGeomObjectSuperClassDesc GeomObjectSuperClassDesc(&GeomObjectClassDesc); + +void CGeomObject::parse(uint16 version) +{ + CObject::parse(version); +} + +void CGeomObject::clean() +{ + CObject::clean(); +} + +void CGeomObject::build(uint16 version) +{ + CObject::build(version); +} + +void CGeomObject::disown() +{ + CObject::disown(); +} + +void CGeomObject::init() +{ + CObject::init(); +} + +bool CGeomObject::inherits(const NLMISC::CClassId classId) const +{ + if (classId == classDesc()->classId()) return true; + return CObject::inherits(classId); +} + +const ISceneClassDesc *CGeomObject::classDesc() const +{ + return &GeomObjectClassDesc; +} + +void CGeomObject::toStringLocal(std::ostream &ostream, const std::string &pad) const +{ + CObject::toStringLocal(ostream, pad); +} + +IStorageObject *CGeomObject::createChunkById(uint16 id, bool container) +{ + switch (id) + { + case PMB_GEOM_BUFFERS_CHUNK_ID: + return new STORAGE::CGeomBuffers(); + } + return CObject::createChunkById(id, container); +} + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/geom_object.h b/code/nel/tools/pipeline/max/builtin/geom_object.h index 7666f3065..dd85708a2 100644 --- a/code/nel/tools/pipeline/max/builtin/geom_object.h +++ b/code/nel/tools/pipeline/max/builtin/geom_object.h @@ -1,9 +1,9 @@ /** * \file geom_object.h - * \brief CGeomObject + * \brief CGeomGeomObject * \date 2012-08-22 08:58GMT * \author Jan Boon (Kaetemi) - * CGeomObject + * CGeomGeomObject */ /* @@ -34,30 +34,52 @@ // NeL includes // Project includes +#include "object.h" namespace PIPELINE { namespace MAX { namespace BUILTIN { /** - * \brief CGeomObject + * \brief CGeomGeomObject * \date 2012-08-22 08:58GMT * \author Jan Boon (Kaetemi) - * CGeomObject + * CGeomGeomObject */ -class CGeomObject +class CGeomObject : public CObject { -protected: - // pointers - // ... - - // instances - // ... public: - CGeomObject(); + CGeomObject(CScene *scene); virtual ~CGeomObject(); + + // class desc + static const ucstring DisplayName; + static const char *InternalName; + static const char *InternalNameUnknown; + static const NLMISC::CClassId ClassId; + static const TSClassId SuperClassId; + + // inherited + virtual void parse(uint16 version); + virtual void clean(); + virtual void build(uint16 version); + virtual void disown(); + virtual void init(); + virtual bool inherits(const NLMISC::CClassId classId) const; + virtual const ISceneClassDesc *classDesc() const; + virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; + +protected: + // inherited + virtual IStorageObject *createChunkById(uint16 id, bool container); + }; /* class CGeomObject */ +typedef CSceneClassDesc CGeomObjectClassDesc; +extern const CGeomObjectClassDesc GeomObjectClassDesc; +typedef CSuperClassDesc CGeomObjectSuperClassDesc; +extern const CGeomObjectSuperClassDesc GeomObjectSuperClassDesc; + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/i_node.cpp b/code/nel/tools/pipeline/max/builtin/i_node.cpp index 867e0e38c..404658dba 100644 --- a/code/nel/tools/pipeline/max/builtin/i_node.cpp +++ b/code/nel/tools/pipeline/max/builtin/i_node.cpp @@ -156,6 +156,19 @@ const ucstring &INode::userName() const return v; } +INode *INode::find(const ucstring &userName) const +{ + ucstring unl = NLMISC::toLower(userName); + for (std::set >::iterator it = m_Children.begin(), end = m_Children.end(); it != end; ++it) + { + INode *node = (*it); + nlassert(node); + if (NLMISC::toLower(node->userName()) == unl) + return node; + } + return NULL; +} + void INode::dumpNodes(std::ostream &ostream, const std::string &pad) const { ostream << "classId()) return true; + return CBaseObject::inherits(classId); +} + +const ISceneClassDesc *CObject::classDesc() const +{ + return &ObjectClassDesc; +} + +void CObject::toStringLocal(std::ostream &ostream, const std::string &pad) const +{ + CBaseObject::toStringLocal(ostream, pad); +} + +IStorageObject *CObject::createChunkById(uint16 id, bool container) +{ + return CBaseObject::createChunkById(id, container); +} + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/object.h b/code/nel/tools/pipeline/max/builtin/object.h index f2a6e4724..0aaf6b861 100644 --- a/code/nel/tools/pipeline/max/builtin/object.h +++ b/code/nel/tools/pipeline/max/builtin/object.h @@ -52,8 +52,34 @@ public: CObject(CScene *scene); virtual ~CObject(); + // class desc + static const ucstring DisplayName; + static const char *InternalName; + static const char *InternalNameUnknown; + static const NLMISC::CClassId ClassId; + static const TSClassId SuperClassId; + + // inherited + virtual void parse(uint16 version); + virtual void clean(); + virtual void build(uint16 version); + virtual void disown(); + virtual void init(); + virtual bool inherits(const NLMISC::CClassId classId) const; + virtual const ISceneClassDesc *classDesc() const; + virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; + +protected: + // inherited + virtual IStorageObject *createChunkById(uint16 id, bool container); + }; /* class CObject */ +typedef CSceneClassDesc CObjectClassDesc; +extern const CObjectClassDesc ObjectClassDesc; +typedef CSuperClassDesc CObjectSuperClassDesc; +extern const CObjectSuperClassDesc ObjectSuperClassDesc; + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/storage/app_data.h b/code/nel/tools/pipeline/max/builtin/storage/app_data.h index 833a464d0..a189458f3 100644 --- a/code/nel/tools/pipeline/max/builtin/storage/app_data.h +++ b/code/nel/tools/pipeline/max/builtin/storage/app_data.h @@ -85,7 +85,7 @@ public: /// Initialize a new instance of this chunk void init(); - // public + // public // TODO: Simplify using templates and returning a specialized storage object, auto-converted to the requested type. /// Gets a pointer to an appdata chunk buffer. Returns NULL if it does not exist. Size is returned in the size parameter. const uint8 *read(NLMISC::CClassId classId, TSClassId superClassId, uint32 subId, uint32 &size) const; /// Locks a pointer to an appdata chunk buffer for writing to with specified capacity. May return NULL if this chunk is unparsable or no memory can be allocated. diff --git a/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp new file mode 100644 index 000000000..fae5c5857 --- /dev/null +++ b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp @@ -0,0 +1,144 @@ +/** + * \file geom_buffers.cpp + * \brief CGeomBuffers + * \date 2012-08-25 07:55GMT + * \author Jan Boon (Kaetemi) + * CGeomBuffers + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE PIPELINE. If not, see + * . + */ + +#include +#include "geom_buffers.h" + +// STL includes + +// NeL includes +// #include + +// Project includes +#include "../../storage_array.h" + +// using namespace std; +// using namespace NLMISC; + +namespace PIPELINE { +namespace MAX { +namespace BUILTIN { +namespace STORAGE { + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +// Elevate warnings to errors in this file for stricter reading +#undef nlwarning +#define nlwarning nlerror + +// Elevate debug to error in this file for debugging +// #undef nldebug +// #define nldebug nlerror + +// Chunk identifiers +#define PMBS_GEOM_BUFFERS_TRI_A_VERTEX_CHUNK_ID 0x0914 +#define PMBS_GEOM_BUFFERS_TRI_A_INDEX_CHUNK_ID 0x0912 +#define PMBS_GEOM_BUFFERS_TRI_B_VERTEX_CHUNK_ID 0x0916 +#define PMBS_GEOM_BUFFERS_TRI_B_INDEX_CHUNK_ID 0x0918 +#define PMBS_GEOM_BUFFERS_TRI_C_VERTEX_CHUNK_ID 0x0938 +#define PMBS_GEOM_BUFFERS_TRI_C_INDEX_CHUNK_ID 0x0942 +#define PBMS_GEOM_BUFFERS_POLY_A_VERTEX_CHUNK_ID 0x0100 +#define PBMS_GEOM_BUFFERS_POLY_A_INDEX_A_CHUNK_ID 0x010a +#define PBMS_GEOM_BUFFERS_POLY_A_INDEX_B_CHUNK_ID 0x011a + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +CGeomBuffers::CGeomBuffers() +{ + +} + +CGeomBuffers::~CGeomBuffers() +{ + +} + +std::string CGeomBuffers::className() const +{ + return "GeomBuffers"; +} + +void CGeomBuffers::toString(std::ostream &ostream, const std::string &pad) const +{ + CStorageContainer::toString(ostream, pad); +} + +void CGeomBuffers::parse(uint16 version) +{ + CStorageContainer::parse(version); +} + +void CGeomBuffers::clean() +{ + CStorageContainer::clean(); +} + +void CGeomBuffers::build(uint16 version) +{ + CStorageContainer::build(version); +} + +void CGeomBuffers::disown() +{ + CStorageContainer::disown(); +} + +IStorageObject *CGeomBuffers::createChunkById(uint16 id, bool container) +{ + switch (id) + { + case PMBS_GEOM_BUFFERS_TRI_A_VERTEX_CHUNK_ID: + case PMBS_GEOM_BUFFERS_TRI_B_VERTEX_CHUNK_ID: + case PMBS_GEOM_BUFFERS_TRI_C_VERTEX_CHUNK_ID: + case PBMS_GEOM_BUFFERS_POLY_A_VERTEX_CHUNK_ID: + nlassert(!container); + return new CStorageArray(); + case PMBS_GEOM_BUFFERS_TRI_A_INDEX_CHUNK_ID: + case PMBS_GEOM_BUFFERS_TRI_B_INDEX_CHUNK_ID: + case PMBS_GEOM_BUFFERS_TRI_C_INDEX_CHUNK_ID: + case PBMS_GEOM_BUFFERS_POLY_A_INDEX_A_CHUNK_ID: + case PBMS_GEOM_BUFFERS_POLY_A_INDEX_B_CHUNK_ID: + nlassert(!container); + return new CStorageArray(); + } + return CStorageContainer::createChunkById(id, container); +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +} /* namespace STORAGE */ +} /* namespace BUILTIN */ +} /* namespace MAX */ +} /* namespace PIPELINE */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h new file mode 100644 index 000000000..0205bcac8 --- /dev/null +++ b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h @@ -0,0 +1,76 @@ +/** + * \file geom_buffers.h + * \brief CGeomBuffers + * \date 2012-08-25 07:55GMT + * \author Jan Boon (Kaetemi) + * CGeomBuffers + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE PIPELINE. If not, see + * . + */ + +#ifndef PIPELINE_GEOM_BUFFERS_H +#define PIPELINE_GEOM_BUFFERS_H +#include + +// STL includes + +// NeL includes + +// Project includes +#include "../../storage_object.h" + +namespace PIPELINE { +namespace MAX { +namespace BUILTIN { +namespace STORAGE { + +/** + * \brief CGeomBuffers + * \date 2012-08-25 07:55GMT + * \author Jan Boon (Kaetemi) + * CGeomBuffers + */ +class CGeomBuffers : public CStorageContainer +{ +public: + CGeomBuffers(); + virtual ~CGeomBuffers(); + + // inherited + virtual std::string className() const; + virtual void toString(std::ostream &ostream, const std::string &pad = "") const; + virtual void parse(uint16 version); + virtual void clean(); + virtual void build(uint16 version); + virtual void disown(); + +protected: + virtual IStorageObject *createChunkById(uint16 id, bool container); + +}; /* class CGeomBuffers */ + +} /* namespace STORAGE */ +} /* namespace BUILTIN */ +} /* namespace MAX */ +} /* namespace PIPELINE */ + +#endif /* #ifndef PIPELINE_GEOM_BUFFERS_H */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/storage_array.h b/code/nel/tools/pipeline/max/storage_array.h index 0bd2ca458..c38cb3bb8 100644 --- a/code/nel/tools/pipeline/max/storage_array.h +++ b/code/nel/tools/pipeline/max/storage_array.h @@ -93,7 +93,8 @@ void CStorageArray::toString(std::ostream &ostream, const std::string &pad) c for (typename TTypeArray::const_iterator it = Value.begin(), end = Value.end(); it != end; ++it) { std::string s = NLMISC::toString(*it); - ostream << "\n" << pad << i << ": " << s; + //ostream << "\n" << pad << i << ": " << s; + ostream << s << ", "; ++i; } ostream << " } "; diff --git a/code/nel/tools/pipeline/max/storage_object.cpp b/code/nel/tools/pipeline/max/storage_object.cpp index b1c0f2463..14a528f0c 100644 --- a/code/nel/tools/pipeline/max/storage_object.cpp +++ b/code/nel/tools/pipeline/max/storage_object.cpp @@ -241,6 +241,16 @@ void CStorageContainer::disown() } } +IStorageObject *CStorageContainer::findStorageObject(uint16 id) const +{ + for (TStorageObjectContainer::const_iterator it = m_Chunks.begin(), end = m_Chunks.end(); it != end; ++it) + { + if (it->first == id) + return it->second; + } + return NULL; +} + bool CStorageContainer::isContainer() const { return true; diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index ef9b18209..6bc1b2eec 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -123,6 +123,7 @@ public: public: // read access inline const TStorageObjectContainer &chunks() const { return m_Chunks; } + IStorageObject *findStorageObject(uint16 id) const; public: // should be protected but that doesn't compile, nice c++! // inherited diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index b3a9d254a..954c3d31b 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -33,12 +34,31 @@ #include "../max/builtin/scene_impl.h" #include "../max/builtin/i_node.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"; +using namespace PIPELINE::MAX; +using namespace PIPELINE::MAX::BUILTIN; + +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"; +void exportObj(const std::string &fileName, const CReferenceMaker *triObject) +{ + triObject->toString(std::cout); + IStorageObject *bufferBlock = triObject->findStorageObject(0x08fe); + nlassert(bufferBlock->isContainer()); + CStorageContainer *buffers = static_cast(bufferBlock); + CStorageArray *vertexBuffer = static_cast *>(buffers->findStorageObject(0x0914)); + CStorageArray *indexBuffer = static_cast *>(buffers->findStorageObject(0x0912)); + + std::ofstream ofs(fileName.c_str()); + for (uint i = 1; i < vertexBuffer->Value.size() - 1; i += 3) + ofs << "v " << vertexBuffer->Value[i] << " " << vertexBuffer->Value[i + 1] << " " << vertexBuffer->Value[i + 2] << "\n"; + for (uint i = 1; i < indexBuffer->Value.size() - 1; i += 5) + ofs << "f " << (indexBuffer->Value[i] + 1) << " " << (indexBuffer->Value[i + 1] + 1) << " " << (indexBuffer->Value[i + 2] + 1) << "\n"; +} + // int __stdcall WinMain(void *, void *, void *, int) int main(int argc, char **argv) { @@ -167,9 +187,9 @@ int main(int argc, char **argv) nldebug("PARSE"); scene.parse(PIPELINE::MAX::VersionUnknown); // parse the structure to readable data nldebug("CLEAN"); - scene.clean(); // cleanup unused file structure + // scene.clean(); // cleanup unused file structure, don't clean up if we want direct access to chunks as well // <- TEST - scene.toString(std::cout); + // scene.toString(std::cout); std::cout << "\n"; //classDirectory3.build(PIPELINE::MAX::VersionUnknown); //classDirectory3.disown(); @@ -180,6 +200,9 @@ int main(int argc, char **argv) scene.container()->scene()->rootNode()->dumpNodes(std::cout); std::cout << "\n"; + PIPELINE::MAX::BUILTIN::INode *node = scene.container()->scene()->rootNode()->find(ucstring("TR_HOF_civil01_gilet")); nlassert(node); + exportObj("tr_hof_civil01_gilet.obj", node->getReference(1)->getReference(1)); + // TEST APP DATA #define MAXSCRIPT_UTILITY_CLASS_ID (NLMISC::CClassId(0x04d64858, 0x16d1751d))