OgreSkeleton.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-2013 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 __Skeleton_H__
30 #define __Skeleton_H__
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreResource.h"
34 #include "OgreQuaternion.h"
35 #include "OgreVector3.h"
36 #include "OgreIteratorWrappers.h"
37 #include "OgreStringVector.h"
38 #include "OgreAnimation.h"
39 #include "OgreHeaderPrefix.h"
40 
41 namespace Ogre {
55  };
56 
57 #define OGRE_MAX_NUM_BONES 256
58 
59 
60  struct LinkedSkeletonAnimationSource;
61 
88  {
89  friend class SkeletonInstance;
90  protected:
93 
94  public:
100  Skeleton(ResourceManager* creator, const String& name, ResourceHandle handle,
101  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
102  virtual ~Skeleton();
103 
104 
118  virtual Bone* createBone(void);
119 
133  virtual Bone* createBone(unsigned short handle);
134 
148  virtual Bone* createBone(const String& name);
149 
160  virtual Bone* createBone(const String& name, unsigned short handle);
161 
163  virtual unsigned short getNumBones(void) const;
164 
176  virtual Bone* getRootBone(void) const;
177 
184 
186  virtual Bone* getBone(unsigned short handle) const;
187 
189  virtual Bone* getBone(const String& name) const;
190 
192  virtual bool hasBone(const String& name) const;
193 
197  virtual void setBindingPose(void);
198 
208  virtual void reset(bool resetManualBones = false);
209 
214  virtual Animation* createAnimation(const String& name, Real length);
215 
224  virtual Animation* getAnimation(const String& name,
225  const LinkedSkeletonAnimationSource** linker) const;
226 
233  virtual Animation* getAnimation(const String& name) const;
234 
236  virtual Animation* _getAnimationImpl(const String& name,
237  const LinkedSkeletonAnimationSource** linker = 0) const;
238 
239 
241  virtual bool hasAnimation(const String& name) const;
242 
244  virtual void removeAnimation(const String& name);
245 
256  virtual void setAnimationState(const AnimationStateSet& animSet);
257 
258 
263  virtual void _initAnimationState(AnimationStateSet* animSet);
264 
270 
277  virtual void _getBoneMatrices(Matrix4* pMatrices);
278 
280  virtual unsigned short getNumAnimations(void) const;
281 
287  virtual Animation* getAnimation(unsigned short index) const;
288 
289 
294 
296  virtual void _updateTransforms(void);
297 
303  virtual void optimiseAllAnimations(bool preservingIdentityNodeTracks = false);
304 
338  virtual void addLinkedSkeletonAnimationSource(const String& skelName,
339  Real scale = 1.0f);
342 
350 
352  virtual void _notifyManualBonesDirty(void);
354  virtual void _notifyManualBoneStateChange(Bone* bone);
355 
357  virtual bool getManualBonesDirty(void) const { return mManualBonesDirty; }
359  virtual bool hasManualBones(void) const { return !mManualBones.empty(); }
360 
363 
397  virtual void _mergeSkeletonAnimations(const Skeleton* source,
398  const BoneHandleMap& boneHandleMap,
399  const StringVector& animations = StringVector());
400 
405  virtual void _buildMapBoneByHandle(const Skeleton* source,
406  BoneHandleMap& boneHandleMap) const;
407 
412  virtual void _buildMapBoneByName(const Skeleton* source,
413  BoneHandleMap& boneHandleMap) const;
414 
415  protected:
422 
423 
427  unsigned short mNextAutoHandle;
433 
434 
438 
441 
447  void deriveRootBone(void) const;
448 
450  void _dumpContents(const String& filename);
451 
454  void loadImpl(void);
455 
458  void unloadImpl(void);
460  size_t calculateSize(void) const;
461 
462  };
463 
465 
468  {
473  : skeletonName(skelName), scale(scl) {}
475  SkeletonPtr skelPtr)
476  : skeletonName(skelName), pSkeleton(skelPtr), scale(scl) {}
477  };
481 }
482 
483 #include "OgreHeaderSuffix.h"
484 
485 #endif
486 
#define _OgreExport
Definition: OgrePlatform.h:257
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:59
Class encapsulating a set of AnimationState objects.
An animation sequence.
Definition: OgreAnimation.h:93
A bone in a skeleton.
Definition: OgreBone.h:52
Concrete IteratorWrapper for const access to the underlying container.
Interface describing a manual resource loader.
Definition: OgreResource.h:515
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
Defines a generic resource handler.
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:80
A SkeletonInstance is a single instance of a Skeleton used by a world object.
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:88
size_t calculateSize(void) const
Calculate the size of a resource; this will only be called after 'load'.
BoneList mBoneList
Storage of bones, indexed by bone handle.
Definition: OgreSkeleton.h:418
virtual void _notifyManualBonesDirty(void)
Internal method for marking the manual bones as dirty.
virtual bool getManualBonesDirty(void) const
Have manual bones been modified since the skeleton was last updated?
Definition: OgreSkeleton.h:357
virtual void setBlendMode(SkeletonAnimationBlendMode state)
Sets the animation blending mode this skeleton will use.
virtual void _mergeSkeletonAnimations(const Skeleton *source, const BoneHandleMap &boneHandleMap, const StringVector &animations=StringVector())
Merge animations from another Skeleton object into this skeleton.
map< String, Animation * >::type AnimationList
Storage of animations, lookup by name.
Definition: OgreSkeleton.h:436
virtual Bone * createBone(unsigned short handle)
Creates a brand new Bone owned by this Skeleton.
virtual void addLinkedSkeletonAnimationSource(const String &skelName, Real scale=1.0f)
Allows you to use the animations from another Skeleton object to animate this skeleton.
virtual Bone * getBone(const String &name) const
Gets a bone by it's name.
virtual SkeletonAnimationBlendMode getBlendMode() const
Gets the animation blending mode which this skeleton will use.
virtual LinkedSkeletonAnimSourceIterator getLinkedSkeletonAnimationSourceIterator(void) const
Get an iterator over the linked skeletons used as animation sources.
virtual bool hasAnimation(const String &name) const
Returns whether this skeleton contains the named animation.
SkeletonAnimationBlendMode mBlendState
Definition: OgreSkeleton.h:416
BoneSet mManualBones
Manual bones.
Definition: OgreSkeleton.h:430
unsigned short mNextAutoHandle
Bone automatic handles.
Definition: OgreSkeleton.h:427
BoneList mRootBones
Pointer to root bones (can now have multiple roots)
Definition: OgreSkeleton.h:425
virtual Bone * getBone(unsigned short handle) const
Gets a bone by it's handle.
virtual bool hasBone(const String &name) const
Returns whether this skeleton contains the named bone.
void loadImpl(void)
Internal implementation of the meat of the 'load' action, only called if this resource is not being l...
virtual BoneIterator getBoneIterator(void)
Get an iterator over all the bones in the skeleton.
virtual void setAnimationState(const AnimationStateSet &animSet)
Changes the state of the skeleton to reflect the application of the passed in collection of animation...
map< String, Bone * >::type BoneListByName
Lookup by bone name.
Definition: OgreSkeleton.h:420
virtual unsigned short getNumAnimations(void) const
Gets the number of animations on this skeleton.
void _dumpContents(const String &filename)
Debugging method.
BoneListByName mBoneListByName
Definition: OgreSkeleton.h:421
virtual void optimiseAllAnimations(bool preservingIdentityNodeTracks=false)
Optimise all of this skeleton's animations.
void deriveRootBone(void) const
Internal method which parses the bones to derive the root bone.
virtual ~Skeleton()
virtual void _updateTransforms(void)
Updates all the derived transforms in the skeleton.
Skeleton()
Internal constructor for use by SkeletonInstance only.
virtual void _buildMapBoneByHandle(const Skeleton *source, BoneHandleMap &boneHandleMap) const
Build the bone handle map to use with Skeleton::_mergeSkeletonAnimations.
Skeleton(ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, bool isManual=false, ManualResourceLoader *loader=0)
Constructor, don't call directly, use SkeletonManager.
virtual void removeAnimation(const String &name)
Removes an Animation from this skeleton.
virtual void removeAllLinkedSkeletonAnimationSources(void)
Remove all links to other skeletons for the purposes of sharing animation.
vector< Bone * >::type BoneList
Definition: OgreSkeleton.h:178
void unloadImpl(void)
Internal implementation of the 'unload' action; called regardless of whether this resource is being l...
vector< ushort >::type BoneHandleMap
Map to translate bone handle from one skeleton to another skeleton.
Definition: OgreSkeleton.h:362
virtual void reset(bool resetManualBones=false)
Resets the position and orientation of all bones in this skeleton to their original binding position.
virtual Bone * createBone(const String &name)
Creates a brand new Bone owned by this Skeleton.
VectorIterator< BoneList > BoneIterator
Definition: OgreSkeleton.h:179
virtual void _buildMapBoneByName(const Skeleton *source, BoneHandleMap &boneHandleMap) const
Build the bone handle map to use with Skeleton::_mergeSkeletonAnimations.
virtual Animation * _getAnimationImpl(const String &name, const LinkedSkeletonAnimationSource **linker=0) const
Internal accessor for animations (returns null if animation does not exist)
bool mManualBonesDirty
Manual bones dirty?
Definition: OgreSkeleton.h:432
virtual void _refreshAnimationState(AnimationStateSet *animSet)
Refresh an animation set suitable for use with this skeleton.
virtual Animation * createAnimation(const String &name, Real length)
Creates a new Animation object for animating this skeleton.
set< Bone * >::type BoneSet
Definition: OgreSkeleton.h:428
virtual BoneIterator getRootBoneIterator(void)
Get an iterator over the root bones in the skeleton, ie those with no parents.
virtual Bone * getRootBone(void) const
Gets the root bone of the skeleton: deprecated in favour of getRootBoneIterator.
vector< LinkedSkeletonAnimationSource >::type LinkedSkeletonAnimSourceList
Definition: OgreSkeleton.h:344
virtual void _notifyManualBoneStateChange(Bone *bone)
Internal method for notifying that a bone is manual.
virtual Bone * createBone(const String &name, unsigned short handle)
Creates a brand new Bone owned by this Skeleton.
LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList
List of references to other skeletons to use animations from.
Definition: OgreSkeleton.h:440
virtual void _getBoneMatrices(Matrix4 *pMatrices)
Populates the passed in array with the bone matrices based on the current position.
AnimationList mAnimationsList
Definition: OgreSkeleton.h:437
virtual bool hasManualBones(void) const
Are there any manually controlled bones?
Definition: OgreSkeleton.h:359
virtual void setBindingPose(void)
Sets the current position / orientation to be the 'binding pose' i.e.
ConstVectorIterator< LinkedSkeletonAnimSourceList > LinkedSkeletonAnimSourceIterator
Definition: OgreSkeleton.h:346
virtual Animation * getAnimation(const String &name) const
Returns the named Animation object.
virtual Bone * createBone(void)
Creates a brand new Bone owned by this Skeleton.
virtual unsigned short getNumBones(void) const
Returns the number of bones in this skeleton.
virtual void _initAnimationState(AnimationStateSet *animSet)
Initialise an animation set suitable for use with this skeleton.
virtual Animation * getAnimation(unsigned short index) const
Gets a single animation by index.
virtual Animation * getAnimation(const String &name, const LinkedSkeletonAnimationSource **linker) const
Returns the named Animation object.
Concrete IteratorWrapper for nonconst access to the underlying container.
SkeletonAnimationBlendMode
Definition: OgreSkeleton.h:50
SharedPtr< Skeleton > SkeletonPtr
@ ANIMBLEND_AVERAGE
Animations are applied by calculating a weighted average of all animations.
Definition: OgreSkeleton.h:52
@ ANIMBLEND_CUMULATIVE
Animations are applied by calculating a weighted cumulative total.
Definition: OgreSkeleton.h:54
vector< String >::type StringVector
float Real
Software floating point type.
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
_StringBase String
Link to another skeleton to share animations.
Definition: OgreSkeleton.h:468
LinkedSkeletonAnimationSource(const String &skelName, Real scl)
Definition: OgreSkeleton.h:472
LinkedSkeletonAnimationSource(const String &skelName, Real scl, SkeletonPtr skelPtr)
Definition: OgreSkeleton.h:474

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.