# OgreSkeleton.h Source File - OGRE Documentation

# OgreSkeleton.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2005 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025
    00026 #ifndef __Skeleton_H__
    00027 #define __Skeleton_H__
    00028
    00029 #include "OgrePrerequisites.h"
    00030 #include "OgreResource.h"
    00031 #include "OgreAnimationState.h"
    00032 #include "OgreQuaternion.h"
    00033 #include "OgreVector3.h"
    00034
    00035 namespace Ogre {
    00036
    00038     enum SkeletonAnimationBlendMode {
    00040         ANIMBLEND_AVERAGE,
    00042         ANIMBLEND_CUMULATIVE
    00043     };
    00044
    00045 #define OGRE_MAX_NUM_BONES 256
    00046
    00047
    00048     struct LinkedSkeletonAnimationSource;
    00049
    00075     class _OgreExport Skeleton : public Resource
    00076     {
    00077         friend class SkeletonInstance;
    00078     protected:
    00080         Skeleton();
    00081
    00082     public:
    00089         Skeleton(ResourceManager* creator, const String& name, ResourceHandle handle,
    00090             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
    00091         virtual ~Skeleton();
    00092
    00093
    00107         virtual Bone* createBone(void);
    00108
    00123         virtual Bone* createBone(unsigned short handle);
    00124
    00139         virtual Bone* createBone(const String& name);
    00140
    00152         virtual Bone* createBone(const String& name, unsigned short handle);
    00153
    00155         virtual unsigned short getNumBones(void) const;
    00156
    00168         virtual Bone* getRootBone(void) const;
    00169
    00170         typedef std::vector<Bone*> BoneList;
    00171         typedef VectorIterator<BoneList> BoneIterator;
    00173         virtual BoneIterator getRootBoneIterator(void);
    00175         virtual BoneIterator getBoneIterator(void);
    00176
    00178         virtual Bone* getBone(unsigned short handle) const;
    00179
    00181         virtual Bone* getBone(const String& name) const;
    00182
    00186         virtual void setBindingPose(void);
    00187
    00197         virtual void reset(bool resetManualBones = false);
    00198
    00203         virtual Animation* createAnimation(const String& name, Real length);
    00204
    00213         virtual Animation* getAnimation(const String& name,
    00214             const LinkedSkeletonAnimationSource** linker = 0) const;
    00215
    00217         virtual void removeAnimation(const String& name);
    00218
    00230         virtual void setAnimationState(const AnimationStateSet& animSet);
    00231
    00233         virtual const AnimationStateSet& getAnimationState(void) const;
    00234
    00235
    00240         virtual void _initAnimationState(AnimationStateSet* animSet);
    00241
    00246         virtual void _refreshAnimationState(AnimationStateSet* animSet);
    00247
    00254         virtual void _getBoneMatrices(Matrix4* pMatrices);
    00255
    00257         virtual unsigned short getNumAnimations(void) const;
    00258
    00264         virtual Animation* getAnimation(unsigned short index) const;
    00265
    00266
    00268         virtual SkeletonAnimationBlendMode getBlendMode();
    00270         virtual void setBlendMode(SkeletonAnimationBlendMode state);
    00271
    00273         virtual void _updateTransforms(void);
    00274
    00278         virtual void optimiseAllAnimations(void);
    00279
    00313         virtual void addLinkedSkeletonAnimationSource(const String& skelName,
    00314             Real scale = 1.0f);
    00316         virtual void removeAllLinkedSkeletonAnimationSources(void);
    00317
    00318         typedef std::vector<LinkedSkeletonAnimationSource>
    00319             LinkedSkeletonAnimSourceList;
    00320         typedef ConstVectorIterator<LinkedSkeletonAnimSourceList>
    00321             LinkedSkeletonAnimSourceIterator;
    00323         virtual LinkedSkeletonAnimSourceIterator
    00324             getLinkedSkeletonAnimationSourceIterator(void) const;
    00325
    00326     protected:
    00327         SkeletonAnimationBlendMode mBlendState;
    00329         BoneList mBoneList;
    00331         typedef std::map<String, Bone*> BoneListByName;
    00332         BoneListByName mBoneListByName;
    00333
    00334
    00336         mutable BoneList mRootBones;
    00338         unsigned short mNextAutoHandle;
    00339
    00340
    00342         typedef std::map<String, Animation*> AnimationList;
    00343         AnimationList mAnimationsList;
    00344
    00346         AnimationStateSet mLastAnimationState;
    00347
    00349         mutable LinkedSkeletonAnimSourceList mLinkedSkeletonAnimSourceList;
    00350
    00356         void deriveRootBone(void) const;
    00357
    00359         void _dumpContents(const String& filename);
    00360
    00363         void loadImpl(void);
    00364
    00367         void unloadImpl(void);
    00369         size_t calculateSize(void) const { return 0; } // TODO
    00370
    00371     };
    00372
    00379     class _OgreExport SkeletonPtr : public SharedPtr<Skeleton>
    00380     {
    00381     public:
    00382         SkeletonPtr() : SharedPtr<Skeleton>() {}
    00383         explicit SkeletonPtr(Skeleton* rep) : SharedPtr<Skeleton>(rep) {}
    00384         SkeletonPtr(const SkeletonPtr& r) : SharedPtr<Skeleton>(r) {}
    00385         SkeletonPtr(const ResourcePtr& r) : SharedPtr<Skeleton>()
    00386         {
    00387             // lock & copy other mutex pointer
    00388             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00389             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00390             pRep = static_cast<Skeleton*>(r.getPointer());
    00391             pUseCount = r.useCountPointer();
    00392             if (pUseCount)
    00393             {
    00394                 ++(*pUseCount);
    00395             }
    00396         }
    00397
    00399         SkeletonPtr& operator=(const ResourcePtr& r)
    00400         {
    00401             if (pRep == static_cast<Skeleton*>(r.getPointer()))
    00402                 return *this;
    00403             release();
    00404             // lock & copy other mutex pointer
    00405             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00406             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00407             pRep = static_cast<Skeleton*>(r.getPointer());
    00408             pUseCount = r.useCountPointer();
    00409             if (pUseCount)
    00410             {
    00411                 ++(*pUseCount);
    00412             }
    00413             return *this;
    00414         }
    00415     };
    00416
    00418     struct LinkedSkeletonAnimationSource
    00419     {
    00420         String skeletonName;
    00421         SkeletonPtr pSkeleton;
    00422         Real scale;
    00423         LinkedSkeletonAnimationSource(const String& skelName, Real scl)
    00424             : skeletonName(skelName), scale(scl) {}
    00425             LinkedSkeletonAnimationSource(const String& skelName, Real scl,
    00426                 SkeletonPtr skelPtr)
    00427                 : skeletonName(skelName), pSkeleton(skelPtr), scale(scl) {}
    00428     };
    00429 }
    00430
    00431
    00432 #endif
    00433

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Sep 25 17:36:01 2005