OgreSkeleton.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Skeleton_H__
#define __Skeleton_H__
#include "OgrePrerequisites.h"
#include "OgreResource.h"
#include "OgreQuaternion.h"
#include "OgreVector3.h"
#include "OgreIteratorWrappers.h"
#include "OgreStringVector.h"
#include "OgreAnimation.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
enum SkeletonAnimationBlendMode {
ANIMBLEND_AVERAGE = 0,
ANIMBLEND_CUMULATIVE = 1
};
#define OGRE_MAX_NUM_BONES 256
struct LinkedSkeletonAnimationSource;
class _OgreExport Skeleton : public Resource, public AnimationContainer
{
friend class SkeletonInstance;
protected:
Skeleton();
public:
Skeleton(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
virtual ~Skeleton();
virtual Bone* createBone(void);
virtual Bone* createBone(unsigned short handle);
virtual Bone* createBone(const String& name);
virtual Bone* createBone(const String& name, unsigned short handle);
virtual unsigned short getNumBones(void) const;
virtual Bone* getRootBone(void) const;
typedef vector<Bone*>::type BoneList;
typedef VectorIterator<BoneList> BoneIterator;
virtual BoneIterator getRootBoneIterator(void);
virtual BoneIterator getBoneIterator(void);
virtual Bone* getBone(unsigned short handle) const;
virtual Bone* getBone(const String& name) const;
virtual bool hasBone(const String& name) const;
virtual void setBindingPose(void);
virtual void reset(bool resetManualBones = false);
virtual Animation* createAnimation(const String& name, Real length);
virtual Animation* getAnimation(const String& name,
const LinkedSkeletonAnimationSource** linker) const;
virtual Animation* getAnimation(const String& name) const;
virtual Animation* _getAnimationImpl(const String& name,
const LinkedSkeletonAnimationSource** linker = 0) const;
virtual bool hasAnimation(const String& name) const;
virtual void removeAnimation(const String& name);
virtual void setAnimationState(const AnimationStateSet& animSet);
virtual void _initAnimationState(AnimationStateSet* animSet);
virtual void _refreshAnimationState(AnimationStateSet* animSet);
virtual void _getBoneMatrices(Matrix4* pMatrices);
virtual unsigned short getNumAnimations(void) const;
virtual Animation* getAnimation(unsigned short index) const;
virtual SkeletonAnimationBlendMode getBlendMode() const;
virtual void setBlendMode(SkeletonAnimationBlendMode state);
virtual void _updateTransforms(void);
virtual void optimiseAllAnimations(bool preservingIdentityNodeTracks = false);
virtual void addLinkedSkeletonAnimationSource(const String& skelName,
Real scale = 1.0f);
virtual void removeAllLinkedSkeletonAnimationSources(void);
typedef vector<LinkedSkeletonAnimationSource>::type
LinkedSkeletonAnimSourceList;
typedef ConstVectorIterator<LinkedSkeletonAnimSourceList>
LinkedSkeletonAnimSourceIterator;
virtual LinkedSkeletonAnimSourceIterator
getLinkedSkeletonAnimationSourceIterator(void) const;
virtual void _notifyManualBonesDirty(void);
virtual void _notifyManualBoneStateChange(Bone* bone);
virtual bool getManualBonesDirty(void) const { return mManualBonesDirty; }
virtual bool hasManualBones(void) const { return !mManualBones.empty(); }
typedef vector<ushort>::type BoneHandleMap;
virtual void _mergeSkeletonAnimations(const Skeleton* source,
const BoneHandleMap& boneHandleMap,
const StringVector& animations = StringVector());
virtual void _buildMapBoneByHandle(const Skeleton* source,
BoneHandleMap& boneHandleMap) const;
virtual void _buildMapBoneByName(const Skeleton* source,
BoneHandleMap& boneHandleMap) const;
protected:
SkeletonAnimationBlendMode mBlendState;
BoneList mBoneList;
typedef map<String, Bone*>::type BoneListByName;
BoneListByName mBoneListByName;
mutable BoneList mRootBones;
unsigned short mNextAutoHandle;
typedef set<Bone*>::type BoneSet;
BoneSet mManualBones;
bool mManualBonesDirty;
typedef map<String, Animation*>::type AnimationList;
AnimationList mAnimationsList;
mutable LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList;
void deriveRootBone(void) const;
void _dumpContents(const String& filename);
void loadImpl(void);
void unloadImpl(void);
size_t calculateSize(void) const;
};
typedef SharedPtr<Skeleton> SkeletonPtr;
struct LinkedSkeletonAnimationSource
{
String skeletonName;
SkeletonPtr pSkeleton;
Real scale;
LinkedSkeletonAnimationSource(const String& skelName, Real scl)
: skeletonName(skelName), scale(scl) {}
LinkedSkeletonAnimationSource(const String& skelName, Real scl,
SkeletonPtr skelPtr)
: skeletonName(skelName), pSkeleton(skelPtr), scale(scl) {}
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::LinkedSkeletonAnimationSource
Link to another skeleton to share animations.
Definition: OgreSkeleton.h:467
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::Skeleton::mBoneList
BoneList mBoneList
Storage of bones, indexed by bone handle.
Definition: OgreSkeleton.h:418
Ogre::ANIMBLEND_CUMULATIVE
Animations are applied by calculating a weighted cumulative total.
Definition: OgreSkeleton.h:54
OgreQuaternion.h
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Skeleton::mNextAutoHandle
unsigned short mNextAutoHandle
Bone automatic handles.
Definition: OgreSkeleton.h:427
Ogre::Skeleton::mBoneListByName
BoneListByName mBoneListByName
Definition: OgreSkeleton.h:421
OgreResource.h
Ogre::Skeleton::LinkedSkeletonAnimSourceList
vector< LinkedSkeletonAnimationSource >::type LinkedSkeletonAnimSourceList
Definition: OgreSkeleton.h:344
Ogre::Skeleton::BoneListByName
map< String, Bone * >::type BoneListByName
Lookup by bone name.
Definition: OgreSkeleton.h:420
Ogre::ANIMBLEND_AVERAGE
Animations are applied by calculating a weighted average of all animations.
Definition: OgreSkeleton.h:52
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
Ogre::Resource
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Ogre::Skeleton
A collection of Bone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:87
Ogre::LinkedSkeletonAnimationSource::pSkeleton
SkeletonPtr pSkeleton
Definition: OgreSkeleton.h:470
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::SkeletonAnimationBlendMode
SkeletonAnimationBlendMode
Definition: OgreSkeleton.h:50
Ogre::Skeleton::mAnimationsList
AnimationList mAnimationsList
Definition: OgreSkeleton.h:437
Ogre::AnimationContainer
An animation container interface, which allows generic access to sibling animations.
Definition: OgreAnimation.h:58
Ogre::AnimationStateSet
Class encapsulating a set of AnimationState objects.
Definition: OgreAnimationState.h:196
Ogre::Skeleton::mManualBonesDirty
bool mManualBonesDirty
Manual bones dirty?
Definition: OgreSkeleton.h:432
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Skeleton::AnimationList
map< String, Animation * >::type AnimationList
Storage of animations, lookup by name.
Definition: OgreSkeleton.h:436
Ogre::Skeleton::LinkedSkeletonAnimSourceIterator
ConstVectorIterator< LinkedSkeletonAnimSourceList > LinkedSkeletonAnimSourceIterator
Definition: OgreSkeleton.h:346
Ogre::Skeleton::mBlendState
SkeletonAnimationBlendMode mBlendState
Definition: OgreSkeleton.h:416
OgrePrerequisites.h
Ogre::Skeleton::mRootBones
BoneList mRootBones
Pointer to root bones (can now have multiple roots)
Definition: OgreSkeleton.h:425
Ogre::SkeletonInstance
A SkeletonInstance is a single instance of a Skeleton used by a world object.
Definition: OgreSkeletonInstance.h:53
Ogre::Bone
A bone in a skeleton.
Definition: OgreBone.h:51
Ogre::Skeleton::BoneList
vector< Bone * >::type BoneList
Definition: OgreSkeleton.h:178
Ogre::Animation
An animation sequence.
Definition: OgreAnimation.h:92
Ogre::Skeleton::BoneIterator
VectorIterator< BoneList > BoneIterator
Definition: OgreSkeleton.h:179
OgreStringVector.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::set
Definition: OgrePrerequisites.h:519
Ogre::Skeleton::mManualBones
BoneSet mManualBones
Manual bones.
Definition: OgreSkeleton.h:430
OgreHeaderSuffix.h
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::Skeleton::hasManualBones
virtual bool hasManualBones(void) const
Are there any manually controlled bones?
Definition: OgreSkeleton.h:359
Ogre::Skeleton::BoneHandleMap
vector< ushort >::type BoneHandleMap
Map to translate bone handle from one skeleton to another skeleton.
Definition: OgreSkeleton.h:362
OgreIteratorWrappers.h
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Skeleton::BoneSet
set< Bone * >::type BoneSet
Definition: OgreSkeleton.h:428
Ogre::LinkedSkeletonAnimationSource::LinkedSkeletonAnimationSource
LinkedSkeletonAnimationSource(const String &skelName, Real scl, SkeletonPtr skelPtr)
Definition: OgreSkeleton.h:474
Ogre::SharedPtr< Skeleton >
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreAnimation.h
OgreHeaderPrefix.h
Ogre::LinkedSkeletonAnimationSource::LinkedSkeletonAnimationSource
LinkedSkeletonAnimationSource(const String &skelName, Real scl)
Definition: OgreSkeleton.h:472
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::SkeletonPtr
SharedPtr< Skeleton > SkeletonPtr
Definition: OgrePrerequisites.h:318
Ogre::LinkedSkeletonAnimationSource::scale
Real scale
Definition: OgreSkeleton.h:471
Ogre::Skeleton::getManualBonesDirty
virtual bool getManualBonesDirty(void) const
Have manual bones been modified since the skeleton was last updated?
Definition: OgreSkeleton.h:357
Ogre::LinkedSkeletonAnimationSource::skeletonName
String skeletonName
Definition: OgreSkeleton.h:469
Ogre::Skeleton::mLinkedSkeletonAnimSourceList
LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList
List of references to other skeletons to use animations from.
Definition: OgreSkeleton.h:440

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