[148] | 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-2013 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 __SkeletonInstance_H__ |
---|
| 30 | #define __SkeletonInstance_H__ |
---|
| 31 | |
---|
| 32 | #include "OgrePrerequisites.h" |
---|
| 33 | #include "OgreSkeleton.h" |
---|
| 34 | #include "OgreHeaderPrefix.h" |
---|
| 35 | |
---|
| 36 | namespace Ogre { |
---|
| 37 | |
---|
| 38 | /** \addtogroup Core |
---|
| 39 | * @{ |
---|
| 40 | */ |
---|
| 41 | /** \addtogroup Scene |
---|
| 42 | * @{ |
---|
| 43 | */ |
---|
| 44 | /** A SkeletonInstance is a single instance of a Skeleton used by a world object. |
---|
| 45 | @remarks |
---|
| 46 | The difference between a Skeleton and a SkeletonInstance is that the |
---|
| 47 | Skeleton is the 'master' version much like Mesh is a 'master' version of |
---|
| 48 | Entity. Many SkeletonInstance objects can be based on a single Skeleton, |
---|
| 49 | and are copies of it when created. Any changes made to this are not |
---|
| 50 | reflected in the master copy. The exception is animations; these are |
---|
| 51 | shared on the Skeleton itself and may not be modified here. |
---|
| 52 | */ |
---|
| 53 | class _OgreExport SkeletonInstance : public Skeleton |
---|
| 54 | { |
---|
| 55 | public: |
---|
| 56 | /** Constructor, don't call directly, this will be created automatically |
---|
| 57 | when you create an Entity based on a skeletally animated Mesh. |
---|
| 58 | */ |
---|
| 59 | SkeletonInstance(const SkeletonPtr& masterCopy); |
---|
| 60 | ~SkeletonInstance(); |
---|
| 61 | |
---|
| 62 | /** Gets the number of animations on this skeleton. */ |
---|
| 63 | unsigned short getNumAnimations(void) const; |
---|
| 64 | |
---|
| 65 | /** Gets a single animation by index. */ |
---|
| 66 | Animation* getAnimation(unsigned short index) const; |
---|
| 67 | /// Internal accessor for animations (returns null if animation does not exist) |
---|
| 68 | Animation* _getAnimationImpl(const String& name, |
---|
| 69 | const LinkedSkeletonAnimationSource** linker = 0) const; |
---|
| 70 | |
---|
| 71 | /** Creates a new Animation object for animating this skeleton. |
---|
| 72 | @remarks |
---|
| 73 | This method updates the reference skeleton, not just this instance! |
---|
| 74 | @param name The name of this animation |
---|
| 75 | @param length The length of the animation in seconds |
---|
| 76 | */ |
---|
| 77 | Animation* createAnimation(const String& name, Real length); |
---|
| 78 | |
---|
| 79 | /** Returns the named Animation object. */ |
---|
| 80 | Animation* getAnimation(const String& name, |
---|
| 81 | const LinkedSkeletonAnimationSource** linker = 0) const; |
---|
| 82 | |
---|
| 83 | /** Removes an Animation from this skeleton. |
---|
| 84 | @remarks |
---|
| 85 | This method updates the reference skeleton, not just this instance! |
---|
| 86 | */ |
---|
| 87 | void removeAnimation(const String& name); |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | /** Creates a TagPoint ready to be attached to a bone */ |
---|
| 91 | TagPoint* createTagPointOnBone(Bone* bone, |
---|
| 92 | const Quaternion &offsetOrientation = Quaternion::IDENTITY, |
---|
| 93 | const Vector3 &offsetPosition = Vector3::ZERO); |
---|
| 94 | |
---|
| 95 | /** Frees a TagPoint that already attached to a bone */ |
---|
| 96 | void freeTagPoint(TagPoint* tagPoint); |
---|
| 97 | |
---|
| 98 | /// @copydoc Skeleton::addLinkedSkeletonAnimationSource |
---|
| 99 | void addLinkedSkeletonAnimationSource(const String& skelName, |
---|
| 100 | Real scale = 1.0f); |
---|
| 101 | /// @copydoc Skeleton::removeAllLinkedSkeletonAnimationSources |
---|
| 102 | void removeAllLinkedSkeletonAnimationSources(void); |
---|
| 103 | /// @copydoc Skeleton::getLinkedSkeletonAnimationSourceIterator |
---|
| 104 | LinkedSkeletonAnimSourceIterator |
---|
| 105 | getLinkedSkeletonAnimationSourceIterator(void) const; |
---|
| 106 | |
---|
| 107 | /// @copydoc Skeleton::_initAnimationState |
---|
| 108 | void _initAnimationState(AnimationStateSet* animSet); |
---|
| 109 | |
---|
| 110 | /// @copydoc Skeleton::_refreshAnimationState |
---|
| 111 | void _refreshAnimationState(AnimationStateSet* animSet); |
---|
| 112 | |
---|
| 113 | /// @copydoc Resource::getName |
---|
| 114 | const String& getName(void) const; |
---|
| 115 | /// @copydoc Resource::getHandle |
---|
| 116 | ResourceHandle getHandle(void) const; |
---|
| 117 | /// @copydoc Resource::getGroup |
---|
| 118 | const String& getGroup(void); |
---|
| 119 | |
---|
| 120 | protected: |
---|
| 121 | /// Pointer back to master Skeleton |
---|
| 122 | SkeletonPtr mSkeleton; |
---|
| 123 | |
---|
| 124 | typedef list<TagPoint*>::type TagPointList; |
---|
| 125 | |
---|
| 126 | /** Active tag point list. |
---|
| 127 | @remarks |
---|
| 128 | This is a linked list of pointers to active tag points |
---|
| 129 | @par |
---|
| 130 | This allows very fast insertions and deletions from anywhere in the list to activate / deactivate |
---|
| 131 | tag points (required for weapon / equip systems etc) as well as reuse of TagPoint instances |
---|
| 132 | without construction & destruction which avoids memory thrashing. |
---|
| 133 | */ |
---|
| 134 | TagPointList mActiveTagPoints; |
---|
| 135 | |
---|
| 136 | /** Free tag point list. |
---|
| 137 | @remarks |
---|
| 138 | This contains a list of the tag points free for use as new instances |
---|
| 139 | as required by the set. When a TagPoint instance is deactivated, there will be a reference on this |
---|
| 140 | list. As they get used this list reduces, as they get released back to to the set they get added |
---|
| 141 | back to the list. |
---|
| 142 | */ |
---|
| 143 | TagPointList mFreeTagPoints; |
---|
| 144 | |
---|
| 145 | /// TagPoint automatic handles |
---|
| 146 | unsigned short mNextTagPointAutoHandle; |
---|
| 147 | |
---|
| 148 | void cloneBoneAndChildren(Bone* source, Bone* parent); |
---|
| 149 | /** Overridden from Skeleton |
---|
| 150 | */ |
---|
| 151 | void loadImpl(void); |
---|
| 152 | /** Overridden from Skeleton |
---|
| 153 | */ |
---|
| 154 | void unloadImpl(void); |
---|
| 155 | |
---|
| 156 | }; |
---|
| 157 | /** @} */ |
---|
| 158 | /** @} */ |
---|
| 159 | |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | #include "OgreHeaderSuffix.h" |
---|
| 163 | |
---|
| 164 | #endif |
---|
| 165 | |
---|