Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreSkeletonInstance.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

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