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:
92  Skeleton();
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 
181  virtual BoneIterator getRootBoneIterator(void);
183  virtual BoneIterator getBoneIterator(void);
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 
269  virtual void _refreshAnimationState(AnimationStateSet* animSet);
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 
291  virtual SkeletonAnimationBlendMode getBlendMode() const;
293  virtual void setBlendMode(SkeletonAnimationBlendMode state);
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);
341  virtual void removeAllLinkedSkeletonAnimationSources(void);
342 
349  getLinkedSkeletonAnimationSourceIterator(void) const;
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:
418  BoneList mBoneList;
421  BoneListByName mBoneListByName;
422 
423 
425  mutable BoneList mRootBones;
427  unsigned short mNextAutoHandle;
430  BoneSet mManualBones;
433 
434 
437  AnimationList mAnimationsList;
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  {
470  SkeletonPtr pSkeleton;
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 
Link to another skeleton to share animations.
Definition: OgreSkeleton.h:467
Concrete IteratorWrapper for nonconst access to the underlying container.
BoneList mBoneList
Storage of bones, indexed by bone handle.
Definition: OgreSkeleton.h:418
Animations are applied by calculating a weighted cumulative total.
Definition: OgreSkeleton.h:54
#define _OgreExport
Definition: OgrePlatform.h:257
unsigned short mNextAutoHandle
Bone automatic handles.
Definition: OgreSkeleton.h:427
BoneListByName mBoneListByName
Definition: OgreSkeleton.h:421
vector< LinkedSkeletonAnimationSource >::type LinkedSkeletonAnimSourceList
Definition: OgreSkeleton.h:344
map< String, Bone * >::type BoneListByName
Lookup by bone name.
Definition: OgreSkeleton.h:420
Animations are applied by calculating a weighted average of all animations.
Definition: OgreSkeleton.h:52
float Real
Software floating point type.
vector< String >::type StringVector
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:87
Interface describing a manual resource loader.
Definition: OgreResource.h:514
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
SkeletonAnimationBlendMode
Definition: OgreSkeleton.h:50
AnimationList mAnimationsList
Definition: OgreSkeleton.h:437
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:58
Class encapsulating a set of AnimationState objects.
bool mManualBonesDirty
Manual bones dirty?
Definition: OgreSkeleton.h:432
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
map< String, Animation * >::type AnimationList
Storage of animations, lookup by name.
Definition: OgreSkeleton.h:436
ConstVectorIterator< LinkedSkeletonAnimSourceList > LinkedSkeletonAnimSourceIterator
Definition: OgreSkeleton.h:346
SkeletonAnimationBlendMode mBlendState
Definition: OgreSkeleton.h:416
BoneList mRootBones
Pointer to root bones (can now have multiple roots)
Definition: OgreSkeleton.h:425
A SkeletonInstance is a single instance of a Skeleton used by a world object.
A bone in a skeleton.
Definition: OgreBone.h:51
vector< Bone * >::type BoneList
Definition: OgreSkeleton.h:178
An animation sequence.
Definition: OgreAnimation.h:92
VectorIterator< BoneList > BoneIterator
Definition: OgreSkeleton.h:179
_StringBase String
BoneSet mManualBones
Manual bones.
Definition: OgreSkeleton.h:430
Defines a generic resource handler.
virtual bool hasManualBones(void) const
Are there any manually controlled bones?
Definition: OgreSkeleton.h:359
vector< ushort >::type BoneHandleMap
Map to translate bone handle from one skeleton to another skeleton.
Definition: OgreSkeleton.h:362
set< Bone * >::type BoneSet
Definition: OgreSkeleton.h:428
LinkedSkeletonAnimationSource(const String &skelName, Real scl, SkeletonPtr skelPtr)
Definition: OgreSkeleton.h:474
Concrete IteratorWrapper for const access to the underlying container.
LinkedSkeletonAnimationSource(const String &skelName, Real scl)
Definition: OgreSkeleton.h:472
SharedPtr< Skeleton > SkeletonPtr
virtual bool getManualBonesDirty(void) const
Have manual bones been modified since the skeleton was last updated?
Definition: OgreSkeleton.h:357
LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList
List of references to other skeletons to use animations from.
Definition: OgreSkeleton.h:440

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jan 2 2017 11:59:31