Linux multi-monitor fullscreen support
[ryzomcore.git] / nel / tools / 3d / pipeline_max / scene.cpp
blob85293e680a7ede5ad5021677e05be89276ede364
1 /**
2 * \file scene.cpp
3 * \brief CScene
4 * \date 2012-08-18 19:25GMT
5 * \author Jan Boon (Kaetemi)
6 * CScene
7 */
9 /*
10 * Copyright (C) 2012 by authors
12 * This file is part of RYZOM CORE PIPELINE.
13 * RYZOM CORE PIPELINE is free software: you can redistribute it
14 * and/or modify it under the terms of the GNU Affero General Public
15 * License as published by the Free Software Foundation, either
16 * version 3 of the License, or (at your option) any later version.
18 * RYZOM CORE PIPELINE is distributed in the hope that it will be
19 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
23 * You should have received a copy of the GNU Affero General Public
24 * License along with RYZOM CORE PIPELINE. If not, see
25 * <http://www.gnu.org/licenses/>.
28 #include <nel/misc/types_nl.h>
29 #include "scene.h"
31 // STL includes
32 #include <iostream>
34 // NeL includes
35 // #include <nel/misc/debug.h>
36 #include <nel/misc/ucstring.h>
38 // Project includes
39 #include "dll_directory.h"
40 #include "class_directory_3.h"
41 #include "scene_class_registry.h"
42 #include "scene_class_unknown.h"
43 #include "builtin/scene_impl.h"
45 using namespace std;
46 // using namespace NLMISC;
48 namespace PIPELINE {
49 namespace MAX {
51 ////////////////////////////////////////////////////////////////////////
52 ////////////////////////////////////////////////////////////////////////
53 ////////////////////////////////////////////////////////////////////////
55 CScene::CScene(const CSceneClassRegistry *sceneClassRegistry, CDllDirectory *dllDirectory, CClassDirectory3 *classDirectory3) : m_SceneClassRegistry(sceneClassRegistry), m_DllDirectory(dllDirectory), m_ClassDirectory3(classDirectory3)
60 CScene::~CScene()
65 std::string CScene::className() const
67 return "Scene";
70 void CScene::toString(std::ostream &ostream, const std::string &pad) const
72 CStorageContainer::toString(ostream, pad);
75 void CScene::parse(uint16 version, uint filter)
77 CStorageContainer::parse(version);
78 nlassert(m_Chunks.size() == 1);
81 void CScene::clean()
83 CStorageContainer::clean();
86 void CScene::build(uint16 version, uint filter)
88 nlassert(m_Chunks.size() == 1);
89 CStorageContainer::build(this->version());
92 void CScene::disown()
94 CStorageContainer::disown();
97 uint16 CScene::version()
99 nlassert(m_Chunks.size() == 1);
100 return m_Chunks.begin()->first;
103 CSceneClassContainer *CScene::container()
105 nlassert(m_Chunks.size() == 1);
106 return static_cast<CSceneClassContainer *>(m_Chunks.begin()->second);
109 IStorageObject *CScene::createChunkById(uint16 id, bool container)
111 if (container)
113 // Return the scene class container. There can be only one.
114 return new CSceneClassContainer(this, m_SceneClassRegistry, m_DllDirectory, m_ClassDirectory3);
116 return CStorageContainer::createChunkById(id, container);
119 ////////////////////////////////////////////////////////////////////////
120 ////////////////////////////////////////////////////////////////////////
121 ////////////////////////////////////////////////////////////////////////
123 CSceneClassContainer::CSceneClassContainer(CScene *scene, const CSceneClassRegistry *sceneClassRegistry, CDllDirectory *dllDirectory, CClassDirectory3 *classDirectory3) : m_Scene(scene), m_SceneClassRegistry(sceneClassRegistry), m_DllDirectory(dllDirectory), m_ClassDirectory3(classDirectory3), m_BuiltinScene(NULL)
128 CSceneClassContainer::~CSceneClassContainer()
133 std::string CSceneClassContainer::className() const
135 return "SceneClassContainer";
138 void CSceneClassContainer::toString(std::ostream &ostream, const std::string &pad) const
140 CStorageContainer::toString(ostream, pad);
143 void CSceneClassContainer::parse(uint16 version, uint filter)
145 // Temporary 'readonly' implementation, not modifying m_Chunks!
146 m_StorageObjectByIndex.resize(m_Chunks.size());
147 TStorageObjectIterator it = m_Chunks.begin();
148 for (std::vector<CSceneClass *>::size_type i = 0; i < m_StorageObjectByIndex.size(); ++i)
150 m_StorageObjectByIndex[i] = static_cast<CSceneClass *>(it->second);
151 ++it;
153 CSceneClass *builtinScene = m_StorageObjectByIndex[m_StorageObjectByIndex.size() - 1];
154 nlassert(builtinScene);
155 m_BuiltinScene = dynamic_cast<BUILTIN::CSceneImpl *>(builtinScene);
156 nlassert(m_BuiltinScene);
157 CStorageContainer::parse(version);
160 void CSceneClassContainer::clean()
162 // Temporary 'readonly' implementation, not modifying m_Chunks!
163 CStorageContainer::clean();
166 void CSceneClassContainer::build(uint16 version, uint filter)
168 // Temporary 'readonly' implementation, not modifying m_Chunks!
169 for (std::vector<CSceneClass *>::size_type i = 0; i < m_StorageObjectByIndex.size(); ++i)
171 m_StorageObjectToIndex[m_StorageObjectByIndex[i]] = i;
173 CStorageContainer::build(version);
176 void CSceneClassContainer::disown()
178 // Temporary 'readonly' implementation, not modifying m_Chunks!
179 CStorageContainer::disown();
182 CSceneClass *CSceneClassContainer::getByStorageIndex(uint32 index) const
184 // Temporary 'readonly' implementation, not modifying m_Chunks!
185 if (index >= m_StorageObjectByIndex.size()) { nlerror("Index %i is outside size %i", index, m_StorageObjectByIndex.size()); return NULL; }
186 return m_StorageObjectByIndex[index];
189 uint32 CSceneClassContainer::getOrCreateStorageIndex(CSceneClass *storageObject)
191 // Temporary 'readonly' implementation, not modifying m_Chunks!
192 return m_StorageObjectToIndex[storageObject];
195 IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container)
197 // nldebug("Scene class id %x (%i)", (uint32)id, (uint32)id);
198 switch (id)
200 // Known unknown special identifiers...
201 case 0x2032:
202 return m_SceneClassRegistry->createUnknown(m_Scene, 0x0, NLMISC::CClassId(0x29263a68, 0x405f22f5), ucstring("OSM Derived"), ucstring("Internal"), ucstring("Internal"));
203 case 0x2033:
204 return m_SceneClassRegistry->createUnknown(m_Scene, 0x0, NLMISC::CClassId(0x4ec13906, 0x5578130e), ucstring("WSM Derived"), ucstring("Internal"), ucstring("Internal"));
205 // return new CSceneClass(m_Scene); // TODO: Make dummy dllentry and classentry for these...
206 // return static_cast<IStorageObject *>(new CSceneClassUnknown<CSceneClass>(dllEntry, classEntry));
208 const CClassEntry *classEntry = m_ClassDirectory3->get(id);
209 CSceneClass *sceneClass = m_SceneClassRegistry->create(m_Scene, classEntry->superClassId(), classEntry->classId());
210 if (sceneClass)
212 return static_cast<IStorageObject *>(sceneClass);
214 else
216 const CDllEntry *dllEntry = m_DllDirectory->get(classEntry->dllIndex());
217 sceneClass = m_SceneClassRegistry->createUnknown(m_Scene, classEntry->superClassId(), classEntry->classId(), classEntry->displayName(), dllEntry->dllFilename(), dllEntry->dllDescription());
218 if (sceneClass)
220 return static_cast<IStorageObject *>(sceneClass);
222 else
224 // Create an invalid unknown scene class
225 return static_cast<IStorageObject *>(new CSceneClassUnknown<CSceneClass>(m_Scene,classEntry->classId(), classEntry->superClassId(), classEntry->displayName(), "SceneClassUnknown", dllEntry->dllFilename(), dllEntry->dllDescription()));
230 ////////////////////////////////////////////////////////////////////////
231 ////////////////////////////////////////////////////////////////////////
232 ////////////////////////////////////////////////////////////////////////
234 } /* namespace MAX */
235 } /* namespace PIPELINE */
237 /* end of file */