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