Revision 692,
1.7 KB
checked in by mattausch, 19 years ago
(diff) |
adding ogre 1.2 and dependencies
|
Line | |
---|
1 | #ifndef _MATERIALSET_H
|
---|
2 | #define _MATERIALSET_H
|
---|
3 |
|
---|
4 | #include "singleton.h"
|
---|
5 | #include "material.h"
|
---|
6 | #include "mayaExportLayer.h"
|
---|
7 |
|
---|
8 | namespace OgreMayaExporter
|
---|
9 | {
|
---|
10 | class MaterialSet : public Singleton<MaterialSet>
|
---|
11 | {
|
---|
12 | public:
|
---|
13 | //constructor
|
---|
14 | MaterialSet(){};
|
---|
15 | //destructor
|
---|
16 | ~MaterialSet(){
|
---|
17 | clear();
|
---|
18 | }
|
---|
19 | //clear
|
---|
20 | void clear(){
|
---|
21 | for (int i=0; i<m_materials.size(); i++)
|
---|
22 | delete m_materials[i];
|
---|
23 | m_materials.clear();
|
---|
24 | }
|
---|
25 | //add material
|
---|
26 | void addMaterial(Material* pMat){
|
---|
27 | bool found = false;
|
---|
28 | for (int i=0; i<m_materials.size() && !found; i++)
|
---|
29 | {
|
---|
30 | if (m_materials[i]->name() == pMat->name())
|
---|
31 | {
|
---|
32 | found = true;
|
---|
33 | delete pMat;
|
---|
34 | }
|
---|
35 | }
|
---|
36 | if (!found)
|
---|
37 | m_materials.push_back(pMat);
|
---|
38 | }
|
---|
39 | //get material
|
---|
40 | Material* getMaterial(const MString& name){
|
---|
41 | for (int i=0; i<m_materials.size(); i++)
|
---|
42 | {
|
---|
43 | if (m_materials[i]->name() == name)
|
---|
44 | return m_materials[i];
|
---|
45 | }
|
---|
46 | return NULL;
|
---|
47 | };
|
---|
48 | //get material set
|
---|
49 | static MaterialSet& getSingleton(){
|
---|
50 | assert(ms_Singleton);
|
---|
51 | return (*ms_Singleton);
|
---|
52 | };
|
---|
53 | static MaterialSet* getSingletonPtr(){
|
---|
54 | return ms_Singleton;
|
---|
55 | };
|
---|
56 | //write materials to Ogre XML
|
---|
57 | MStatus writeXML(ParamList ¶ms){
|
---|
58 | MStatus stat;
|
---|
59 | for (int i=0; i<m_materials.size(); i++)
|
---|
60 | {
|
---|
61 | stat = m_materials[i]->writeXML(params);
|
---|
62 | if (MS::kSuccess != stat)
|
---|
63 | {
|
---|
64 | MString msg = "Error writing material ";
|
---|
65 | msg += m_materials[i]->name();
|
---|
66 | msg += ", aborting operation";
|
---|
67 | MGlobal::displayInfo(msg);
|
---|
68 | }
|
---|
69 | }
|
---|
70 | return MS::kSuccess;
|
---|
71 | };
|
---|
72 |
|
---|
73 | protected:
|
---|
74 | std::vector<Material*> m_materials;
|
---|
75 | };
|
---|
76 |
|
---|
77 | template<> MaterialSet* Singleton<MaterialSet>::ms_Singleton = 0;
|
---|
78 |
|
---|
79 | }; //end namespace
|
---|
80 |
|
---|
81 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.