Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics_new/src/ogreode/OgreOdeEntityInformer.h @ 2119

Last change on this file since 2119 was 2119, checked in by rgrieder, 15 years ago

Merged physics branch into physics_new branch.

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