OGRE: OgreAnimationState.h Source File - OGRE Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# OgreAnimationState.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029
    00030 #ifndef __AnimationSet_H__
    00031 #define __AnimationSet_H__
    00032
    00033 #include "OgrePrerequisites.h"
    00034
    00035 #include "OgreString.h"
    00036 #include "OgreController.h"
    00037 #include "OgreIteratorWrappers.h"
    00038
    00039 namespace Ogre {
    00040
    00046     class _OgreExport AnimationState
    00047     {
    00048     public:
    00050         AnimationState(const String& animName, AnimationStateSet *parent,
    00051             Real timePos, Real length, Real weight = 1.0, bool enabled = false);
    00053         AnimationState(AnimationStateSet* parent, const AnimationState &rhs);
    00057         virtual ~AnimationState();
    00058
    00060         const String& getAnimationName() const;
    00062         Real getTimePosition(void) const;
    00064         void setTimePosition(Real timePos);
    00066         Real getLength() const;
    00068         void setLength(Real len);
    00070         Real getWeight(void) const;
    00072         void setWeight(Real weight);
    00077         void addTime(Real offset);
    00078
    00080         bool hasEnded(void) const;
    00081
    00083         bool getEnabled(void) const;
    00085         void setEnabled(bool enabled);
    00086
    00088         bool operator==(const AnimationState& rhs) const;
    00089         // Inequality operator
    00090         bool operator!=(const AnimationState& rhs) const;
    00091
    00095         void setLoop(bool loop) { mLoop = loop; }
    00097         bool getLoop(void) const { return mLoop; }
    00098
    00103         void copyStateFrom(const AnimationState& animState);
    00104
    00106         AnimationStateSet* getParent(void) const { return mParent; }
    00107
    00108     protected:
    00109         String mAnimationName;
    00110         AnimationStateSet* mParent;
    00111         Real mTimePos;
    00112         Real mLength;
    00113         Real mWeight;
    00114         bool mEnabled;
    00115         bool mLoop;
    00116
    00117     };
    00118
    00119     // A map of animation states
    00120     typedef std::map<String, AnimationState*> AnimationStateMap;
    00121     typedef MapIterator<AnimationStateMap> AnimationStateIterator;
    00122     typedef ConstMapIterator<AnimationStateMap> ConstAnimationStateIterator;
    00123     // A list of enabled animation states
    00124     typedef std::list<AnimationState*> EnabledAnimationStateList;
    00125     typedef ConstVectorIterator<EnabledAnimationStateList> ConstEnabledAnimationStateIterator;
    00126
    00129     class _OgreExport AnimationStateSet
    00130     {
    00131     public:
    00133         OGRE_AUTO_MUTEX
    00135         AnimationStateSet();
    00137         AnimationStateSet(const AnimationStateSet& rhs);
    00138
    00139         ~AnimationStateSet();
    00140
    00148         AnimationState* createAnimationState(const String& animName,
    00149             Real timePos, Real length, Real weight = 1.0, bool enabled = false);
    00151         AnimationState* getAnimationState(const String& name) const;
    00153         bool hasAnimationState(const String& name) const;
    00155         void removeAnimationState(const String& name);
    00157         void removeAllAnimationStates(void);
    00158
    00165         AnimationStateIterator getAnimationStateIterator(void);
    00172         ConstAnimationStateIterator getAnimationStateIterator(void) const;
    00174         void copyMatchingState(AnimationStateSet* target) const;
    00176         void _notifyDirty(void);
    00178         unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; }
    00179
    00181         void _notifyAnimationStateEnabled(AnimationState* target, bool enabled);
    00183         bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); }
    00190         ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const;
    00191
    00192     protected:
    00193         unsigned long mDirtyFrameNumber;
    00194         AnimationStateMap mAnimationStates;
    00195         EnabledAnimationStateList mEnabledAnimationStates;
    00196
    00197     };
    00198
    00207     class _OgreExport AnimationStateControllerValue : public ControllerValue<Real>
    00208     {
    00209     protected:
    00210         AnimationState* mTargetAnimationState;
    00211     public:
    00213         AnimationStateControllerValue(AnimationState* targetAnimationState)
    00214             : mTargetAnimationState(targetAnimationState) {}
    00216         ~AnimationStateControllerValue() {}
    00218         Real getValue(void) const;
    00219
    00221         void setValue(Real value);
    00222
    00223     };
    00224
    00225
    00226 }
    00227
    00228 #endif
    00229

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:25 2008