OGRE  2.0
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 "OgreStringVector.h"
35 #include "OgreAnimation.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
52  };
53 
54 #define OGRE_MAX_NUM_BONES 256
55 
56 
57  struct LinkedSkeletonAnimationSource;
58 
85  {
86  friend class OldSkeletonInstance;
87  protected:
89  Skeleton();
90 
91  public:
97  Skeleton(ResourceManager* creator, const String& name, ResourceHandle handle,
98  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
99  virtual ~Skeleton();
100 
101 
115  virtual OldBone* createBone(void);
116 
130  virtual OldBone* createBone(unsigned short handle);
131 
145  virtual OldBone* createBone(const String& name);
146 
157  virtual OldBone* createBone(const String& name, unsigned short handle);
158 
160  virtual unsigned short getNumBones(void) const;
161 
173  virtual OldBone* getRootBone(void) const;
174 
179  virtual BoneIterator getRootBoneIterator(void);
181  virtual BoneIterator getBoneIterator(void);
182  ConstBoneIterator getBoneIteratorConst(void) const;
183 
185  virtual OldBone* getBone(unsigned short handle) const;
186 
188  virtual OldBone* getBone(const String& name) const;
189 
191  virtual bool hasBone(const String& name) const;
192 
196  virtual void setBindingPose(void);
197 
207  virtual void reset(bool resetManualBones = false);
208 
213  virtual Animation* createAnimation(const String& name, Real length);
214 
223  virtual Animation* getAnimation(const String& name,
224  const LinkedSkeletonAnimationSource** linker) const;
225 
232  virtual Animation* getAnimation(const String& name) const;
233 
235  virtual Animation* _getAnimationImpl(const String& name,
236  const LinkedSkeletonAnimationSource** linker = 0) const;
237 
238 
240  virtual bool hasAnimation(const String& name) const;
241 
243  virtual void removeAnimation(const String& name);
244 
255  virtual void setAnimationState(const AnimationStateSet& animSet);
256 
257 
262  virtual void _initAnimationState(AnimationStateSet* animSet);
263 
268  virtual void _refreshAnimationState(AnimationStateSet* animSet);
269 
276  virtual void _getBoneMatrices(Matrix4* pMatrices);
277 
279  virtual unsigned short getNumAnimations(void) const;
280 
286  virtual Animation* getAnimation(unsigned short index) const;
287 
288 
290  virtual SkeletonAnimationBlendMode getBlendMode() const;
292  virtual void setBlendMode(SkeletonAnimationBlendMode state);
293 
295  virtual void _updateTransforms(void);
296 
302  virtual void optimiseAllAnimations(bool preservingIdentityNodeTracks = false);
303 
337  virtual void addLinkedSkeletonAnimationSource(const String& skelName,
338  Real scale = 1.0f);
340  virtual void removeAllLinkedSkeletonAnimationSources(void);
341 
348  getLinkedSkeletonAnimationSourceIterator(void) const;
349 
351  virtual void _notifyManualBonesDirty(void);
353  virtual void _notifyManualBoneStateChange(OldBone* bone);
354 
356  virtual bool getManualBonesDirty(void) const { return mManualBonesDirty; }
358  virtual bool hasManualBones(void) const { return !mManualBones.empty(); }
359 
362 
396  virtual void _mergeSkeletonAnimations(const Skeleton* source,
397  const BoneHandleMap& boneHandleMap,
398  const StringVector& animations = StringVector());
399 
404  virtual void _buildMapBoneByHandle(const Skeleton* source,
405  BoneHandleMap& boneHandleMap) const;
406 
411  virtual void _buildMapBoneByName(const Skeleton* source,
412  BoneHandleMap& boneHandleMap) const;
413 
414  protected:
421 
422 
426  unsigned short mNextAutoHandle;
432 
433 
437 
440 
446  void deriveRootBone(void) const;
447 
449  void _dumpContents(const String& filename);
450 
453  void loadImpl(void);
454 
457  void unloadImpl(void);
459  size_t calculateSize(void) const;
460 
461  };
462 
465  {
470  : skeletonName(skelName), scale(scl) {}
472  SkeletonPtr skelPtr)
473  : skeletonName(skelName), pSkeleton(skelPtr), scale(scl) {}
474  };
478 }
479 
480 #include "OgreHeaderSuffix.h"
481 
482 #endif
483 
Class encapsulating a set of AnimationState objects.
SkeletonAnimationBlendMode
Definition: OgreSkeleton.h:47
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
VectorIterator< BoneList > BoneIterator
Definition: OgreSkeleton.h:176
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
AnimationList mAnimationsList
Definition: OgreSkeleton.h:436
vector< ushort >::type BoneHandleMap
Map to translate bone handle from one skeleton to another skeleton.
Definition: OgreSkeleton.h:361
SkeletonAnimationBlendMode mBlendState
Definition: OgreSkeleton.h:415
LinkedSkeletonAnimationSource(const String &skelName, Real scl)
Definition: OgreSkeleton.h:469
BoneList mBoneList
Storage of bones, indexed by bone handle.
Definition: OgreSkeleton.h:417
LinkedSkeletonAnimationSource(const String &skelName, Real scl, SkeletonPtr skelPtr)
Definition: OgreSkeleton.h:471
Interface describing a manual resource loader.
Definition: OgreResource.h:498
BoneList mRootBones
Pointer to root bones (can now have multiple roots)
Definition: OgreSkeleton.h:424
map< String, OldBone * >::type BoneListByName
Lookup by bone name.
Definition: OgreSkeleton.h:419
vector< LinkedSkeletonAnimationSource >::type LinkedSkeletonAnimSourceList
Definition: OgreSkeleton.h:343
virtual bool getManualBonesDirty(void) const
Have manual bones been modified since the skeleton was last updated?
Definition: OgreSkeleton.h:356
Animations are applied by calculating a weighted cumulative total.
Definition: OgreSkeleton.h:51
unsigned short mNextAutoHandle
OldBone automatic handles.
Definition: OgreSkeleton.h:426
set< OldBone * >::type BoneSet
Definition: OgreSkeleton.h:427
Concrete IteratorWrapper for const access to the underlying container.
map< String, Animation * >::type AnimationList
Storage of animations, lookup by name.
Definition: OgreSkeleton.h:435
vector< String >::type StringVector
Link to another skeleton to share animations.
Definition: OgreSkeleton.h:464
A bone in a skeleton.
Definition: OgreOldBone.h:51
Animations are applied by calculating a weighted average of all animations.
Definition: OgreSkeleton.h:49
ConstVectorIterator< LinkedSkeletonAnimSourceList > LinkedSkeletonAnimSourceIterator
Definition: OgreSkeleton.h:345
bool mManualBonesDirty
Manual bones dirty?
Definition: OgreSkeleton.h:431
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:77
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList
List of references to other skeletons to use animations from.
Definition: OgreSkeleton.h:439
BoneListByName mBoneListByName
Definition: OgreSkeleton.h:420
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:56
virtual bool hasManualBones(void) const
Are there any manually controlled bones?
Definition: OgreSkeleton.h:358
vector< OldBone * >::type BoneList
Definition: OgreSkeleton.h:175
Defines a generic resource handler.
_StringBase String
Definition: OgreCommon.h:53
BoneSet mManualBones
Manual bones.
Definition: OgreSkeleton.h:429
A OldSkeletonInstance is a single instance of a Skeleton used by a world object.
ConstVectorIterator< BoneList > ConstBoneIterator
Definition: OgreSkeleton.h:177
Concrete IteratorWrapper for nonconst access to the underlying container.
An animation sequence.
Definition: OgreAnimation.h:90
A collection of OldBone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:84