[1985] | 1 | /*************************************************************************** |
---|
| 2 | |
---|
| 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 |
---|
| 6 | |
---|
| 7 | Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes) |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | This program is free software; you can redistribute it and/or modify it under |
---|
| 12 | the terms of the GPL General Public License with runtime exception as published by the Free Software |
---|
| 13 | Foundation; either version 2 of the License, or (at your option) any later |
---|
| 14 | version. |
---|
| 15 | |
---|
| 16 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
| 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
| 18 | FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GPL General Public License with runtime exception along with |
---|
| 21 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
| 22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
| 23 | http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 24 | ----------------------------------------------------------------------------- |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | #ifndef _OGREBULLETCOLLISIONS_CollisionObject_H |
---|
| 28 | #define _OGREBULLETCOLLISIONS_CollisionObject_H |
---|
| 29 | |
---|
| 30 | #include "OgreBulletCollisionsPreRequisites.h" |
---|
| 31 | |
---|
| 32 | #include "OgreBulletCollisionsWorld.h" |
---|
| 33 | |
---|
| 34 | namespace OgreBulletCollisions |
---|
| 35 | { |
---|
| 36 | // ------------------------------------------------------------------------- |
---|
| 37 | /*! |
---|
| 38 | * \brief |
---|
| 39 | * |
---|
| 40 | * Object is the Basic Bullet Collision representation of an Physical thing in |
---|
| 41 | * a scene. It does need a Shape Object to know its "Geometrics" Bounds. |
---|
| 42 | * |
---|
| 43 | * \remarks |
---|
| 44 | * Objects doesn't need to be represented by a Visible 3D mesh. |
---|
| 45 | * |
---|
| 46 | * \see |
---|
| 47 | * Ogre::MovableObject | Ogre::UserDefinedObject | OgreBulletDynamics::RigidBody |
---|
| 48 | */ |
---|
| 49 | class Object : public Ogre::MovableObject, public Ogre::UserDefinedObject |
---|
| 50 | { |
---|
| 51 | public: |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | Object(const Ogre::String &name, CollisionsWorld *world, bool init); |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | virtual ~Object(); |
---|
| 59 | |
---|
| 60 | // override Movables |
---|
| 61 | #if (OGRE_VERSION >= ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0) |
---|
| 62 | void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables); |
---|
| 63 | #endif |
---|
| 64 | virtual const Ogre::String& getMovableType() const; |
---|
| 65 | virtual void _notifyAttached(Ogre::Node* parent,bool isTagPoint = false); |
---|
| 66 | //virtual const Ogre::String& getName(void) const {return mName}; |
---|
| 67 | virtual void _notifyCurrentCamera(Ogre::Camera* camera); |
---|
| 68 | virtual const Ogre::AxisAlignedBox& getBoundingBox(void) const; |
---|
| 69 | virtual Ogre::Real getBoundingRadius(void) const; |
---|
| 70 | virtual void _updateRenderQueue(Ogre::RenderQueue* queue); |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | inline const Ogre::Vector3 &getWorldPosition() const {return mRootNode->_getDerivedPosition();}; |
---|
| 74 | inline const Ogre::Quaternion &getWorldOrientation() const {return mRootNode->_getDerivedOrientation();}; |
---|
| 75 | |
---|
| 76 | inline void setPosition(const Ogre::Vector3 &p) {mRootNode->setPosition (p);}; |
---|
| 77 | inline void setOrientation(const Ogre::Quaternion &q) {return mRootNode->setOrientation (q);}; |
---|
| 78 | |
---|
| 79 | inline void setPosition(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z) {mRootNode->setPosition (x,y,z);}; |
---|
| 80 | inline void setOrientation(const Ogre::Real x, const Ogre::Real y, const Ogre::Real z, const Ogre::Real w) {return mRootNode->setOrientation (x,y,z,w);}; |
---|
| 81 | |
---|
| 82 | virtual void setPosition(const btVector3 &pos); |
---|
| 83 | virtual void setOrientation(const btQuaternion &quat); |
---|
| 84 | virtual void setTransform(const btVector3 &pos, const btQuaternion &quat); |
---|
| 85 | virtual void setTransform(const btTransform& worldTrans); |
---|
| 86 | |
---|
| 87 | inline btCollisionObject* getBulletObject() const { return mObject;}; |
---|
| 88 | inline btCollisionWorld* getBulletCollisionWorld() const { return mWorld->getBulletCollisionWorld ();}; |
---|
| 89 | inline CollisionsWorld* getCollisionWorld() const { return mWorld;}; |
---|
| 90 | |
---|
| 91 | inline CollisionShape *getShape() const{ return mShape;}; |
---|
| 92 | inline DebugCollisionShape* getDebugShape() const{ return mDebugShape;}; |
---|
| 93 | |
---|
| 94 | void setShape(CollisionShape *shape, |
---|
| 95 | const Ogre::Vector3 &pos, |
---|
| 96 | const Ogre::Quaternion &quat); |
---|
| 97 | void showDebugShape(bool show); |
---|
| 98 | |
---|
| 99 | Ogre::SceneNode *getRootNode() { return mRootNode; } |
---|
| 100 | |
---|
| 101 | protected: |
---|
| 102 | |
---|
| 103 | Ogre::SceneNode* mRootNode; |
---|
| 104 | Ogre::SceneNode* mShapeNode; |
---|
| 105 | Ogre::SceneNode* mDebugNode; |
---|
| 106 | |
---|
| 107 | ObjectState * mState; |
---|
| 108 | CollisionsWorld* mWorld; |
---|
| 109 | |
---|
| 110 | btCollisionObject* mObject; |
---|
| 111 | |
---|
| 112 | Ogre::AxisAlignedBox mBounds; |
---|
| 113 | |
---|
| 114 | CollisionShape* mShape; |
---|
| 115 | DebugCollisionShape * mDebugShape; |
---|
| 116 | |
---|
| 117 | public: |
---|
| 118 | static const Ogre::String mMovableType; |
---|
| 119 | }; |
---|
| 120 | // ------------------------------------------------------------------------- |
---|
| 121 | } |
---|
| 122 | #endif //_OGREBULLETCOLLISIONS_CollisionObject_H |
---|
| 123 | |
---|