[1809] | 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-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | #ifndef __SkeletonInstance_H__
|
---|
| 27 | #define __SkeletonInstance_H__
|
---|
| 28 |
|
---|
| 29 | #include "OgrePrerequisites.h"
|
---|
| 30 | #include "OgreSkeleton.h"
|
---|
| 31 |
|
---|
| 32 | namespace Ogre {
|
---|
| 33 |
|
---|
| 34 | /** A SkeletonInstance is a single instance of a Skeleton used by a world object.
|
---|
| 35 | @remarks
|
---|
| 36 | The difference between a Skeleton and a SkeletonInstance is that the
|
---|
| 37 | Skeleton is the 'master' version much like Mesh is a 'master' version of
|
---|
| 38 | Entity. Many SkeletonInstance objects can be based on a single Skeleton,
|
---|
| 39 | and are copies of it when created. Any changes made to this are not
|
---|
| 40 | reflected in the master copy. The exception is animations; these are
|
---|
| 41 | shared on the Skeleton itself and may not be modified here.
|
---|
| 42 | */
|
---|
| 43 | class _OgreExport SkeletonInstance : public Skeleton
|
---|
| 44 | {
|
---|
| 45 | public:
|
---|
| 46 | /** Constructor, don't call directly, this will be created automatically
|
---|
| 47 | when you create an Entity based on a skeletally animated Mesh.
|
---|
| 48 | */
|
---|
| 49 | SkeletonInstance(const SkeletonPtr& masterCopy);
|
---|
| 50 | ~SkeletonInstance();
|
---|
| 51 |
|
---|
| 52 | /** Gets the number of animations on this skeleton. */
|
---|
| 53 | unsigned short getNumAnimations(void) const;
|
---|
| 54 |
|
---|
| 55 | /** Gets a single animation by index. */
|
---|
| 56 | Animation* getAnimation(unsigned short index) const;
|
---|
| 57 | /// Internal accessor for animations (returns null if animation does not exist)
|
---|
| 58 | Animation* _getAnimationImpl(const String& name,
|
---|
| 59 | const LinkedSkeletonAnimationSource** linker = 0) const;
|
---|
| 60 |
|
---|
| 61 | /** Creates a new Animation object for animating this skeleton.
|
---|
| 62 | @remarks
|
---|
| 63 | This method updates the reference skeleton, not just this instance!
|
---|
| 64 | @param name The name of this animation
|
---|
| 65 | @param length The length of the animation in seconds
|
---|
| 66 | */
|
---|
| 67 | Animation* createAnimation(const String& name, Real length);
|
---|
| 68 |
|
---|
| 69 | /** Returns the named Animation object. */
|
---|
| 70 | Animation* getAnimation(const String& name,
|
---|
| 71 | const LinkedSkeletonAnimationSource** linker = 0) const;
|
---|
| 72 |
|
---|
| 73 | /** Removes an Animation from this skeleton.
|
---|
| 74 | @remarks
|
---|
| 75 | This method updates the reference skeleton, not just this instance!
|
---|
| 76 | */
|
---|
| 77 | void removeAnimation(const String& name);
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | /** Creates a TagPoint ready to be attached to a bone */
|
---|
| 81 | TagPoint* createTagPointOnBone(Bone* bone,
|
---|
| 82 | const Quaternion &offsetOrientation = Quaternion::IDENTITY,
|
---|
| 83 | const Vector3 &offsetPosition = Vector3::ZERO);
|
---|
| 84 |
|
---|
| 85 | /** Frees a TagPoint that already attached to a bone */
|
---|
| 86 | void freeTagPoint(TagPoint* tagPoint);
|
---|
| 87 |
|
---|
| 88 | /// @copydoc Skeleton::addLinkedSkeletonAnimationSource
|
---|
| 89 | void addLinkedSkeletonAnimationSource(const String& skelName,
|
---|
| 90 | Real scale = 1.0f);
|
---|
| 91 | /// @copydoc Skeleton::removeAllLinkedSkeletonAnimationSources
|
---|
| 92 | void removeAllLinkedSkeletonAnimationSources(void);
|
---|
| 93 | /// @copydoc Skeleton::getLinkedSkeletonAnimationSourceIterator
|
---|
| 94 | LinkedSkeletonAnimSourceIterator
|
---|
| 95 | getLinkedSkeletonAnimationSourceIterator(void) const;
|
---|
| 96 |
|
---|
| 97 | /// @copydoc Skeleton::_initAnimationState
|
---|
| 98 | void _initAnimationState(AnimationStateSet* animSet);
|
---|
| 99 |
|
---|
| 100 | /// @copydoc Skeleton::_refreshAnimationState
|
---|
| 101 | void _refreshAnimationState(AnimationStateSet* animSet);
|
---|
| 102 |
|
---|
| 103 | /// @copydoc Resource::getName
|
---|
| 104 | const String& getName(void) const;
|
---|
| 105 | /// @copydoc Resource::getHandle
|
---|
| 106 | ResourceHandle getHandle(void) const;
|
---|
| 107 | /// @copydoc Resource::getGroup
|
---|
| 108 | const String& getGroup(void);
|
---|
| 109 |
|
---|
| 110 | protected:
|
---|
| 111 | /// Pointer back to master Skeleton
|
---|
| 112 | SkeletonPtr mSkeleton;
|
---|
| 113 |
|
---|
| 114 | typedef std::list<TagPoint*> ActiveTagPointList;
|
---|
| 115 | typedef std::deque<TagPoint*> FreeTagPointQueue;
|
---|
| 116 |
|
---|
| 117 | /** Active tag point list.
|
---|
| 118 | @remarks
|
---|
| 119 | This is a linked list of pointers to actived tag point
|
---|
| 120 | @par
|
---|
| 121 | This allows very fast instertions and deletions from anywhere in the list to activate / deactivate
|
---|
| 122 | tag points (required for weapon / equip systems etc) as well as resuse of TagPoint instances
|
---|
| 123 | without construction & destruction which avoids memory thrashing.
|
---|
| 124 | */
|
---|
| 125 | ActiveTagPointList mActiveTagPoints;
|
---|
| 126 |
|
---|
| 127 | /** Free tag point queue.
|
---|
| 128 | @remarks
|
---|
| 129 | This contains a list of the tag points free for use as new instances
|
---|
| 130 | as required by the set. When a TagPoint instances are deactived, there will are referenced on this
|
---|
| 131 | deque. As they get used this deque reduces, as they get released back to to the set they get added
|
---|
| 132 | back to the deque.
|
---|
| 133 | */
|
---|
| 134 | FreeTagPointQueue mFreeTagPoints;
|
---|
| 135 |
|
---|
| 136 | /// TagPoint automatic handles
|
---|
| 137 | unsigned short mNextTagPointAutoHandle;
|
---|
| 138 |
|
---|
| 139 | void cloneBoneAndChildren(Bone* source, Bone* parent);
|
---|
| 140 | /** Overridden from Skeleton
|
---|
| 141 | */
|
---|
| 142 | void loadImpl(void);
|
---|
| 143 | /** Overridden from Skeleton
|
---|
| 144 | */
|
---|
| 145 | void unloadImpl(void);
|
---|
| 146 |
|
---|
| 147 | };
|
---|
| 148 |
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | #endif
|
---|
| 153 |
|
---|