Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics_merge/src/orxonox/objects/collisionshapes/CollisionShape.h @ 2442

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

Finally merged physics stuff. Target is physics_merge because I'll have to do some testing first.

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
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:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _CollisionShape_H__
30#define _CollisionShape_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "LinearMath/btVector3.h"
35#include "util/Math.h"
36#include "core/BaseObject.h"
37#include "network/synchronisable/Synchronisable.h"
38
39namespace orxonox
40{
41    class _OrxonoxExport CollisionShape : public BaseObject, public Synchronisable
42    {
43        public:
44            CollisionShape(BaseObject* creator);
45            virtual ~CollisionShape();
46
47            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
48            void registerVariables();
49
50            inline void setPosition(const Vector3& position)
51                { this->position_ = position; this->updateParent(); }
52            inline const Vector3& getPosition() const
53                { return this->position_; }
54
55            inline void setOrientation(const Quaternion& orientation)
56                { this->orientation_ = orientation; this->updateParent(); }
57            inline const Quaternion& getOrientation() const
58                { return this->orientation_; }
59
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)); }
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
69            btVector3 getLocalInertia(float mass) const;
70
71            inline btCollisionShape* getCollisionShape() const
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
79        protected:
80            virtual void updateParent();
81
82            btCollisionShape*       collisionShape_;
83            CompoundCollisionShape* parent_;
84
85        private:
86            void parentChanged();
87
88            Vector3                 position_;
89            Quaternion              orientation_;
90            Vector3                 scale_;
91            unsigned int            parentID_;
92    };
93}
94
95#endif /* _CollisionShape_H__ */
Note: See TracBrowser for help on using the repository browser.