Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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 
00072     class _OgreExport Skeleton : public Resource
00073     {
00074         friend class SkeletonInstance;
00075     protected:
00077         Skeleton();
00078 
00079     public:
00086         Skeleton(ResourceManager* creator, const String& name, ResourceHandle handle,
00087             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
00088         virtual ~Skeleton();
00089 
00090 
00104         virtual Bone* createBone(void);
00105 
00120         virtual Bone* createBone(unsigned short handle);
00121 
00136         virtual Bone* createBone(const String& name);
00137 
00149         virtual Bone* createBone(const String& name, unsigned short handle);
00150 
00152         virtual unsigned short getNumBones(void) const;
00153 
00165         virtual Bone* getRootBone(void) const;
00166 
00167         typedef std::vector<Bone*> BoneList;
00168         typedef VectorIterator<BoneList> BoneIterator;
00170         virtual BoneIterator getRootBoneIterator(void);
00172         virtual BoneIterator getBoneIterator(void);
00173 
00175         virtual Bone* getBone(unsigned short handle) const;
00176 
00178         virtual Bone* getBone(const String& name) const;
00179 
00183         virtual void setBindingPose(void);
00184 
00194         virtual void reset(bool resetManualBones = false);
00195 
00200         virtual Animation* createAnimation(const String& name, Real length);
00201 
00203         virtual Animation* getAnimation(const String& name) const;
00204 
00206         virtual void removeAnimation(const String& name);
00207 
00219         virtual void setAnimationState(const AnimationStateSet& animSet);
00220 
00222         virtual const AnimationStateSet& getAnimationState(void) const;
00223         
00224 
00229         virtual void _initAnimationState(AnimationStateSet* animSet);
00230 
00237         virtual void _getBoneMatrices(Matrix4* pMatrices);
00238 
00240         virtual unsigned short getNumAnimations(void) const;
00241 
00243         virtual Animation* getAnimation(unsigned short index) const;
00244 
00245 
00247         virtual SkeletonAnimationBlendMode getBlendMode();
00249         virtual void setBlendMode(SkeletonAnimationBlendMode state);
00250 
00252         virtual void _updateTransforms(void);
00253 
00254 
00255     protected:
00256         SkeletonAnimationBlendMode mBlendState;
00258         BoneList mBoneList;
00260         typedef std::map<String, Bone*> BoneListByName;
00261         BoneListByName mBoneListByName;
00262 
00263 
00265         mutable BoneList mRootBones;
00267         unsigned short mNextAutoHandle;
00268 
00269 
00271         typedef std::map<String, Animation*> AnimationList;
00272         AnimationList mAnimationsList;
00273 
00274 
00276         AnimationStateSet mLastAnimationState;
00277 
00283         void deriveRootBone(void) const;
00284 
00286         void _dumpContents(const String& filename);
00287 
00290         void loadImpl(void);
00291 
00294         void unloadImpl(void);
00296         size_t calculateSize(void) const { return 0; } // TODO 
00297 
00298     };
00299 
00306     class _OgreExport SkeletonPtr : public SharedPtr<Skeleton> 
00307     {
00308     public:
00309         SkeletonPtr() : SharedPtr<Skeleton>() {}
00310         explicit SkeletonPtr(Skeleton* rep) : SharedPtr<Skeleton>(rep) {}
00311         SkeletonPtr(const SkeletonPtr& r) : SharedPtr<Skeleton>(r) {} 
00312         SkeletonPtr(const ResourcePtr& r) : SharedPtr<Skeleton>()
00313         {
00314             // lock & copy other mutex pointer
00315             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00316             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00317             pRep = static_cast<Skeleton*>(r.getPointer());
00318             pUseCount = r.useCountPointer();
00319             if (pUseCount)
00320             {
00321                 ++(*pUseCount);
00322             }
00323         }
00324 
00326         SkeletonPtr& operator=(const ResourcePtr& r)
00327         {
00328             if (pRep == static_cast<Skeleton*>(r.getPointer()))
00329                 return *this;
00330             release();
00331             // lock & copy other mutex pointer
00332             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00333             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00334             pRep = static_cast<Skeleton*>(r.getPointer());
00335             pUseCount = r.useCountPointer();
00336             if (pUseCount)
00337             {
00338                 ++(*pUseCount);
00339             }
00340             return *this;
00341         }
00342     };
00343 
00344 }
00345 
00346 
00347 #endif
00348 

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:23 2005