/src/ogre/OgreMain/include/OgreBone.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | |
29 | | #ifndef __Bone_H__ |
30 | | #define __Bone_H__ |
31 | | |
32 | | #include "OgrePrerequisites.h" |
33 | | #include "OgreNode.h" |
34 | | |
35 | | |
36 | | namespace Ogre |
37 | | { |
38 | | /** \addtogroup Core |
39 | | * @{ |
40 | | */ |
41 | | /** \addtogroup Animation |
42 | | * @{ |
43 | | */ |
44 | | |
45 | | /** A bone in a skeleton. |
46 | | |
47 | | See Skeleton for more information about the principles behind skeletal animation. |
48 | | This class is a node in the joint hierarchy. Mesh vertices also have assignments |
49 | | to bones to define how they move in relation to the skeleton. |
50 | | */ |
51 | | class _OgreExport Bone : public Node |
52 | | { |
53 | | public: |
54 | | /** Constructor, not to be used directly (use Bone::createChild or Skeleton::createBone) */ |
55 | | Bone(unsigned short handle, Skeleton* creator); |
56 | | /** Constructor, not to be used directly (use Bone::createChild or Skeleton::createBone) */ |
57 | | Bone(const String& name, unsigned short handle, Skeleton* creator); |
58 | | ~Bone(); |
59 | | |
60 | | private: |
61 | | // Intentionally hide base implementations of createChild methods. This will also suppress |
62 | | // warnings like 'Ogre::Bone::createChild' hides overloaded virtual functions |
63 | | using Node::createChild; |
64 | | public: |
65 | | /** Creates a new Bone as a child of this bone. |
66 | | |
67 | | This method creates a new bone which will inherit the transforms of this |
68 | | bone, with the handle specified. |
69 | | @param |
70 | | handle The numeric handle to give the new bone; must be unique within the Skeleton. |
71 | | @param |
72 | | translate Initial translation offset of child relative to parent |
73 | | @param |
74 | | rotate Initial rotation relative to parent |
75 | | */ |
76 | | Bone* createChild(unsigned short handle, |
77 | | const Vector3& translate = Vector3::ZERO, const Quaternion& rotate = Quaternion::IDENTITY); |
78 | | |
79 | | /** Gets the numeric handle for this bone (unique within the skeleton). */ |
80 | 0 | unsigned short getHandle(void) const { return mHandle; } |
81 | | |
82 | | /** Sets the current position / orientation to be the 'binding pose' ie the layout in which |
83 | | bones were originally bound to a mesh. |
84 | | */ |
85 | | void setBindingPose(void); |
86 | | |
87 | | /** Resets the position and orientation of this Bone to the original binding position. |
88 | | |
89 | | Bones are bound to the mesh in a binding pose. They are then modified from this |
90 | | position during animation. This method returns the bone to it's original position and |
91 | | orientation. |
92 | | */ |
93 | | void reset(void); |
94 | | |
95 | | /** Sets whether or not this bone is manually controlled. |
96 | | |
97 | | Manually controlled bones can be altered by the application at runtime, |
98 | | and their positions will not be reset by the animation routines. Note |
99 | | that you should also make sure that there are no AnimationTrack objects |
100 | | referencing this bone, or if there are, you should disable them using |
101 | | pAnimation->destroyTrack(pBone->getHandle()); |
102 | | @par |
103 | | You can also use AnimationState::setBlendMask to mask out animation from |
104 | | chosen tracks if you want to prevent application of a scripted animation |
105 | | to a bone without altering the Animation definition. |
106 | | */ |
107 | | void setManuallyControlled(bool manuallyControlled); |
108 | | |
109 | | /** Getter for mManuallyControlled Flag */ |
110 | 0 | bool isManuallyControlled() const { return mManuallyControlled; } |
111 | | |
112 | | |
113 | | /** Gets the transform which takes bone space to current from the binding pose. |
114 | | |
115 | | Internal use only. |
116 | | */ |
117 | | void _getOffsetTransform(Affine3& m) const; |
118 | | |
119 | | /** Gets the inverted binding pose scale. */ |
120 | 0 | const Vector3& _getBindingPoseInverseScale(void) const { return mBindDerivedInverseScale; } |
121 | | /** Gets the inverted binding pose position. */ |
122 | 0 | const Vector3& _getBindingPoseInversePosition(void) const { return mBindDerivedInversePosition; } |
123 | | /** Gets the inverted binding pose orientation. */ |
124 | 0 | const Quaternion& _getBindingPoseInverseOrientation(void) const { return mBindDerivedInverseOrientation; } |
125 | | |
126 | | /// @see Node::needUpdate |
127 | | void needUpdate(bool forceParentUpdate = false) override; |
128 | | |
129 | | |
130 | | private: |
131 | | /** See Node. */ |
132 | | Node* createChildImpl(void) override; |
133 | | /** See Node. */ |
134 | | Node* createChildImpl(const String& name) override; |
135 | | |
136 | | /// Pointer back to creator, for child creation (not smart ptr so child does not preserve parent) |
137 | | Skeleton* mCreator; |
138 | | |
139 | | /// The inversed derived scale of the bone in the binding pose |
140 | | Vector3 mBindDerivedInverseScale; |
141 | | /// The inversed derived orientation of the bone in the binding pose |
142 | | Quaternion mBindDerivedInverseOrientation; |
143 | | /// The inversed derived position of the bone in the binding pose |
144 | | Vector3 mBindDerivedInversePosition; |
145 | | /// The numeric handle of this bone |
146 | | unsigned short mHandle; |
147 | | /** Bones set as manuallyControlled are not reseted in Skeleton::reset() */ |
148 | | bool mManuallyControlled; |
149 | | }; |
150 | | |
151 | | /** @} */ |
152 | | /** @} */ |
153 | | |
154 | | } |
155 | | |
156 | | #endif |