From 8cacf5f3860158e8311551b2f9acf865c4d49ea2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 19 Aug 2012 22:57:22 +0200 Subject: [PATCH] Added: #1440 Parser skeleton for Scene --HG-- branch : build_pipeline_v3 --- code/nel/tools/pipeline/max/scene.cpp | 179 ++++++++++++++++++ code/nel/tools/pipeline/max/scene.h | 184 +++++++++++++++++++ code/nel/tools/pipeline/max/storage_object.h | 8 + code/nel/tools/pipeline/max_dump/info.txt | 1 + code/nel/tools/pipeline/max_dump/main.cpp | 5 +- 5 files changed, 375 insertions(+), 2 deletions(-) create mode 100644 code/nel/tools/pipeline/max/scene.cpp create mode 100644 code/nel/tools/pipeline/max/scene.h diff --git a/code/nel/tools/pipeline/max/scene.cpp b/code/nel/tools/pipeline/max/scene.cpp new file mode 100644 index 000000000..c4f8e4859 --- /dev/null +++ b/code/nel/tools/pipeline/max/scene.cpp @@ -0,0 +1,179 @@ +/** + * \file scene.cpp + * \brief CScene + * \date 2012-08-18 19:25GMT + * \author Jan Boon (Kaetemi) + * CScene + */ + +/* + * 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 "scene.h" + +// STL includes + +// NeL includes +// #include +#include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace PIPELINE { +namespace MAX { + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +CScene::CScene() +{ + +} + +CScene::~CScene() +{ + +} + +std::string CScene::getClassName() +{ + return "Scene"; +} + +void CScene::toString(std::ostream &ostream, const std::string &pad) +{ + CStorageContainer::toString(ostream, pad); +} + +IStorageObject *CScene::createChunkById(uint16 id, bool container) +{ + if (container) + { + // Return the scene class container. There can be only one. + return new CSceneClassContainer(); + } + return CStorageContainer::createChunkById(id, container); +} + +void CScene::serialized(TStorageObjectContainer::iterator soit, bool container) +{ + CStorageContainer::serialized(soit, container); +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +CSceneClassContainer::CSceneClassContainer() +{ + +} + +CSceneClassContainer::~CSceneClassContainer() +{ + +} + +std::string CSceneClassContainer::getClassName() +{ + return "SceneClassContainer"; +} + +void CSceneClassContainer::toString(std::ostream &ostream, const std::string &pad) +{ + CStorageContainer::toString(ostream, pad); +} + +IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container) +{ + if (container) + { + // TODO: Check the class registry. + // Return default unknown scene class. + return new CSceneClass(); + } + return CStorageContainer::createChunkById(id, container); +} + +void CSceneClassContainer::serialized(TStorageObjectContainer::iterator soit, bool container) +{ + CStorageContainer::serialized(soit, container); +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +CSceneClass::CSceneClass() +{ + +} + +CSceneClass::~CSceneClass() +{ + +} + +std::string CSceneClass::getClassName() +{ + return getClassDesc()->getInternalName(); +} + +void CSceneClass::toString(std::ostream &ostream, const std::string &pad) +{ + CStorageContainer::toString(ostream, pad); +} + +IStorageObject *CSceneClass::createChunkById(uint16 id, bool container) +{ + return CStorageContainer::createChunkById(id, container); +} + +void CSceneClass::serialized(TStorageObjectContainer::iterator soit, bool container) +{ + CStorageContainer::serialized(soit, container); +} + +const ucchar *CSceneClass::DisplayName = ucstring("Unknown Scene Class").c_str(); +const char *CSceneClass::InternalName = "SceneClass"; +const NLMISC::CClassId CSceneClass::ClassId = NLMISC::CClassId::Null; +const TSClassId CSceneClass::SuperClassId = 0x0000; + +namespace { +static const CSceneClassDesc SceneClassDesc; +} /* anonymous namespace */ + +const ISceneClassDesc *CSceneClass::getClassDesc() +{ + return static_cast(&SceneClassDesc); +} + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +} /* namespace MAX */ +} /* namespace PIPELINE */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/max/scene.h b/code/nel/tools/pipeline/max/scene.h new file mode 100644 index 000000000..9f4f2e6c8 --- /dev/null +++ b/code/nel/tools/pipeline/max/scene.h @@ -0,0 +1,184 @@ +/** + * \file scene.h + * \brief CScene + * \date 2012-08-18 19:25GMT + * \author Jan Boon (Kaetemi) + * CScene + */ + +/* + * 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_SCENE_H +#define PIPELINE_SCENE_H +#include + +// STL includes + +// NeL includes +#include + +// Project includes +#include "storage_object.h" +#include "storage_value.h" + +namespace PIPELINE { +namespace MAX { + +// Don't really care about superclass IDs right now, but we have to. +typedef uint32 TSClassId; + +/** + * \brief CScene + * \date 2012-08-19 19:25GMT + * \author Jan Boon (Kaetemi) + * CScene + */ +class CScene : public CStorageContainer +{ +public: + CScene(); + virtual ~CScene(); + + // inherited + virtual std::string getClassName(); + virtual void toString(std::ostream &ostream, const std::string &pad = ""); + +protected: + virtual IStorageObject *createChunkById(uint16 id, bool container); + virtual void serialized(TStorageObjectContainer::iterator soit, bool container); + +}; /* class CScene */ + +/** + * \brief CSceneClassContainer + * \date 2012-08-19 19:25GMT + * \author Jan Boon (Kaetemi) + * CSceneClassContainer + */ +class CSceneClassContainer : public CStorageContainer +{ +public: + CSceneClassContainer(); + virtual ~CSceneClassContainer(); + + // inherited + virtual std::string getClassName(); + virtual void toString(std::ostream &ostream, const std::string &pad = ""); + +protected: + virtual IStorageObject *createChunkById(uint16 id, bool container); + virtual void serialized(TStorageObjectContainer::iterator soit, bool container); + +}; /* class CSceneClassContainer */ + +class ISceneClassDesc; + +/** + * \brief CSceneClass + * \date 2012-08-19 19:25GMT + * \author Jan Boon (Kaetemi) + * CSceneClass + */ +class CSceneClass : public CStorageContainer +{ +public: + CSceneClass(); + virtual ~CSceneClass(); + + // inherited + virtual std::string getClassName(); + virtual void toString(std::ostream &ostream, const std::string &pad = ""); + + // static const + static const ucchar *DisplayName; + static const char *InternalName; + static const NLMISC::CClassId ClassId; + static const TSClassId SuperClassId; + + // virtual + virtual const ISceneClassDesc *getClassDesc(); + +protected: + virtual IStorageObject *createChunkById(uint16 id, bool container); + virtual void serialized(TStorageObjectContainer::iterator soit, bool container); + +}; /* class CSceneClass */ + +/** + * \brief ISceneClassDesc + * \date 2012-08-19 19:25GMT + * \author Jan Boon (Kaetemi) + * ISceneClassDesc + */ +class ISceneClassDesc +{ +public: + virtual CSceneClass *create() const = 0; + virtual void destroy(CSceneClass *sc) const = 0; + virtual const ucchar *getDisplayName() const = 0; + virtual const char *getInternalName() const = 0; + virtual NLMISC::CClassId getClassId() const = 0; + virtual TSClassId getSuperClassId() const = 0; + +}; /* class ISceneClassDesc */ + +/** + * \brief CSceneClassDesc + * \date 2012-08-19 19:25GMT + * \author Jan Boon (Kaetemi) + * CSceneClassDesc + * Use in a cpp when registering the CClassId. + */ +template +class CSceneClassDesc : public ISceneClassDesc +{ +public: + virtual CSceneClass *create() const { return static_cast(new T()); } + virtual void destroy(CSceneClass *sc) const { delete static_cast(sc); } + virtual const ucchar *getDisplayName() const { return T::DisplayName; } + virtual const char *getInternalName() const { return T::InternalName; } + virtual NLMISC::CClassId getClassId() const { return T::ClassId; } + virtual TSClassId getSuperClassId() const { return T::SuperClassId; } + +}; /* class CSceneClassDesc */ + +/** + * \brief CSceneClassRegistry + * \date 2012-08-19 19:25GMT + * \author Jan Boon (Kaetemi) + * CSceneClassRegistry + */ +class CSceneClassRegistry +{ +public: + void add(const NLMISC::CClassId, const ISceneClassDesc *desc); + void remove(const NLMISC::CClassId); + CSceneClass *create(const NLMISC::CClassId classid) const; + void destroy(CSceneClass *sceneClass) const; + const ISceneClassDesc *describe(const NLMISC::CClassId classid) const; + +}; /* class ISceneClassConstructor */ + +} /* namespace MAX */ +} /* namespace PIPELINE */ + +#endif /* #ifndef PIPELINE_SCENE_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 1e0c00109..b2f0b8bbc 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -47,6 +47,14 @@ struct EStorage : public NLMISC::Exception virtual ~EStorage() throw() { } }; +enum TParseLevel +{ + PARSE_SYSTEM = 0x00000001, // Parse system related classes + // PARSE_BUILTIN = 0x00000002; // Parse all builtin classes - reserved + PARSE_NELDATA = 0x00000004, // Parse all structures related to nel specific data (nel material, node properties, etcetera) + PARSE_NEL3D = 0x00000008, // Parse classes to initialize their nel3d equivalent classes +}; + // IStorageObject : exposes serial(CStorageStream &stream) and dump(const std::string &pad) class IStorageObject : public NLMISC::IStreamable { diff --git a/code/nel/tools/pipeline/max_dump/info.txt b/code/nel/tools/pipeline/max_dump/info.txt index d04480a76..838100500 100644 --- a/code/nel/tools/pipeline/max_dump/info.txt +++ b/code/nel/tools/pipeline/max_dump/info.txt @@ -839,6 +839,7 @@ max2010 max2010 scene, near no fx 2f 27 02 05 +std::string CExportNel::getScriptAppData (Animatable *node, uint32 id, const std::string& def) AppDataChunk *ap=node->GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, id); MAXSCRIPT_UTILITY_CLASS_ID Class_ID(0x4d64858, 0x16d1751d) UTILITY_CLASS_ID 0x001020 diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 3805e9002..0250bd330 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -22,12 +22,13 @@ #include "../max/class_directory_3.h" #include "../max/class_data.h" #include "../max/config.h" +#include "../max/scene.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 = "/home/kaetemi/3dsMax/scenes/test2008.max"; //static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max"; -static const char *streamname = "ClassDirectory3"; +static const char *streamname = "Scene"; // int __stdcall WinMain(void *, void *, void *, int) int main(int argc, char **argv) @@ -79,7 +80,7 @@ int main(int argc, char **argv) //gsf_input_dump(input, 1); // just a regular hex dump of this input stream PIPELINE::MAX::CStorageStream instream(input); //dumpContainer(instream, ""); - PIPELINE::MAX::CClassDirectory3 ctr; + PIPELINE::MAX::CScene ctr; ctr.serial(instream); ctr.toString(std::cout); std::cout << "\n";