1 | /** |
---|
2 | * This source file is part of OgreColladaPlugin |
---|
3 | * an addon for OGRE (Object-oriented Graphics Rendering Engine) |
---|
4 | * For the latest info, see http://www.ogre3d.org/ |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify it under |
---|
7 | * the terms of the GNU Lesser General Public License as published by the Free Software |
---|
8 | * Foundation; either version 2 of the License, or (at your option) any later |
---|
9 | * version. |
---|
10 | |
---|
11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
---|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
13 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
14 | |
---|
15 | * You should have received a copy of the GNU Lesser General Public License along with |
---|
16 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
17 | * Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
18 | * http://www.gnu.org/copyleft/lesser.txt. |
---|
19 | * |
---|
20 | * @authors Philipp Hartl, Jeff Doyle (nfz) |
---|
21 | * @see README |
---|
22 | */ |
---|
23 | |
---|
24 | #include "OgreColladaPrerequisites.h" |
---|
25 | #include "OgreColladaManager.h" |
---|
26 | #include "OgreColladaDocument.h" |
---|
27 | |
---|
28 | #include "OgreStringConverter.h" |
---|
29 | |
---|
30 | namespace Ogre { |
---|
31 | |
---|
32 | //----------------------------------------------------------------------- |
---|
33 | template<> ColladaManager* Singleton<ColladaManager>::ms_Singleton = 0; |
---|
34 | |
---|
35 | //----------------------------------------------------------------------- |
---|
36 | ColladaManager::ColladaManager(void) |
---|
37 | : mVersion(StringConverter::toString(COLLADA_VERSION_MAJOR) + "." + |
---|
38 | StringConverter::toString(COLLADA_VERSION_MINOR) + "." + |
---|
39 | StringConverter::toString(COLLADA_VERSION_PATCH)) |
---|
40 | { |
---|
41 | |
---|
42 | LogManager::getSingleton().logMessage("Collada Plugin version: " + mVersion); |
---|
43 | // Resource type |
---|
44 | mResourceType = "Collada"; |
---|
45 | |
---|
46 | // Register with resource group manager |
---|
47 | ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this); |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | //----------------------------------------------------------------------- |
---|
52 | ColladaManager::~ColladaManager(void) |
---|
53 | { |
---|
54 | // Resources cleared by superclass |
---|
55 | // Unregister with resource group manager |
---|
56 | ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType); |
---|
57 | ResourceGroupManager::getSingleton()._unregisterScriptLoader(this); |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | //----------------------------------------------------------------------- |
---|
62 | ColladaManager* ColladaManager::getSingletonPtr(void) |
---|
63 | { |
---|
64 | return ms_Singleton; |
---|
65 | } |
---|
66 | |
---|
67 | //----------------------------------------------------------------------- |
---|
68 | ColladaManager& ColladaManager::getSingleton(void) |
---|
69 | { |
---|
70 | assert( ms_Singleton ); return ( *ms_Singleton ); |
---|
71 | } |
---|
72 | |
---|
73 | //----------------------------------------------------------------------- |
---|
74 | ColladaDocumentPtr ColladaManager::load(const String& daeFileName, SceneManager* sceneMgr, |
---|
75 | NameValuePairList* loadParams, |
---|
76 | const String& group |
---|
77 | ) |
---|
78 | { |
---|
79 | ColladaDocumentPtr daeDoc = ResourceManager::load(daeFileName, group, false, 0, loadParams); |
---|
80 | if (!daeDoc.isNull()) daeDoc->setSceneManager(sceneMgr); |
---|
81 | |
---|
82 | return daeDoc; |
---|
83 | } |
---|
84 | |
---|
85 | //----------------------------------------------------------------------- |
---|
86 | Resource* ColladaManager::createImpl(const String& name, ResourceHandle handle, |
---|
87 | const String& group, bool isManual, ManualResourceLoader* loader, |
---|
88 | const NameValuePairList* params) |
---|
89 | { |
---|
90 | return new ColladaDocument(this, name, handle, group, isManual, loader); |
---|
91 | } |
---|
92 | |
---|
93 | } |
---|