diff --git a/code/nel/tools/pipeline/max/builtin/animatable.cpp b/code/nel/tools/pipeline/max/builtin/animatable.cpp index 7b16bff23..11211ed78 100644 --- a/code/nel/tools/pipeline/max/builtin/animatable.cpp +++ b/code/nel/tools/pipeline/max/builtin/animatable.cpp @@ -88,7 +88,16 @@ void CAnimatable::build(uint16 version) CSceneClass::build(version); if (m_AppData) { - putChunk(PMBS_APP_DATA_CHUNK_ID, m_AppData); + if (m_AppData->entries().size() == 0) + { + // Discard appdata if it has no entries + delete m_AppData; + m_AppData = NULL; + } + else + { + putChunk(PMBS_APP_DATA_CHUNK_ID, m_AppData); + } } } @@ -117,13 +126,24 @@ const ISceneClassDesc *CAnimatable::classDesc() const void CAnimatable::toStringLocal(std::ostream &ostream, const std::string &pad) const { CSceneClass::toStringLocal(ostream, pad); - if (m_AppData) + if (m_AppData && m_AppData->entries().size() != 0) { ostream << "\n" << pad << "AppData: "; m_AppData->toString(ostream, pad + "\t"); } } +STORAGE::CAppData *CAnimatable::appData() +{ + if (m_ChunksOwnsPointers) { nlerror("Not parsed"); return NULL; } + if (!m_AppData) + { + m_AppData = new STORAGE::CAppData(); + m_AppData->init(); + } + return m_AppData; +} + IStorageObject *CAnimatable::createChunkById(uint16 id, bool container) { switch (id) diff --git a/code/nel/tools/pipeline/max/builtin/animatable.h b/code/nel/tools/pipeline/max/builtin/animatable.h index 8ecb87841..7072b519c 100644 --- a/code/nel/tools/pipeline/max/builtin/animatable.h +++ b/code/nel/tools/pipeline/max/builtin/animatable.h @@ -76,7 +76,7 @@ public: virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "") const; // public - inline STORAGE::CAppData *appData() const { return m_AppData; } + STORAGE::CAppData *appData(); protected: // inherited diff --git a/code/nel/tools/pipeline/max/builtin/reference_maker.cpp b/code/nel/tools/pipeline/max/builtin/reference_maker.cpp index 6853f7f26..e67e58692 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_maker.cpp +++ b/code/nel/tools/pipeline/max/builtin/reference_maker.cpp @@ -42,6 +42,27 @@ namespace PIPELINE { namespace MAX { namespace BUILTIN { +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +// 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 PMB_REFERENCES_2034_CHUNK_ID 0x2034 +#define PMB_REFERENCES_2035_CHUNK_ID 0x2034 +#define PMB_204B_EQUALS_2E_CHUNK_ID 0x204B + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + CReferenceMaker::CReferenceMaker() { @@ -101,6 +122,20 @@ void CReferenceMaker::toStringLocal(std::ostream &ostream, const std::string &pa CAnimatable::toStringLocal(ostream, pad); } +IStorageObject *CReferenceMaker::createChunkById(uint16 id, bool container) +{ + switch (id) + { + case PMB_204B_EQUALS_2E_CHUNK_ID: + return new CStorageValue(); + } + return CAnimatable::createChunkById(id, container); +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/reference_maker.h b/code/nel/tools/pipeline/max/builtin/reference_maker.h index 5e33adecb..504b5b7d3 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_maker.h +++ b/code/nel/tools/pipeline/max/builtin/reference_maker.h @@ -69,6 +69,10 @@ public: 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 CReferenceMaker */ typedef CSceneClassDesc CReferenceMakerClassDesc; diff --git a/code/nel/tools/pipeline/max/builtin/reference_target.cpp b/code/nel/tools/pipeline/max/builtin/reference_target.cpp index 85ef3f7c2..5dc4d147b 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_target.cpp +++ b/code/nel/tools/pipeline/max/builtin/reference_target.cpp @@ -101,6 +101,11 @@ void CReferenceTarget::toStringLocal(std::ostream &ostream, const std::string &p CReferenceMaker::toStringLocal(ostream, pad); } +IStorageObject *CReferenceTarget::createChunkById(uint16 id, bool container) +{ + return CReferenceMaker::createChunkById(id, container); +} + } /* namespace BUILTIN */ } /* namespace MAX */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/max/builtin/reference_target.h b/code/nel/tools/pipeline/max/builtin/reference_target.h index 70cf481d4..b32a71b46 100644 --- a/code/nel/tools/pipeline/max/builtin/reference_target.h +++ b/code/nel/tools/pipeline/max/builtin/reference_target.h @@ -77,6 +77,10 @@ public: 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 CReferenceTarget */ typedef CSceneClassDesc CReferenceTargetClassDesc; diff --git a/code/nel/tools/pipeline/max/storage_array.cpp b/code/nel/tools/pipeline/max/storage_array.cpp new file mode 100644 index 000000000..acd0326c7 --- /dev/null +++ b/code/nel/tools/pipeline/max/storage_array.cpp @@ -0,0 +1,49 @@ +/** + * \file storage_array.cpp + * \brief CStorageArray + * \date 2012-08-21 11:33GMT + * \author Jan Boon (Kaetemi) + * CStorageArray + */ + +/* + * 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 "storage_array.h" + +// STL includes + +// NeL includes +// #include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace PIPELINE { +namespace MAX { + +void blahblahblah() { } + +} /* namespace MAX */ +} /* namespace PIPELINE */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/storage_array.h b/code/nel/tools/pipeline/max/storage_array.h new file mode 100644 index 000000000..c23dc8507 --- /dev/null +++ b/code/nel/tools/pipeline/max/storage_array.h @@ -0,0 +1,122 @@ +/** + * \file storage_array.h + * \brief CStorageArray + * \date 2012-08-21 11:33GMT + * \author Jan Boon (Kaetemi) + * CStorageArray + */ + +/* + * 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_STORAGE_ARRAY_H +#define PIPELINE_STORAGE_ARRAY_H +#include + +// STL includes +#include + +// NeL includes +#include +#include + +// Project includes +#include "storage_object.h" + +namespace PIPELINE { +namespace MAX { + +/** + * \brief CStorageArray + * \date 2012-08-21 11:33GMT + * \author Jan Boon (Kaetemi) + * WARNING: sizeof(TType) should match the serialized size, + * otherwise you must specialize the getSize and setSize functions! + */ +template +class CStorageArray : public IStorageObject +{ +public: + // public data + typedef T TType; + typedef std::vector TTypeArray; + TTypeArray Value; + + // inherited + virtual std::string className() const; + virtual void serial(NLMISC::IStream &stream); + virtual void toString(std::ostream &ostream, const std::string &pad = "") const; + +public: // should be protected but that doesn't compile, nice c++! + // Sets size when reading + virtual void setSize(sint32 size); + // Gets the size when writing, return false if unknown + virtual bool getSize(sint32 &size) const; +}; /* class CStorageArray */ + +template +std::string CStorageArray::className() const +{ + return "StorageArray"; +} + +template +void CStorageArray::serial(NLMISC::IStream &stream) +{ + for (typename TTypeArray::const_iterator it = Value.begin(), end = Value.end(); it != end; ++it) + { + stream.serial(*it); + } +} + +template +void CStorageArray::toString(std::ostream &ostream, const std::string &pad) const +{ + ostream << "(" << className() << ") { "; // << 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; + ++i; + } + ostream << " } "; +} + +template +void CStorageArray::setSize(sint32 size) +{ + if ((sizeof(TType) % size) != 0) + nlerror("Size does not match value type"); + Value.resize(size / sizeof(TType)); +} + +template +bool CStorageArray::getSize(sint32 &size) const +{ + size = Value.size() * sizeof(TType); + return true; +} + +} /* namespace MAX */ +} /* namespace PIPELINE */ + +#endif /* #ifndef PIPELINE_STORAGE_ARRAY_H */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index 55a6715bd..1acd5ded6 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -39,7 +39,8 @@ namespace PIPELINE { namespace MAX { - class CStorageChunks; + +class CStorageChunks; struct EStorage : public NLMISC::Exception { diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index af020797e..ed774e697 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -33,8 +33,8 @@ //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 *filename = "/home/kaetemi/3dsMax/scenes/test2008.max"; +//static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max"; static const char *streamname = "Scene"; // int __stdcall WinMain(void *, void *, void *, int)