[2303] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
[2304] | 23 | * Reto Grieder |
---|
[2303] | 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _CollisionShape_H__ |
---|
| 30 | #define _CollisionShape_H__ |
---|
| 31 | |
---|
| 32 | #include "OrxonoxPrereqs.h" |
---|
| 33 | |
---|
[2423] | 34 | #include "LinearMath/btVector3.h" |
---|
[2374] | 35 | #include "util/Math.h" |
---|
| 36 | #include "core/BaseObject.h" |
---|
[2377] | 37 | #include "network/Synchronisable.h" |
---|
[2303] | 38 | |
---|
| 39 | namespace orxonox |
---|
| 40 | { |
---|
[2374] | 41 | class _OrxonoxExport CollisionShape : public BaseObject, public network::Synchronisable |
---|
[2303] | 42 | { |
---|
| 43 | public: |
---|
| 44 | CollisionShape(BaseObject* creator); |
---|
| 45 | virtual ~CollisionShape(); |
---|
| 46 | |
---|
| 47 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[2374] | 48 | void registerVariables(); |
---|
[2303] | 49 | |
---|
[2374] | 50 | inline void setPosition(const Vector3& position) |
---|
[2423] | 51 | { this->position_ = position; this->updateParent(); } |
---|
[2374] | 52 | inline const Vector3& getPosition() const |
---|
| 53 | { return this->position_; } |
---|
[2303] | 54 | |
---|
[2374] | 55 | inline void setOrientation(const Quaternion& orientation) |
---|
[2423] | 56 | { this->orientation_ = orientation; this->updateParent(); } |
---|
[2374] | 57 | inline const Quaternion& getOrientation() const |
---|
| 58 | { return this->orientation_; } |
---|
[2303] | 59 | |
---|
[2423] | 60 | void yaw(const Degree& angle) { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Y)); } |
---|
| 61 | void pitch(const Degree& angle) { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_X)); } |
---|
| 62 | void roll(const Degree& angle) { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Z)); } |
---|
[2374] | 63 | |
---|
| 64 | virtual void setScale3D(const Vector3& scale); |
---|
| 65 | virtual void setScale(float scale); |
---|
| 66 | inline const Vector3& getScale3D(void) const |
---|
| 67 | { return this->scale_; } |
---|
| 68 | |
---|
[2423] | 69 | btVector3 getLocalInertia(float mass) const; |
---|
| 70 | |
---|
| 71 | inline btCollisionShape* getCollisionShape() const |
---|
[2374] | 72 | { return this->collisionShape_; } |
---|
| 73 | |
---|
| 74 | bool hasTransform() const; |
---|
| 75 | |
---|
| 76 | inline void setParent(CompoundCollisionShape* shape, unsigned int ID) |
---|
| 77 | { this->parent_ = shape; this->parentID_ = ID; } |
---|
| 78 | |
---|
[2303] | 79 | protected: |
---|
[2423] | 80 | virtual void updateParent(); |
---|
[2303] | 81 | |
---|
[2423] | 82 | btCollisionShape* collisionShape_; |
---|
| 83 | CompoundCollisionShape* parent_; |
---|
| 84 | |
---|
[2303] | 85 | private: |
---|
[2423] | 86 | void parentChanged(); |
---|
[2306] | 87 | |
---|
[2423] | 88 | Vector3 position_; |
---|
| 89 | Quaternion orientation_; |
---|
| 90 | Vector3 scale_; |
---|
| 91 | unsigned int parentID_; |
---|
[2303] | 92 | }; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | #endif /* _CollisionShape_H__ */ |
---|