OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreBone.h
Go to the documentation of this file.
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 #ifndef _Bone_H_
29 #define _Bone_H_
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreId.h"
35 
36 #ifndef NDEBUG
37  #include "OgreNode.h"
38 #endif
39 
40 #include "OgreHeaderPrefix.h"
41 
42 namespace Ogre {
43 
61  class _OgreExport Bone : public NodeAlloc, public IdObject
62  {
64  protected:
67 
68 #ifndef NDEBUG
72 #endif
73 
80 
82 
85 
87  void _updateFromParent(void);
88 
90  void updateFromParentImpl(void);
91 
92  void setCachedTransformOutOfDate(void) const;
93 
94  void resetParentTransformPtr(void);
95 
99  void removeChild( Bone* child );
100 
101  public:
108  size_t mGlobalIndex;
110  size_t mParentIndex;
111 
112  Bone();
113  virtual ~Bone();
114 
115  void _initialize( IdType id, BoneMemoryManager *boneMemoryManager,
116  Bone *parent, ArrayMatrixAf4x3 const * RESTRICT_ALIAS reverseBind );
117  void _deinitialize(void);
118 
120  uint16 getDepthLevel() const { return mDepthLevel; }
121 
123  BoneTransform& _getTransform() { return mTransform; }
124 
126  void _memoryRebased(void);
127 
128  void _setReverseBindPtr( const ArrayMatrixAf4x3 *ptr ) { mReverseBind = ptr; }
129 
131  void setName( const String &name ) { mName = name; }
132 
134  const String& getName(void) const { return mName; }
135 
137  Bone* getParent(void) const { return mParent; }
138 
149  void _setNodeParent( Node *nodeParent );
150 
155  inline void setOrientation( Quaternion q );
156 
161  inline Quaternion getOrientation() const;
162 
167  inline void setPosition( const Vector3& pos );
168 
173  inline Vector3 getPosition(void) const;
174 
179  inline void setScale( const Vector3& pos );
180 
185  inline Vector3 getScale(void) const;
186 
201  void setInheritOrientation(bool inherit);
202 
207  bool getInheritOrientation(void) const;
208 
215  void setInheritScale(bool inherit);
216 
221  bool getInheritScale(void) const;
222 
233  {
234  assert( !mCachedTransformOutOfDate );
235  return mTransform.mDerivedTransform[mTransform.mIndex];
236  }
237 
251  {
252  assert( !mCachedTransformOutOfDate &&
253  (!mDebugParentNode || !mDebugParentNode->isCachedTransformOutOfDate()) );
254  return mTransform.mFinalTransform[mTransform.mIndex];
255  }
256 
258  const SimpleMatrixAf4x3& _getFullTransformUpdated(void);
259 
262  /*virtual SceneNode* createChildSceneNode(
263  SceneMemoryMgrTypes sceneType = SCENE_DYNAMIC,
264  const Vector3& translate = Vector3::ZERO,
265  const Quaternion& rotate = Quaternion::IDENTITY );*/
266 
268  static void updateAllTransforms( const size_t numNodes, BoneTransform t,
269  ArrayMatrixAf4x3 const * RESTRICT_ALIAS reverseBind,
270  size_t numBinds );
271  };
276 }// namespace
277 
278 #include "OgreBone.inl"
279 
280 #include "OgreHeaderSuffix.h"
281 
282 #endif
Wrap-around class that contains multiple ArrayMemoryManager, one per hierarchy depth.
#define _OgreExport
Definition: OgrePlatform.h:255
uint16 getDepthLevel() const
Returns how deep in the hierarchy we are (eg. 0 -> root node, 1 -> child of root) ...
Definition: OgreBone.h:120
uint16 mDepthLevel
Depth level in the hierarchy tree (0: Root node, 1: Child of root, etc)
Definition: OgreBone.h:75
ArrayMatrixAf4x3 const *RESTRICT_ALIAS mReverseBind
Definition: OgreBone.h:65
size_t mParentIndex
Index in the vector holding this node reference (could be our parent node, or a global array tracking...
Definition: OgreBone.h:110
Node * mDebugParentNode
Definition: OgreBone.h:70
FORCEINLINE const SimpleMatrixAf4x3 & _getLocalSpaceTransform(void) const
Gets the transformation matrix for this bone in local space (i.e.
Definition: OgreBone.h:232
const String & getName(void) const
Returns the name of the node.
Definition: OgreBone.h:134
Cache-friendly container of AFFINE 4x4 matrices represented as a SoA array.
bool mCachedTransformOutOfDate
Definition: OgreBone.h:69
BoneTransform & _getTransform()
Returns a direct access to the Transform state.
Definition: OgreBone.h:123
String mName
Definition: OgreBone.h:81
#define RESTRICT_ALIAS
Definition: OgrePlatform.h:448
Implementation of a Quaternion, i.e.
Bone * mParent
Pointer to parent node.
Definition: OgreBone.h:77
Ogre::uint32 IdType
Big projects with lots, lots of units for very long periods of time (MMORPGs?) may want to define thi...
Definition: OgreId.h:36
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
FORCEINLINE const SimpleMatrixAf4x3 & _getFullTransform(void) const
Gets the full transformation matrix for this node.
Definition: OgreBone.h:250
Represents the transform of a single object, arranged in SoA (Structure of Arrays) ...
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
BoneVec mChildren
Collection of pointers to direct children.
Definition: OgreBone.h:79
BoneTransform mTransform
Definition: OgreBone.h:66
size_t mGlobalIndex
Index in the vector holding this node reference (could be our parent node, or a global array tracking...
Definition: OgreBone.h:108
Bone * getParent(void) const
Gets this Bones's parent (NULL if this is the root).
Definition: OgreBone.h:137
void _setReverseBindPtr(const ArrayMatrixAf4x3 *ptr)
Definition: OgreBone.h:128
Simple wrap up to load an AoS matrix 4x3 using SSE.
#define FORCEINLINE
Definition: OgrePlatform.h:104
BoneMemoryManager * mBoneMemoryManager
The memory manager used to allocate the Transform.
Definition: OgreBone.h:84
_StringBase String
Definition: OgreCommon.h:53
unsigned short uint16
Definition: OgrePlatform.h:421
vector< Bone * >::type BoneVec
Definition: OgreBone.h:63
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:58
Class representing a Bone in the join hierarchy of a skeleton.
Definition: OgreBone.h:61
bool mInitialized
Definition: OgreBone.h:71
void setName(const String &name)
Sets a custom name for this node. Doesn't have to be unique.
Definition: OgreBone.h:131