source: GTP/trunk/App/Demos/Geom/include/OgreAnimationState.h @ 1030

Revision 1030, 5.3 KB checked in by gumbau, 18 years ago (diff)

Ogre Stuff initial import

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 __AnimationSet_H__
27#define __AnimationSet_H__
28
29#include "OgrePrerequisites.h"
30
31#include "OgreString.h"
32#include "OgreController.h"
33#include "OgreIteratorWrappers.h"
34
35namespace Ogre {
36
37    /** Represents the state of an animation and the weight of it's influence.
38    @remarks
39        Other classes can hold instances of this class to store the state of any animations
40        they are using.
41        This class implements the ControllerValue interface to enable automatic update of
42        animation state through controllers.
43    */
44    class _OgreExport AnimationState : public ControllerValue<Real>
45    {
46    public:
47        /// Default constructor for STL only
48        AnimationState();
49                /** Destructor - is here because class has virtual functions and some compilers
50                        would whine if it won't exist.
51                */
52                virtual ~AnimationState();
53       
54        /// Normal constructor with all params supplied
55        AnimationState(const String& animName, Real timePos, Real length, Real weight = 1.0, bool enabled = false);
56        /// Gets the name of the animation to which this state applies
57        const String& getAnimationName() const;
58        /// Sets the name of the animation to which this state applies
59        void setAnimationName(const String& name);
60        /// Gets the time position for this animation
61        Real getTimePosition(void) const;
62        /// Sets the time position for this animation
63        void setTimePosition(Real timePos);
64        /// Gets the total length of this animation (may be shorter than whole animation)
65        Real getLength() const;
66        /// Sets the total length of this animation (may be shorter than whole animation)
67        void setLength(Real len);
68        /// Gets the weight (influence) of this animation
69        Real getWeight(void) const;
70        /// Sets the weight (influence) of this animation
71        void setWeight(Real weight);
72        /** Modifies the time position, adjusting for animation length
73        @remarks
74            This method loops at the edges if animation looping is enabled.
75        */
76        void addTime(Real offset);
77
78        /// Returns true if this animation is currently enabled
79        bool getEnabled(void) const;
80        /// Sets whether this animation is enabled
81        void setEnabled(bool enabled);
82
83        /// Equality operator
84        bool operator==(const AnimationState& rhs) const;
85        // Inequality operator
86        bool operator!=(const AnimationState& rhs) const;
87
88        /** ControllerValue implementation. */
89        Real getValue(void) const;
90
91        /** ControllerValue implementation. */
92        void setValue(Real value);
93        /** Sets whether or not an animation loops at the start and end of
94            the animation if the time continues to be altered.
95        */
96        void setLoop(bool loop) { mLoop = loop; }
97        /// Gets whether or not this animation loops           
98        bool getLoop(void) const { return mLoop; }
99     
100        /** Copies the states from another animation state, preserving the animation name
101        (unlike operator=) but copying everything else.
102        @param animState Reference to animation state which will use as source.
103        */
104        void copyStateFrom(const AnimationState& animState);
105
106    protected:
107        String mAnimationName;
108        Real mTimePos;
109        Real mLength;
110        Real mInvLength;
111        Real mWeight;
112        bool mEnabled;
113        bool mLoop;
114
115    };
116
117    // A set of animation states
118    typedef std::map<String, AnimationState> AnimationStateSet;
119    typedef MapIterator<AnimationStateSet> AnimationStateIterator;
120
121    /** Copies a subset animation states from source to target.
122    @remarks
123        This routine assume target is a subset of source, it will copy all animation state
124        of the target with the settings from source.
125    @param target Reference to animation state set which will receive the states.
126    @param source Reference to animation state set which will use as source.
127    */
128    _OgreExport void CopyAnimationStateSubset(AnimationStateSet& target, const AnimationStateSet& source);
129
130}
131
132#endif
133
Note: See TracBrowser for help on using the repository browser.