source: OGRE/trunk/ogrenew/OgreMain/include/OgreSkeletonInstance.h @ 692

Revision 692, 5.6 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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-2005 The OGRE Team
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-----------------------------------------------------------------------------
24*/
25
26#ifndef __SkeletonInstance_H__
27#define __SkeletonInstance_H__
28
29#include "OgrePrerequisites.h"
30#include "OgreSkeleton.h"
31
32namespace 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
58        /** Creates a new Animation object for animating this skeleton.
59        @remarks
60            This method updates the reference skeleton, not just this instance!
61        @param name The name of this animation
62        @param length The length of the animation in seconds
63        */
64        Animation* createAnimation(const String& name, Real length);
65
66        /** Returns the named Animation object. */
67        Animation* getAnimation(const String& name,
68                        const LinkedSkeletonAnimationSource** linker = 0) const;
69
70        /** Removes an Animation from this skeleton.
71        @remarks
72            This method updates the reference skeleton, not just this instance!
73        */
74        void removeAnimation(const String& name);
75
76
77        /** Creates a TagPoint ready to be attached to a bone */
78        TagPoint* createTagPointOnBone(Bone* bone,
79            const Quaternion &offsetOrientation = Quaternion::IDENTITY,
80            const Vector3         &offsetPosition    = Vector3::UNIT_SCALE);
81
82        /** Frees a TagPoint that already attached to a bone */
83        void freeTagPoint(TagPoint* tagPoint);
84
85                /// @copydoc Skeleton::addLinkedSkeletonAnimationSource
86                void addLinkedSkeletonAnimationSource(const String& skelName,
87                        Real scale = 1.0f);
88                /// @copydoc Skeleton::removeAllLinkedSkeletonAnimationSources
89                void removeAllLinkedSkeletonAnimationSources(void);
90                /// @copydoc Skeleton::getLinkedSkeletonAnimationSourceIterator
91                LinkedSkeletonAnimSourceIterator
92                        getLinkedSkeletonAnimationSourceIterator(void) const;
93
94                /// @copydoc Skeleton::_initAnimationState
95                void _initAnimationState(AnimationStateSet* animSet);
96
97                /// @copydoc Skeleton::_refreshAnimationState
98                void _refreshAnimationState(AnimationStateSet* animSet);
99    protected:
100        /// Pointer back to master Skeleton
101        SkeletonPtr mSkeleton;
102
103        typedef std::list<TagPoint*> ActiveTagPointList;
104        typedef std::deque<TagPoint*> FreeTagPointQueue;
105
106        /** Active tag point list.
107        @remarks
108            This is a linked list of pointers to actived tag point
109        @par
110            This allows very fast instertions and deletions from anywhere in the list to activate / deactivate
111            tag points (required for weapon / equip systems etc)    as well as resuse of TagPoint instances
112            without construction & destruction which avoids memory thrashing.
113        */
114        ActiveTagPointList mActiveTagPoints;
115
116        /** Free tag point queue.
117        @remarks
118            This contains a list of the tag points free for use as new instances
119            as required by the set. When a TagPoint instances are deactived, there will are referenced on this
120            deque. As they get used this deque reduces, as they get released back to to the set they get added
121            back to the deque.
122        */
123        FreeTagPointQueue mFreeTagPoints;
124
125        /// TagPoint automatic handles
126        unsigned short mNextTagPointAutoHandle;
127
128        void cloneBoneAndChildren(Bone* source, Bone* parent);
129        /** Overridden from Skeleton
130        */
131        void loadImpl(void);
132        /** Overridden from Skeleton
133        */
134        void unloadImpl(void);
135
136    };
137
138}
139
140
141#endif
142
Note: See TracBrowser for help on using the repository browser.