Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogreode/prefab/include/OgreOdeRagdoll.h @ 21

Last change on this file since 21 was 21, checked in by nicolasc, 16 years ago

added ogreode and Colladaplugin

File size: 3.8 KB
Line 
1#ifndef _OGREODERAGDOLL_H_
2#define _OGREODERAGDOLL_H_
3
4#include "OgreOde_Prefab.h"
5
6#include <map>
7
8namespace OgreOde_Prefab
9{
10
11    class _OgreOdeExport_Prefab Ragdoll : public Object, public Ogre::Entity, public OgreOde::CollisionListener
12    {
13
14        friend class RagdollFactory;
15
16    public:
17        class PhysicalBone;
18        typedef std::vector<Ragdoll::PhysicalBone*> RagdollPhysicalBoneList;
19
20    public:
21                class _OgreOdeExport_Prefab PhysicalBone
22                {
23                public:
24                        PhysicalBone();
25                        ~PhysicalBone();
26
27                public:
28                        OgreOde::Body                                                           *_body;
29                        OgreOde::Geometry                                                       *_geometry;
30                        Ogre::Vector3                                           _original_position;
31                        Ogre::Quaternion                                        _original_orientation;
32                        Ogre::Bone                                                      *_bone;
33                        PhysicalBone                                            *_parent_bone;
34                        RagdollPhysicalBoneList             _child_bones;
35                        OgreOde::Joint                                                          *_joint;
36                        OgreOde::AngularMotorJoint                                      *_motor;
37                };
38
39                class _OgreOdeExport_Prefab BoneSettings
40                {
41                public:
42                        enum Collapse
43                        {
44                                Collapse_None,
45                                Collapse_Up,
46                                Collapse_Down
47                        };
48
49                public:
50                        BoneSettings();
51                        ~BoneSettings();
52
53                public:
54                        OgreOde::Geometry::Class                _geometry_class;
55                        OgreOde::Joint::Type                    _joint_type;
56                        Ogre::Vector3           _primary_axis;
57                        Ogre::Vector3           _secondary_axis;
58                        Collapse                        _collapse;
59                        Ogre::Real                      _mass;
60                        Ogre::Real                      _radius;
61                        Ogre::Real                      _primary_histop,_primary_lostop,_secondary_histop,_secondary_lostop;
62                        Ogre::Real                      _linear_damping,_angular_damping;
63                };
64
65        public:
66                void setDefaultBoneSettings(const Ragdoll::BoneSettings &settings);
67                const Ragdoll::BoneSettings &getDefaultBoneSettings(){return _default_bone_settings;}
68               
69                void setBoneSettings(const Ogre::String& bone_name,const Ragdoll::BoneSettings &settings);
70                void setSelfCollisions(bool collide);
71
72        void takePhysicalControl(OgreOde::World* world, OgreOde::Space* space, bool static_geometry = false);
73                void turnToStone();
74
75                void sleep();
76                void sleep(Ragdoll::PhysicalBone* bone);
77
78                void wake();
79                void wake(Ragdoll::PhysicalBone* bone);
80
81                bool isAwake();
82                bool isAwake(Ragdoll::PhysicalBone* bone);
83
84                void releasePhysicalControl();
85
86                bool isPhysical()const {return _is_physical;}
87                bool isStatic()const {return _is_static;}
88
89                ~Ragdoll();
90
91                void update();
92
93        virtual const Ogre::AxisAlignedBox& getBoundingBox(void) const;
94
95                bool pick(OgreOde::RayGeometry *ray, OgreOde::Body* &body, Ogre::Vector3 &position);
96                bool collision(OgreOde::Contact* contact);
97
98
99        protected:
100
101                Ragdoll(const Ogre::String& name, Ogre::MeshPtr& ptr); 
102
103                void createBoneBody(Ogre::Bone *bone, Ragdoll::PhysicalBone *parent, bool static_geometry);
104                void updatePhysicalBone(Ragdoll::PhysicalBone *physical_bone, const Ogre::Matrix4 &this_trans, const Ogre::Matrix4 &base_trans);
105
106                void turnToStone(Ragdoll::PhysicalBone* bone);
107                void releasePhysicalControl(Ragdoll::PhysicalBone* bone);
108
109                void pick(Ragdoll::PhysicalBone *bone, OgreOde::RayGeometry *ray);
110
111                RagdollPhysicalBoneList _root_bones;
112                Ragdoll::BoneSettings _default_bone_settings;
113                std::map<Ogre::String, Ragdoll::BoneSettings> _bone_settings;
114                Ogre::Matrix4 _node_trans,_node_trans_inv;
115                Ogre::Quaternion _node_orient;
116                Ogre::Vector3 _node_posn;
117
118                std::vector<std::pair<OgreOde::Body*,Ogre::Vector3> > _hit_list;
119
120                OgreOde::EntityInformer *_ei;
121                OgreOde::SimpleSpace    *_space;
122        OgreOde::JointGroup     *_joint_group;
123
124                bool    _is_static;
125                bool    _is_physical;
126        bool    _is_hardwareAnimationRemovedByMe;
127
128        };
129
130        /** Factory object for creating Ragdoll instances */
131        class _OgreOdeExport_Prefab RagdollFactory : public Ogre::MovableObjectFactory
132        {
133        protected:
134                Ogre::MovableObject* createInstanceImpl( const Ogre::String& name, const Ogre::NameValuePairList* params);
135        public:
136                RagdollFactory() {}
137                ~RagdollFactory() {}
138
139                static Ogre::String FACTORY_TYPE_NAME;
140
141                const Ogre::String& getType(void) const;
142                void destroyInstance( Ogre::MovableObject* obj); 
143
144        }; 
145}
146
147#endif
Note: See TracBrowser for help on using the repository browser.