MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cylindercollisionshape.h
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _physicscylindercollisionshape_h
41 #define _physicscylindercollisionshape_h
42 
43 #include "Physics/primitivecollisionshape.h"
44 
45 class btCylinderShape;
46 
47 namespace Mezzanine
48 {
49  namespace Physics
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @class CylinderCollisionShape
53  /// @headerfile collisionshape.h
54  /// @brief A cylinder physics shape.
55  /// @details A primitive cylinder shape. Like Capsules and Cones Cylinders can be
56  /// aligned to any of the 3 linear axes(X, Y, or Z).
57  ///////////////////////////////////////
59  {
60  protected:
61  /// @internal
62  /// @brief Does the initialization for a Cylinder
63  /// @param Name The name of the shape to initialize
64  /// @param HalfExtents This of the shape to initialize
65  /// @param UpAxis which direction gets the flat 'top' of the cylinder perpendicular ot it.
66  void Construct(const String& Name, const Vector3& HalfExtents, StandardAxis UpAxis);
67 
68  /// @internal
69  /// @brief Does the initialization for a Cylinder
70  /// @param Name The name of the shape to initialize
71  /// @param BulletShape A pointer to a valid fully constructed internal Collision shape.
72  void Construct(const String& Name, btCylinderShape* BulletShape);
73 
74  public:
75  /// @brief Verbose Vector Constructor.
76  /// @param Name The name of this Shape.
77  /// @param Radius The radius of the Cylinder.
78  /// @param Height The height of the Cylinder, Height is indicated in the direction of the upAxis.
79  /// @param UpAxis Which axis the cylinder is to be oriented along. Typical usage is for
80  /// a capsule to be oriented on the Y axis(0,1,0), which would make it stand upright.
81  CylinderCollisionShape(const String& Name, const Real& Radius, const Real& Height, const Vector3& UpAxis);
82  /// @brief Verbose Constructor.
83  /// @param Name The name of this Shape.
84  /// @param Radius The radius of the Cylinder.
85  /// @param Height The height of the Cylinder, Height is indicated in the direction of the upAxis.
86  /// @param UpAxis Which StandardAxis the cylinder is to be oriented along.
87  CylinderCollisionShape(const String& Name, const Real& Radius, const Real& Height, StandardAxis UpAxis);
88  /// @brief Terse Vector Constructor.
89  /// @param Name The name of this Shape.
90  /// @param HalfExtents A Vector3 with the Height of the cylinder on the axis corresponding to the UpAxis and the Radius store in the other two axis.
91  /// @param UpAxis Which axis the cylinder is to be oriented along. Typical usage is for
92  /// a capsule to be oriented on the Y axis(0,1,0), which would make it stand upright.
93  CylinderCollisionShape(const String& Name, const Vector3& HalfExtents, const Vector3& UpAxis);
94  /// @brief Terse Constructor.
95  /// @param Name The name of this Shape.
96  /// @param HalfExtents A Vector3 with the Height of the cylinder on the axis corresponding to the UpAxis and the Radius store in the other two axis.
97  /// @param UpAxis Which StandardAxis the cylinder is to be oriented along.
98  CylinderCollisionShape(const String& Name, const Vector3& HalfExtents, StandardAxis UpAxis);
99  /// @internal
100  /// @brief Internal Constructor.
101  /// @param Name The name of this Shape.
102  /// @param BulletShape The internal shape this shape is based on.
103  CylinderCollisionShape(const String& Name, btCylinderShape* BulletShape);
104  /// @copydoc BoxCollisionShape::BoxCollisionShape(XML::Node OneNode)
106  /// @brief Class Destructor.
107  virtual ~CylinderCollisionShape();
108 
109  /// @brief A (very) simple way to create a Vector3 containing the Half Extents of a Cylinder with given dimenions/
110  /// @param Radius The radius of the Cylinder.
111  /// @param Height The height of the Cylinder, Height is indicated in the direction of the upAxis.
112  /// @param UpAxis Which StandardAxis the cylinder is to be oriented along.
113  static Vector3 CreateHalfExtents(const Real& Radius, const Real& Height, StandardAxis UpAxis);
114  /// @brief Gets the half extents used to construct this cylinder.
115  /// @return Returns a vector3 containing the half extents of this cylinder.
116  virtual Vector3 GetHalfExtents() const;
117  /// @brief Gets the half extents with padding.
118  /// @return Returns a vector3 containing the half extents with the margin added to each axis.
119  virtual Vector3 GetHalfExtentsWithMargin() const;
120  /// @brief Gets the radius of the cylinder.
121  /// @return Returns a real representing the radius at the base of the cylinder.
122  virtual Real GetRadius() const;
123  /// @brief Gets which axis this cylinder is oriented along.
124  /// @return Returns a Vector3 representing which local axis is oriented along the world up axis.
125  virtual Vector3 GetUpAxis() const;
126  /// @copydoc CollisionShape::GetType()
127  virtual CollisionShape::ShapeType GetType() const;
128  /// @copydoc CollisionShape::GetBulletShape
129  virtual btCylinderShape* GetBulletCylinderShape() const;
130 
131  /// @copydoc CollisionShape::GetBulletShape
132  virtual void ProtoSerialize(XML::Node& CurrentRoot) const;
133  /// @copydoc CollisionShape::GetBulletShape
134  virtual void ProtoDeSerialize(const XML::Node& OneNode);
135  /// @brief Get the name of the the XML tag this class will leave behind as its instances are serialized.
136  /// @return A string containing "CylinderCollisionShape"
137  static String SerializableName();
138  };// ©ylinderCollisionShape
139  }//Physics
140 }//Mezzanine
141 
142 /// @copydoc operator << (std::ostream& stream, const Mezzanine::Physics::CollisionShape& ShapeToSerialize)
143 std::ostream& MEZZ_LIB operator << (std::ostream& stream, const Mezzanine::Physics::CylinderCollisionShape& ShapeToSerialize);
144 /// @copydoc operator >> (std::istream& stream, Mezzanine::Physics::CollisionShape& x)
145 std::istream& MEZZ_LIB operator >> (std::istream& stream, Mezzanine::Physics::CylinderCollisionShape& x);
146 /// @copydoc operator >> (const Mezzanine::XML::Node& OneNode, Mezzanine::Physics::CollisionShape& x)
147 void MEZZ_LIB operator >> (const Mezzanine::XML::Node& OneNode, Mezzanine::Physics::CylinderCollisionShape& x);
148 
149 #endif