Orxonox  0.0.5 Codename: Arcturus
BoxCollisionShape.h
Go to the documentation of this file.
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 
35 #ifndef _BoxCollisionShape_H__
36 #define _BoxCollisionShape_H__
37 
38 #include "objects/ObjectsPrereqs.h"
39 
40 #include "util/Math.h"
42 
43 namespace orxonox
44 {
45 
57  {
58  public:
59  BoxCollisionShape(Context* context);
60 
61  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
62 
70  inline bool setHalfExtents(const Vector3& extents)
71  { if(this->halfExtents_ == extents) return false; this->halfExtents_ = extents; updateShape(); return true; }
76  inline const Vector3& getHalfExtents() const
77  { return halfExtents_;}
78 
85  inline bool setWidth(float value)
86  { if(this->halfExtents_.z == value/2.0f) return false; this->halfExtents_.z = value / 2.0f; updateShape(); return true; }
91  inline float getWidth() const
92  { return this->halfExtents_.z * 2.0f; }
93 
100  inline bool setHeight(float value)
101  { if(this->halfExtents_.y == value/2.0f) return false; this->halfExtents_.y = value / 2.0f; updateShape(); return true; }
106  inline float getHeight() const
107  { return this->halfExtents_.y * 2.0f; }
108 
115  inline bool setLength(float value)
116  { if(this->halfExtents_.x == value/2.0f) return false; this->halfExtents_.x = value / 2.0f; updateShape(); return true; }
121  inline float getLength() const
122  { return this->halfExtents_.x * 2.0f; }
123 
124  virtual void changedScale(); // Is called when the scale of the BoxCollisionShape has changed.
125 
126  private:
127  void registerVariables();
128 
129  btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the BoxCollisionShape.
130 
131  Vector3 halfExtents_;
132  };
133 }
134 
135 #endif /* _BoxCollisionShape_H__ */
#define _ObjectsExport
Definition: ObjectsPrereqs.h:60
float getLength() const
Get the length of the BoxCollisionShape.
Definition: BoxCollisionShape.h:121
bool setLength(float value)
Set the length of the BoxCollisionShape.
Definition: BoxCollisionShape.h:115
xmlelement
Definition: Super.h:519
Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the ...
float getWidth() const
Get the width of the BoxCollisionShape.
Definition: BoxCollisionShape.h:91
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
bool setHalfExtents(const Vector3 &extents)
Set the half extents of the BoxCollisionShape.
Definition: BoxCollisionShape.h:70
Definition of the CollisionShape class.
Definition: Context.h:45
Shared library macros, enums, constants and forward declarations for the objects module ...
Wrapper for bullet collision shape class btCollisionShape.
Definition: CollisionShape.h:57
float getHeight() const
Get the height of the BoxCollisionShape.
Definition: BoxCollisionShape.h:106
bool setWidth(float value)
Set the width of the BoxCollisionShape.
Definition: BoxCollisionShape.h:85
bool setHeight(float value)
Set the height of the BoxCollisionShape.
Definition: BoxCollisionShape.h:100
const Vector3 & getHalfExtents() const
Get the half extents of the BoxCollisionShape.
Definition: BoxCollisionShape.h:76
Wrapper for the bullet box collision shape class btBoxShape.
Definition: BoxCollisionShape.h:56
Vector3 halfExtents_
The half extents of the BoxCollisionShape. The x-component is half the length, the y-component is hal...
Definition: BoxCollisionShape.h:131