1 /***************************************************************************
3 This source file is part of OGREBULLET
4 (Object-oriented Graphics Rendering Engine Bullet Wrapper)
5 For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
7 Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 -----------------------------------------------------------------------------
31 #ifndef _OGREBULLETDYNAMICS_Character_H
32 #define _OGREBULLETDYNAMICS_Character_H
34 #include "OgreBulletDynamicsPreRequisites.h"
36 #include "OgreBulletCollisionsObject.h"
37 #include "OgreBulletCollisionsWorld.h"
38 #include "BulletDynamics/Character/btKinematicCharacterController.h"
39 #include "BulletCollision/CollisionDispatch/btGhostObject.h"
40 #include "Utils/OgreBulletConverter.h"
42 #include "OgreBulletDynamicsWorld.h"
44 namespace OgreBulletDynamics
46 // -------------------------------------------------------------------------
47 // basic character controller class
48 class _OgreBulletExport CharacterController : public OgreBulletCollisions::Object
51 CharacterController(const Ogre::String &name,
53 Ogre::SceneNode *node);
55 virtual ~CharacterController();
58 void removeFromWorld();
59 void setLinearVelocity(const Ogre::Vector3 &vel);
60 void setLinearVelocity(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z);
61 Ogre::Vector3 getLinearVelocity();
62 void setAngularVelocity(const Ogre::Vector3 &vel);
63 void setAngularVelocity(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z);
64 Ogre::Vector3 getAngularVelocity();
65 void setAngularFactor(const Ogre::Vector3 &vel);
66 void setAngularFactor(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z);
67 Ogre::Vector3 getAngularFactor();
68 void applyImpulse(const Ogre::Vector3 &impulse, const Ogre::Vector3 &position);
69 void applyForce(const Ogre::Vector3 &impulse, const Ogre::Vector3 &position);
70 void setSleepingThresholds( const Ogre::Real linear, const Ogre::Real angular );
71 void setGravity(const Ogre::Vector3 &gravity);
72 Ogre::Vector3 getGravity();
75 inline btRigidBody* getBulletRigidBody() const;
76 inline btDynamicsWorld* getBulletDynamicsWorld() const;
77 inline DynamicsWorld* getDynamicsWorld();
79 Ogre::SceneNode* getSceneNode() const {return mRootNode;};
81 inline void disableDeactivation();
82 inline void enableActiveState ();
83 inline void forceActivationState();
84 void setDeactivationTime(const float ftime);
86 inline const btTransform &getCenterOfMassTransform() const;
87 inline Ogre::Quaternion getCenterOfMassOrientation () const;
88 inline Ogre::Vector3 getCenterOfMassPosition() const;
90 Ogre::Vector3 getCenterOfMassPivot (const Ogre::Vector3 &pivotPosition) const;
92 void setDamping( const Ogre::Real linearDamping, const Ogre::Real angularDamping );
94 short mCollisionGroup;
97 btKinematicCharacterController *m_character;
99 // -------------------------------------------------------------------------
100 // basic rigid body class inline methods
101 // -------------------------------------------------------------------------
102 /*inline btRigidBody* RigidBody::getBulletRigidBody() const
104 return static_cast <btRigidBody* > (mObject);
106 // -------------------------------------------------------------------------
107 inline btDynamicsWorld* CharacterController::getBulletDynamicsWorld() const
109 return static_cast <btDynamicsWorld * > (mWorld->getBulletCollisionWorld ());
111 // -------------------------------------------------------------------------
112 inline DynamicsWorld* CharacterController::getDynamicsWorld()
114 return static_cast <DynamicsWorld* > (mWorld);
118 #endif //_OGREBULLETDYNAMICS_Character_H