Spinning Topp Logo BlackTopp Studios
inc
bone.h
1 // © Copyright 2010 - 2016 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 _graphicsbone_h
41 #define _graphicsbone_h
42 
43 #include "transformableobject.h"
44 
45 namespace Ogre
46 {
47  class Bone;
48 }
49 
50 namespace Mezzanine
51 {
52  namespace Graphics
53  {
54  class Skeleton;
55  ///////////////////////////////////////////////////////////////////////////////
56  /// @brief This class encapsulates the bones contained in a skeleton used for animation.
57  /// @details
58  ///////////////////////////////////////
60  {
61  protected:
62  friend class Skeleton;
63  /// @internal
64  /// @brief The pointer to the internal Bone this is based on.
65  Ogre::Bone* GraphicsBone;
66  /// @internal
67  /// @brief The host skeleton this bone belongs to.
69  //public:
70  /// @internal
71  /// @brief Internal constructor.
72  /// @param HostSkel The parent skeleton this bone blongs to.
73  /// @param InternalBone The internal bone this Bone is based on.
74  Bone(Skeleton* HostSkel, Ogre::Bone* InternalBone);
75  /// @brief Class destructor.
76  ~Bone();
77  public:
78  ///////////////////////////////////////////////////////////////////////////////
79  // Utility Methods
80 
81  /// @brief Gets the host skeleton this bone belongs to.
82  /// @return Returns a pointer to the parent skeleton.
83  Skeleton* GetHost() const;
84  /// @brief Gets the name of this Bone.
85  /// @return Returns a const reference to a string containing the name of this bone.
86  const String& GetName() const;
87  /// @brief Gets the unique identifying number belonging to this bone.
88  /// @return Returns a UInt16 representing the identifier unique to this bone within it's parent skeleton.
89  UInt16 GetHandle() const;
90  /// @brief Sets whether or not this bone is to be manually controlled.
91  /// @param Manual True to allow this bone to be explicitly altered, false to make it only accept animation updates.
92  void SetManuallyControlled(Boole Manual);
93  /// @brief Gets whether or not this bone is being manually controlled.
94  /// @return Returns true if this bone can be directly manipulated, false otherwise.
95  Boole GetManuallyControlled() const;
96 
97  ///////////////////////////////////////////////////////////////////////////////
98  // Child Methods
99 
100  /// @brief Creates a new bone in the parent skeleton as a child of this bone.
101  /// @param Handle The handle to be given to the bone being created. Must be unique to the parent skeleton.
102  /// @param Trans The translation to apply to the created bone.
103  /// @param Rot The rotation to apply to the created bone.
104  /// @return Returns a pointer to the created child bone.
105  Bone* CreateChild(const UInt16 Handle, const Vector3& Trans, const Quaternion& Rot);
106  /// @brief Gets the number of child bones contained by this bone.
107  /// @return Returns a UInt16 containing the number of bones that are children of this bone.
108  UInt16 GetNumChildren() const;
109  /// @brief Gets a child bone by it's index.
110  /// @param Index The index of the bone to retrieve.
111  /// @return Returns a pointer to the requested Bone.
112  Bone* GetChild(const UInt16 Index) const;
113  /// @brief Gets a child bone by it's name.
114  /// @param Name The name of the bone to retrieve.
115  /// @return Returns a pointer to the requested Bone.
116  Bone* GetChild(const String& Name) const;
117  /// @brief Removes a bone from this bone.
118  /// @note This does not remove the bone from the skeleton.
119  /// @param ToBeRemoved The child bone to be removed from this bone.
120  void RemoveChild(Bone* ToBeRemoved);
121  /// @brief Removes a bone from this bone by index.
122  /// @note This does not remove the bone from the skeleton.
123  /// @param Index The index of the child bone to be removed from this bone.
124  void RemoveChild(const UInt16 Index);
125  /// @brief Removes a bone from this bone.
126  /// @note This does not remove the bone from the skeleton.
127  /// @param Name The name of the child bone to be removed from this bone.
128  void RemoveChild(const String& Name);
129 
130  ///////////////////////////////////////////////////////////////////////////////
131  // Transform Methods
132 
133  /// @copydoc TransformableChildObject::SetLocation(const Vector3& Loc)
134  void SetLocation(const Vector3& Loc);
135  /// @copydoc TransformableChildObject::SetLocation(const Real X, const Real Y, const Real Z)
136  void SetLocation(const Real X, const Real Y, const Real Z);
137  /// @copydoc TransformableChildObject::GetLocation() const
138  Vector3 GetLocation() const;
139  /// @copydoc TransformableChildObject::SetOrientation(const Quaternion& Ori)
140  void SetOrientation(const Quaternion& Ori);
141  /// @copydoc TransformableChildObject::SetOrientation(const Real X, const Real Y, const Real Z, const Real W)
142  void SetOrientation(const Real X, const Real Y, const Real Z, const Real W);
143  /// @copydoc TransformableChildObject::GetOrientation() const
144  Quaternion GetOrientation() const;
145  /// @copydoc TransformableChildObject::SetScale(const Vector3& Sc)
146  void SetScale(const Vector3& Sc);
147  /// @copydoc TransformableChildObject::SetScale(const Real X, const Real Y, const Real Z)
148  void SetScale(const Real X, const Real Y, const Real Z);
149  /// @copydoc TransformableChildObject::GetScale() const
150  Vector3 GetScale() const;
151 
152  /// @copydoc TransformableChildObject::Translate(const Vector3& Trans, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent)
153  void Translate(const Vector3& Trans, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent);
154  /// @copydoc TransformableChildObject::Translate(const Real X, const Real Y, const Real Z, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent)
155  void Translate(const Real X, const Real Y, const Real Z, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent);
156  /// @copydoc TransformableChildObject::Yaw(const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent)
157  void Yaw(const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent);
158  /// @copydoc TransformableChildObject::Pitch(const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent)
159  void Pitch(const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent);
160  /// @copydoc TransformableChildObject::Roll(const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent)
161  void Roll(const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent);
162  /// @copydoc TransformableChildObject::Rotate(const Vector3& Axis, const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent)
163  void Rotate(const Vector3& Axis, const Real Angle, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent);
164  /// @copydoc TransformableChildObject::Rotate(const Quaternion& Rotation, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent)
165  void Rotate(const Quaternion& Rotation, const Mezzanine::TransformSpace Space = Mezzanine::TS_Parent);
166  /// @copydoc TransformableChildObject::Scale(const Vector3& Scale)
167  void Scale(const Vector3& Scale);
168  /// @copydoc TransformableChildObject::Scale(const Real X, const Real Y, const Real Z)
169  void Scale(const Real X, const Real Y, const Real Z);
170 
171  ///////////////////////////////////////////////////////////////////////////////
172  // Internal Methods
173 
174  /// @internal
175  /// @brief Gets the internal bone pointer.
176  /// @return Returns a shared pointer pointing to the internal bone.
177  Ogre::Bone* _GetInternalBone() const;
178  };//Bone
179  }//Graphics
180 }//Mezzanine
181 
182 #endif
183 
This is an interface for all child 3D objects that can have their full transforms manipulated...
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
Ogre::Bone * GraphicsBone
The pointer to the internal Bone this is based on.
Definition: bone.h:65
This class encapsulates the bones contained in a skeleton used for animation.
Definition: bone.h:59
This class encapsulates the Skeletal animation functionality of a Mesh.
Definition: skeleton.h:63
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
Mostly reserved for rotations, means a rotation to occur around the parent instead of self...
Definition: enumerations.h:141
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
TransformSpace
Used to define what frame of reference is to be used when positioning or rotating objects...
Definition: enumerations.h:138
This is used to store information about rotation in 3d space.
Definition: quaternion.h:68
Skeleton * Host
The host skeleton this bone belongs to.
Definition: bone.h:68
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159