1 | #ifndef _OGREODEENTITYINFORMER_H_ |
---|
2 | #define _OGREODEENTITYINFORMER_H_ |
---|
3 | |
---|
4 | #include "OgreOdePreReqs.h" |
---|
5 | #include "OgreOdeTriangleMeshData.h" |
---|
6 | |
---|
7 | namespace OgreOde |
---|
8 | { |
---|
9 | class _OgreOdeExport EntityInformer |
---|
10 | { |
---|
11 | public: |
---|
12 | EntityInformer(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY); |
---|
13 | EntityInformer(); |
---|
14 | ~EntityInformer(); |
---|
15 | |
---|
16 | void addEntity(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY); |
---|
17 | // Cannot be animated. |
---|
18 | void addMesh(const Ogre::MeshPtr &mesh, const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY); |
---|
19 | |
---|
20 | Ogre::Real getRadius(); |
---|
21 | Ogre::Vector3 getSize(); |
---|
22 | Ogre::Vector3 getCenter(); |
---|
23 | |
---|
24 | Body* createSingleDynamicSphere(Ogre::Real mass, World *world, Space* space = 0); |
---|
25 | Body* createSingleDynamicBox(Ogre::Real mass, World *world, Space* space = 0); |
---|
26 | |
---|
27 | TriangleMeshGeometry* createStaticTriangleMesh(World *world, Space* space = 0); |
---|
28 | BoxGeometry* createSingleStaticBox(World *world, Space* space = 0); |
---|
29 | |
---|
30 | CapsuleGeometry* createOrientedCapsule(unsigned char bone, World *world, Space* space = 0); |
---|
31 | BoxGeometry* createOrientedBox(unsigned char bone, World *world, Space* space = 0); |
---|
32 | BoxGeometry* createAlignedBox(unsigned char bone, World *world, Space* space = 0); |
---|
33 | |
---|
34 | const Ogre::Vector3* getVertices(); |
---|
35 | unsigned int getVertexCount(); |
---|
36 | const TriangleIndex* getIndices(); |
---|
37 | unsigned int getIndexCount(); |
---|
38 | |
---|
39 | protected: |
---|
40 | void addVertexData(const Ogre::VertexData *vertex_data, |
---|
41 | const Ogre::VertexData *blended_data = 0, |
---|
42 | const Ogre::Mesh::IndexMap *indexMap = 0); |
---|
43 | void addIndexData(Ogre::IndexData *data, const unsigned int offset = 0); |
---|
44 | bool getBoneVertices(unsigned char bone,unsigned int &vertex_count, Ogre::Vector3* &vertices); |
---|
45 | |
---|
46 | Ogre::Entity* _entity; |
---|
47 | Ogre::SceneNode* _node; |
---|
48 | Ogre::Matrix4 _transform; |
---|
49 | |
---|
50 | Ogre::Real _radius; |
---|
51 | Ogre::Vector3 _size; |
---|
52 | Ogre::Vector3 _center; |
---|
53 | |
---|
54 | Ogre::Vector3* _vertices; |
---|
55 | TriangleIndex* _indices; |
---|
56 | unsigned int _vertex_count; |
---|
57 | unsigned int _index_count; |
---|
58 | |
---|
59 | BoneMapping *_bone_mapping; |
---|
60 | }; |
---|
61 | |
---|
62 | /** Class may create a TriangleMeshDataPtr, store and reuses it with TriangleMeshDataManager. |
---|
63 | This can limit the number of instances of the mesh data at a given scale to one. |
---|
64 | Since TriangleMeshGeometry is created using TriangleMeshDataPtr, have the advantage that |
---|
65 | the TriangleMeshDataPtr can be changed without having to recreate the TriangleMeshGeometry see |
---|
66 | TriangleMeshGeometry::changeTriangleMeshData(). |
---|
67 | When TriangleMeshGeometry is created it is created at the origin with an identity orientation. |
---|
68 | */ |
---|
69 | class _OgreOdeExport EntityInformerReuse : public EntityInformer |
---|
70 | { |
---|
71 | |
---|
72 | public: |
---|
73 | |
---|
74 | /** forceRecreate will force the creation of a TriangleMeshDataPtr, use only when the mesh has undergone some change |
---|
75 | */ |
---|
76 | EntityInformerReuse(Ogre::Entity *entity, const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE, bool forceRecreate = false); |
---|
77 | EntityInformerReuse(const Ogre::MeshPtr &mesh, const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE, bool forceRecreate = false); |
---|
78 | |
---|
79 | ~EntityInformerReuse(); |
---|
80 | |
---|
81 | /** Creates TriangleMeshGeometry using TriangleMeshDataPtr |
---|
82 | */ |
---|
83 | TriangleMeshGeometry* createStaticTriangleMesh(World *world, Space* space = 0); |
---|
84 | |
---|
85 | /** Recreates any TriangleMeshGeometry with the TriangleMeshDataPtr |
---|
86 | */ |
---|
87 | TriangleMeshGeometry* recreateStaticTriangleMesh(TriangleMeshGeometry* geom); |
---|
88 | |
---|
89 | /** Shouldn't be adding Entity or Mesh, one TriangleMeshData per Mesh/Entity for any scale. |
---|
90 | */ |
---|
91 | virtual void addEntity(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY){} |
---|
92 | virtual void addMesh(const Ogre::MeshPtr &mesh, const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY){} |
---|
93 | |
---|
94 | TriangleMeshDataPtr getTriangleMeshDataPtr(){ return _dataPtr; } |
---|
95 | |
---|
96 | protected: |
---|
97 | |
---|
98 | TriangleMeshDataPtr _dataPtr; |
---|
99 | |
---|
100 | }; |
---|
101 | |
---|
102 | } |
---|
103 | |
---|
104 | #endif |
---|
105 | |
---|
106 | |
---|