1 | #ifndef __OgreOdeTriangleMeshDataManager_H__ |
---|
2 | #define __OgreOdeTriangleMeshDataManager_H__ |
---|
3 | |
---|
4 | #include "OgreOdePreReqs.h" |
---|
5 | |
---|
6 | #include <map> |
---|
7 | #include <OgreSingleton.h> |
---|
8 | #include <OgreVector3.h> |
---|
9 | |
---|
10 | namespace OgreOde |
---|
11 | { |
---|
12 | |
---|
13 | /** Each time a new TriangleMeshData is created it is added to this mananger, in TriangleMeshData's |
---|
14 | destructor it is removed from the manager |
---|
15 | */ |
---|
16 | class TriangleMeshDataManager : public Ogre::Singleton<TriangleMeshDataManager> |
---|
17 | { |
---|
18 | |
---|
19 | protected: |
---|
20 | |
---|
21 | struct vectorLess { |
---|
22 | bool operator()(const Ogre::Vector3& a, const Ogre::Vector3& b) const |
---|
23 | { |
---|
24 | if (a.x < b.x) return true; |
---|
25 | if (a.x > b.x) return false; |
---|
26 | if (a.y < b.y) return true; |
---|
27 | if (a.y > b.y) return false; |
---|
28 | return a.z < b.z; |
---|
29 | } |
---|
30 | }; |
---|
31 | |
---|
32 | public: |
---|
33 | |
---|
34 | typedef std::map<Ogre::String, std::map<Ogre::Vector3, TriangleMeshDataPtr, vectorLess > > TriangleMeshDataPtrMap; |
---|
35 | |
---|
36 | /** |
---|
37 | */ |
---|
38 | TriangleMeshDataManager(); |
---|
39 | |
---|
40 | /** |
---|
41 | */ |
---|
42 | virtual ~TriangleMeshDataManager(); |
---|
43 | |
---|
44 | /** |
---|
45 | */ |
---|
46 | static TriangleMeshDataManager* getSingletonPtr(); |
---|
47 | |
---|
48 | /** |
---|
49 | */ |
---|
50 | static TriangleMeshDataManager& getSingleton(); |
---|
51 | |
---|
52 | /** |
---|
53 | */ |
---|
54 | void addTriangleMeshData(const Ogre::String& name, TriangleMeshDataPtr shape, Ogre::Vector3 scale); |
---|
55 | |
---|
56 | /** |
---|
57 | */ |
---|
58 | void removeTriangleMeshData(const Ogre::String& name, Ogre::Vector3 scale); |
---|
59 | |
---|
60 | /** |
---|
61 | */ |
---|
62 | TriangleMeshDataPtr getTriangleMeshData(const Ogre::String& name, Ogre::Vector3 scale); |
---|
63 | |
---|
64 | /** |
---|
65 | */ |
---|
66 | const TriangleMeshDataPtrMap getTriangleMeshDataPtrMap(){ return mTriangleMeshDataMap; } |
---|
67 | |
---|
68 | protected: |
---|
69 | |
---|
70 | // mesh name, scale, TriangleMeshDataPtr |
---|
71 | TriangleMeshDataPtrMap mTriangleMeshDataMap; |
---|
72 | |
---|
73 | }; |
---|
74 | } |
---|
75 | |
---|
76 | #endif //__OgreOdeTriangleMeshDataManager_H__ |
---|
77 | |
---|
78 | |
---|