# 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-2005 The OGRE Team
    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 */
    00025
    00026 #ifndef __AnimationSet_H__
    00027 #define __AnimationSet_H__
    00028
    00029 #include "OgrePrerequisites.h"
    00030
    00031 #include "OgreString.h"
    00032 #include "OgreController.h"
    00033 #include "OgreIteratorWrappers.h"
    00034
    00035 namespace Ogre {
    00036
    00042     class _OgreExport AnimationState
    00043     {
    00044     public:
    00046         AnimationState(const String& animName, AnimationStateSet *parent,
    00047             Real timePos, Real length, Real weight = 1.0, bool enabled = false);
    00049         AnimationState(AnimationStateSet* parent, const AnimationState &rhs);
    00053         virtual ~AnimationState();
    00054
    00056         const String& getAnimationName() const;
    00058         Real getTimePosition(void) const;
    00060         void setTimePosition(Real timePos);
    00062         Real getLength() const;
    00064         void setLength(Real len);
    00066         Real getWeight(void) const;
    00068         void setWeight(Real weight);
    00073         void addTime(Real offset);
    00074
    00076         bool getEnabled(void) const;
    00078         void setEnabled(bool enabled);
    00079
    00081         bool operator==(const AnimationState& rhs) const;
    00082         // Inequality operator
    00083         bool operator!=(const AnimationState& rhs) const;
    00084
    00088         void setLoop(bool loop) { mLoop = loop; }
    00090         bool getLoop(void) const { return mLoop; }
    00091
    00096         void copyStateFrom(const AnimationState& animState);
    00097
    00099         AnimationStateSet* getParent(void) const { return mParent; }
    00100
    00101     protected:
    00102         String mAnimationName;
    00103         AnimationStateSet* mParent;
    00104         Real mTimePos;
    00105         Real mLength;
    00106         Real mInvLength;
    00107         Real mWeight;
    00108         bool mEnabled;
    00109         bool mLoop;
    00110
    00111     };
    00112
    00113     // A map of animation states
    00114     typedef std::map<String, AnimationState*> AnimationStateMap;
    00115     typedef MapIterator<AnimationStateMap> AnimationStateIterator;
    00116     typedef ConstMapIterator<AnimationStateMap> ConstAnimationStateIterator;
    00117     // A list of enabled animation states
    00118     typedef std::list<AnimationState*> EnabledAnimationStateList;
    00119     typedef ConstVectorIterator<EnabledAnimationStateList> ConstEnabledAnimationStateIterator;
    00120
    00123     class _OgreExport AnimationStateSet
    00124     {
    00125     public:
    00127         AnimationStateSet();
    00129         AnimationStateSet(const AnimationStateSet& rhs);
    00130
    00131         ~AnimationStateSet();
    00132
    00140         AnimationState* createAnimationState(const String& animName,
    00141             Real timePos, Real length, Real weight = 1.0, bool enabled = false);
    00143         AnimationState* getAnimationState(const String& name) const;
    00145         bool hasAnimationState(const String& name) const;
    00147         void removeAnimationState(const String& name);
    00149         void removeAllAnimationStates(void);
    00150
    00152         AnimationStateIterator getAnimationStateIterator(void);
    00154         ConstAnimationStateIterator getAnimationStateIterator(void) const;
    00156         void copyMatchingState(AnimationStateSet* target) const;
    00158         void _notifyDirty(void);
    00160         unsigned long getDirtyFrameNumber(void) const { return mDirtyFrameNumber; }
    00161
    00163         void _notifyAnimationStateEnabled(AnimationState* target, bool enabled);
    00165         bool hasEnabledAnimationState(void) const { return !mEnabledAnimationStates.empty(); }
    00167         ConstEnabledAnimationStateIterator getEnabledAnimationStateIterator(void) const;
    00168
    00169     protected:
    00170         unsigned long mDirtyFrameNumber;
    00171         AnimationStateMap mAnimationStates;
    00172         EnabledAnimationStateList mEnabledAnimationStates;
    00173
    00174     };
    00175
    00184     class _OgreExport AnimationStateControllerValue : public ControllerValue<Real>
    00185     {
    00186     protected:
    00187         AnimationState* mTargetAnimationState;
    00188     public:
    00190         AnimationStateControllerValue(AnimationState* targetAnimationState)
    00191             : mTargetAnimationState(targetAnimationState) {}
    00193         ~AnimationStateControllerValue() {}
    00195         Real getValue(void) const;
    00196
    00198         void setValue(Real value);
    00199
    00200     };
    00201
    00202
    00203 }
    00204
    00205 #endif
    00206

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 17 15:39:07 2006