1 | |
---|
2 | #include "BBCManager.h" |
---|
3 | |
---|
4 | namespace BBC { |
---|
5 | |
---|
6 | template <> BBCManager* CSingleton<BBCManager>::ms_Singleton = NULL; |
---|
7 | |
---|
8 | BBCManager* BBCManager::getSingletonPtr(void) |
---|
9 | { |
---|
10 | return ms_Singleton; |
---|
11 | } |
---|
12 | |
---|
13 | BBCManager& BBCManager::getSingleton(void) |
---|
14 | { |
---|
15 | assert( ms_Singleton ); return ( *ms_Singleton ); |
---|
16 | } |
---|
17 | |
---|
18 | BBCManager::BBCManager() |
---|
19 | { |
---|
20 | } |
---|
21 | |
---|
22 | BBCManager::~BBCManager() |
---|
23 | { |
---|
24 | |
---|
25 | } |
---|
26 | |
---|
27 | void BBCManager::shutdown() |
---|
28 | { |
---|
29 | } |
---|
30 | |
---|
31 | void BBCManager::initialize() |
---|
32 | { |
---|
33 | } |
---|
34 | |
---|
35 | Ogre::Mesh* BBCManager::loadMesh(Ogre::String folderName, Ogre::String fileName) |
---|
36 | { |
---|
37 | //std::ifstream ifs;
|
---|
38 | //ifs.open(Ogre::String(folderName + fileName).c_str(), std::ios_base::in | std::ios_base::binary);
|
---|
39 | //Ogre::DataStreamPtr stream(new Ogre::FileStreamDataStream(folderName + fileName, &ifs, false));
|
---|
40 | //Ogre::MeshPtr mesh = OBA::OgreBase::getSingleton().getMeshManager()->create(fileName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
---|
41 | //OBA::OgreBase::getSingleton().getMeshSerializer()->importMesh(stream, mesh.getPointer()); |
---|
42 | |
---|
43 | Ogre::ResourceGroupManager::getSingleton().addResourceLocation(folderName, "FileSystem", fileName, false);
|
---|
44 |
|
---|
45 | Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(fileName, fileName);
|
---|
46 | |
---|
47 | return mesh.getPointer(); |
---|
48 | } |
---|
49 | |
---|
50 | Ogre::Mesh* BBCManager::loadXMLMesh(Ogre::String name) |
---|
51 | { |
---|
52 | Ogre::MeshPtr newMesh = Ogre::MeshManager::getSingleton().createManual(name.substr(0,((name.size()-1)-4)),Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); |
---|
53 | |
---|
54 | Ogre::VertexElementType colourElementType; |
---|
55 | if (true) |
---|
56 | { |
---|
57 | // DirectX Colour Format |
---|
58 | colourElementType = Ogre::VET_COLOUR_ARGB; |
---|
59 | } |
---|
60 | else |
---|
61 | { |
---|
62 | // OpenGL Colour Format |
---|
63 | colourElementType = Ogre::VET_COLOUR_ABGR; |
---|
64 | } |
---|
65 | |
---|
66 | OBA::OgreBase::getSingleton().getXMLMeshSerializer()->importMesh(name, colourElementType, newMesh.getPointer()); |
---|
67 | |
---|
68 | return newMesh.getPointer(); |
---|
69 | } |
---|
70 | |
---|
71 | void BBCManager::saveMesh(Ogre::String name) |
---|
72 | { |
---|
73 | Ogre::MeshPtr meshPtr = Ogre::MeshManager::getSingleton().getByName(name); |
---|
74 | OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(meshPtr.getPointer(),name); |
---|
75 | } |
---|
76 | |
---|
77 | void BBCManager::saveXMLMesh(Ogre::String name) |
---|
78 | { |
---|
79 | Ogre::MeshPtr meshPtr = Ogre::MeshManager::getSingleton().getByName(name); |
---|
80 | OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(meshPtr.getPointer(),name + ".xml"); |
---|
81 | } |
---|
82 | |
---|
83 | void BBCManager::saveMaterial(Ogre::String materialName) |
---|
84 | { |
---|
85 | Ogre::ResourceManager::ResourceMapIterator it = Ogre::MaterialManager::getSingleton().getResourceIterator();
|
---|
86 | while (it.hasMoreElements())
|
---|
87 | {
|
---|
88 | Ogre::MaterialPtr m = it.getNext();
|
---|
89 |
|
---|
90 | if (m->getName() == materialName)
|
---|
91 | {
|
---|
92 | OBA::OgreBase::getSingleton().getMaterialSerializer()->queueForExport(m);
|
---|
93 | break;
|
---|
94 | }
|
---|
95 | }
|
---|
96 | //OBA::OgreBase::getSingleton().getMaterialSerializer()->exportQueued(dest);
|
---|
97 | } |
---|
98 | |
---|
99 | } |
---|