OGRE  1.9.0
OgreSkeleton.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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"
37#include "OgreStringVector.h"
38#include "OgreAnimation.h"
39#include "OgreHeaderPrefix.h"
40
41namespace Ogre {
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
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);
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
An animation container interface, which allows generic access to sibling animations.
Class encapsulating a set of AnimationState objects.
An animation sequence.
A bone in a skeleton.
Definition OgreBone.h:52
Concrete IteratorWrapper for const access to the underlying container.
Interface describing a manual resource loader.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition OgreMatrix4.h:79
Defines a generic resource handler.
Abstract class representing a loadable resource (e.g.
Reference-counted shared pointer, used for objects where implicit destruction is required.
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.
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.
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?
map< String, Bone * >::type BoneListByName
Lookup by bone name.
virtual void setBlendMode(SkeletonAnimationBlendMode state)
Sets the animation blending mode this skeleton will use.
virtual Bone * createBone(const String &name, unsigned short handle)
Creates a brand new Bone owned by this Skeleton.
virtual Bone * createBone(void)
Creates a brand new Bone owned by this Skeleton.
virtual void _mergeSkeletonAnimations(const Skeleton *source, const BoneHandleMap &boneHandleMap, const StringVector &animations=StringVector())
Merge animations from another Skeleton object into 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 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
BoneSet mManualBones
Manual bones.
unsigned short mNextAutoHandle
Bone automatic handles.
BoneList mRootBones
Pointer to root bones (can now have multiple roots)
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...
virtual unsigned short getNumAnimations(void) const
Gets the number of animations on this skeleton.
void _dumpContents(const String &filename)
Debugging method.
BoneListByName mBoneListByName
virtual void optimiseAllAnimations(bool preservingIdentityNodeTracks=false)
Optimise all of this skeleton's animations.
vector< LinkedSkeletonAnimationSource >::type LinkedSkeletonAnimSourceList
void deriveRootBone(void) const
Internal method which parses the bones to derive the root bone.
virtual ~Skeleton()
set< Bone * >::type BoneSet
virtual void _updateTransforms(void)
Updates all the derived transforms in the skeleton.
virtual Animation * getAnimation(const String &name, const LinkedSkeletonAnimationSource **linker) const
Returns the named Animation object.
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 Animation * getAnimation(const String &name) const
Returns the named Animation object.
virtual Bone * createBone(const String &name)
Creates a brand new Bone owned by this Skeleton.
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.
void unloadImpl(void)
Internal implementation of the 'unload' action; called regardless of whether this resource is being l...
virtual Animation * _getAnimationImpl(const String &name, const LinkedSkeletonAnimationSource **linker=0) const
Internal accessor for animations (returns null if animation does not exist)
virtual Animation * createAnimation(const String &name, Real length)
Creates a new Animation object for animating this skeleton.
virtual Animation * getAnimation(unsigned short index) const
Gets a single animation by index.
vector< Bone * >::type BoneList
virtual void reset(bool resetManualBones=false)
Resets the position and orientation of all bones in this skeleton to their original binding position.
virtual void _buildMapBoneByName(const Skeleton *source, BoneHandleMap &boneHandleMap) const
Build the bone handle map to use with Skeleton::_mergeSkeletonAnimations.
map< String, Animation * >::type AnimationList
Storage of animations, lookup by name.
bool mManualBonesDirty
Manual bones dirty?
virtual void _refreshAnimationState(AnimationStateSet *animSet)
Refresh an animation set suitable for use with this skeleton.
virtual Bone * getRootBone(void) const
Gets the root bone of the skeleton: deprecated in favour of getRootBoneIterator.
ConstVectorIterator< LinkedSkeletonAnimSourceList > LinkedSkeletonAnimSourceIterator
virtual BoneIterator getRootBoneIterator(void)
Get an iterator over the root bones in the skeleton, ie those with no parents.
virtual Bone * getBone(unsigned short handle) const
Gets a bone by it's handle.
virtual void _notifyManualBoneStateChange(Bone *bone)
Internal method for notifying that a bone is manual.
LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList
List of references to other skeletons to use animations from.
virtual void _getBoneMatrices(Matrix4 *pMatrices)
Populates the passed in array with the bone matrices based on the current position.
AnimationList mAnimationsList
virtual bool hasManualBones(void) const
Are there any manually controlled bones?
virtual Bone * getBone(const String &name) const
Gets a bone by it's name.
virtual void setBindingPose(void)
Sets the current position / orientation to be the 'binding pose' i.e.
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.
VectorIterator< BoneList > BoneIterator
virtual Bone * createBone(unsigned short handle)
Creates a brand new Bone owned by this Skeleton.
vector< ushort >::type BoneHandleMap
Map to translate bone handle from one skeleton to another skeleton.
Concrete IteratorWrapper for nonconst access to the underlying container.
SkeletonAnimationBlendMode
SharedPtr< Skeleton > SkeletonPtr
@ ANIMBLEND_AVERAGE
Animations are applied by calculating a weighted average of all animations.
@ ANIMBLEND_CUMULATIVE
Animations are applied by calculating a weighted cumulative total.
vector< String >::type StringVector
float Real
Software floating point type.
unsigned long long int ResourceHandle
_StringBase String
Link to another skeleton to share animations.
LinkedSkeletonAnimationSource(const String &skelName, Real scl)
LinkedSkeletonAnimationSource(const String &skelName, Real scl, SkeletonPtr skelPtr)
std::map< K, V, P, A > type
std::set< T, P, A > type
std::vector< T, A > type