diff --git a/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp index fae5c5857..e9a53b7fe 100644 --- a/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp +++ b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.cpp @@ -29,9 +29,11 @@ #include "geom_buffers.h" // STL includes +#include // NeL includes // #include +#include // Project includes #include "../../storage_array.h" @@ -71,6 +73,26 @@ namespace STORAGE { //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// +void CGeomTriIndexInfo::serial(NLMISC::IStream &stream) +{ + stream.serial(a); + stream.serial(b); + stream.serial(c); + stream.serial(i1); + stream.serial(i2); +} + +std::string CGeomTriIndexInfo::toString() const +{ + std::stringstream ss; + ss << a << ", " << b << ", " << c << ", " << i1 << ", " << i2; + return ss.str(); +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + CGeomBuffers::CGeomBuffers() { @@ -115,19 +137,23 @@ 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(); + case PMBS_GEOM_BUFFERS_TRI_A_INDEX_CHUNK_ID: + nlassert(!container); + return new CStorageArraySizePre(); + case PMBS_GEOM_BUFFERS_TRI_A_VERTEX_CHUNK_ID: + nlassert(!container); + return new CStorageArraySizePre(); } return CStorageContainer::createChunkById(id, container); } diff --git a/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h index 0205bcac8..eefda308d 100644 --- a/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h +++ b/code/nel/tools/pipeline/max/builtin/storage/geom_buffers.h @@ -41,6 +41,17 @@ namespace MAX { namespace BUILTIN { namespace STORAGE { +struct CGeomTriIndexInfo +{ + uint32 a; + uint32 b; + uint32 c; + uint32 i1; + uint32 i2; + void serial(NLMISC::IStream &stream); + std::string toString() const; +}; + /** * \brief CGeomBuffers * \date 2012-08-25 07:55GMT diff --git a/code/nel/tools/pipeline/max/storage_array.h b/code/nel/tools/pipeline/max/storage_array.h index c38cb3bb8..ca558c60c 100644 --- a/code/nel/tools/pipeline/max/storage_array.h +++ b/code/nel/tools/pipeline/max/storage_array.h @@ -88,16 +88,16 @@ void CStorageArray::serial(NLMISC::IStream &stream) template void CStorageArray::toString(std::ostream &ostream, const std::string &pad) const { - ostream << "(" << className() << ") { "; // << s << " } "; + ostream << "(" << className() << ") [" << Value.size() << "] { "; // << s << " } "; uint i = 0; 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 << s << ", "; + ostream << "{ " << s << " } "; ++i; } - ostream << " } "; + ostream << "} "; } template @@ -115,6 +115,43 @@ bool CStorageArray::getSize(sint32 &size) const return true; } +template +class CStorageArraySizePre : public CStorageArray +{ +public: + virtual std::string className() const; + virtual void serial(NLMISC::IStream &stream); + virtual void setSize(sint32 size); + virtual bool getSize(sint32 &size) const; +}; + +template +std::string CStorageArraySizePre::className() const +{ + return "StorageArraySizePre"; +} + +template +void CStorageArraySizePre::serial(NLMISC::IStream &stream) +{ + uint32 size = this->Value.size(); + stream.serial(size); + nlassert(this->Value.size() == size); + CStorageArray::serial(stream); +} + +template +void CStorageArraySizePre::setSize(sint32 size) +{ + CStorageArray::setSize(size - sizeof(uint32)); +} + +template +bool CStorageArraySizePre::getSize(sint32 &size) const +{ + return CStorageArray::getSize(size) + sizeof(uint32); +} + } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 954c3d31b..96c4f1006 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "../max/storage_stream.h" #include "../max/storage_object.h" @@ -30,12 +31,14 @@ // Testing #include "../max/builtin/storage/app_data.h" +#include "../max/builtin/storage/geom_buffers.h" #include "../max/builtin/builtin.h" #include "../max/builtin/scene_impl.h" #include "../max/builtin/i_node.h" using namespace PIPELINE::MAX; using namespace PIPELINE::MAX::BUILTIN; +using namespace PIPELINE::MAX::BUILTIN::STORAGE; 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"; @@ -49,14 +52,14 @@ void exportObj(const std::string &fileName, const CReferenceMaker *triObject) 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)); + CStorageArraySizePre *vertexBuffer = static_cast *>(buffers->findStorageObject(0x0914)); + CStorageArraySizePre *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"; + for (uint i = 0; i < vertexBuffer->Value.size(); ++i) + ofs << "v " << vertexBuffer->Value[i].x << " " << vertexBuffer->Value[i].y << " " << vertexBuffer->Value[i].z << "\n"; + for (uint i = 0; i < indexBuffer->Value.size(); ++i) + ofs << "f " << (indexBuffer->Value[i].a) << " " << (indexBuffer->Value[i].b) << " " << (indexBuffer->Value[i].c) << "\n"; } // int __stdcall WinMain(void *, void *, void *, int)