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

OgreAnimationTrack.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 __AnimationTrack_H__
00027 #define __AnimationTrack_H__
00028 
00029 #include "OgrePrerequisites.h"
00030 #include "OgreSimpleSpline.h"
00031 #include "OgreRotationalSpline.h"
00032 #include "OgreKeyFrame.h"
00033 #include "OgreAnimable.h"
00034 #include "OgrePose.h"
00035 
00036 namespace Ogre 
00037 {
00057     class _OgreExport AnimationTrack
00058     {
00059     public:
00061         AnimationTrack(Animation* parent, unsigned short handle);
00062 
00063         virtual ~AnimationTrack();
00064 
00066         unsigned short getHandle(void) const { return mHandle; }
00067 
00069         virtual unsigned short getNumKeyFrames(void) const;
00070 
00072         virtual KeyFrame* getKeyFrame(unsigned short index) const;
00073 
00095         virtual Real getKeyFramesAtTime(Real timePos, KeyFrame** keyFrame1, KeyFrame** keyFrame2,
00096             unsigned short* firstKeyIndex = 0) const;
00097 
00105         virtual KeyFrame* createKeyFrame(Real timePos);
00106 
00108         virtual void removeKeyFrame(unsigned short index);
00109 
00111         virtual void removeAllKeyFrames(void);
00112 
00113 
00123         virtual void getInterpolatedKeyFrame(Real timeIndex, KeyFrame* kf) const = 0;
00124 
00134         virtual void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00135             Real scale = 1.0f) = 0;
00136 
00139         virtual void _keyFrameDataChanged(void) const {}
00140 
00145         virtual bool hasNonZeroKeyFrames(void) const { return true; }
00146 
00148         virtual void optimise(void) {}
00149 
00150     protected:
00151         typedef std::vector<KeyFrame*> KeyFrameList;
00152         KeyFrameList mKeyFrames;
00153         Animation* mParent;
00154         unsigned short mHandle;
00155 
00157         virtual KeyFrame* createKeyFrameImpl(Real time) = 0;
00158 
00159 
00160     };
00161 
00164     class _OgreExport NumericAnimationTrack : public AnimationTrack
00165     {
00166     public:
00168         NumericAnimationTrack(Animation* parent, unsigned short handle);
00170         NumericAnimationTrack(Animation* parent, unsigned short handle, 
00171             AnimableValuePtr& target);
00172 
00180         virtual NumericKeyFrame* createNumericKeyFrame(Real timePos);
00181 
00183         void getInterpolatedKeyFrame(Real timeIndex, KeyFrame* kf) const;
00184 
00186         void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00187             Real scale = 1.0f);
00188 
00197         void applyToAnimable(const AnimableValuePtr& anim, Real timePos, 
00198             Real weight = 1.0, Real scale = 1.0f);
00199 
00201         virtual const AnimableValuePtr& getAssociatedAnimable(void) const;
00202 
00205         virtual void setAssociatedAnimable(const AnimableValuePtr& val);
00206 
00208         NumericKeyFrame* getNumericKeyFrame(unsigned short index) const;
00209 
00210 
00211     protected:
00213         AnimableValuePtr mTargetAnim;
00214 
00216         KeyFrame* createKeyFrameImpl(Real time);
00217 
00218 
00219     };
00220 
00223     class _OgreExport NodeAnimationTrack : public AnimationTrack
00224     {
00225     public:
00227         NodeAnimationTrack(Animation* parent, unsigned short handle);
00229         NodeAnimationTrack(Animation* parent, unsigned short handle, 
00230             Node* targetNode);
00238         virtual TransformKeyFrame* createNodeKeyFrame(Real timePos);
00240         virtual Node* getAssociatedNode(void) const;
00241 
00243         virtual void setAssociatedNode(Node* node);
00244 
00246         virtual void applyToNode(Node* node, Real timePos, Real weight = 1.0, 
00247             bool accumulate = false, Real scale = 1.0f);
00248 
00250         virtual void setUseShortestRotationPath(bool useShortestPath);
00251 
00253         virtual bool getUseShortestRotationPath() const;
00254 
00256         void getInterpolatedKeyFrame(Real timeIndex, KeyFrame* kf) const;
00257 
00259         void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00260             Real scale = 1.0f);
00261 
00263         void _keyFrameDataChanged(void) const;
00264 
00266         virtual TransformKeyFrame* getNodeKeyFrame(unsigned short index) const;
00267 
00268 
00273         virtual bool hasNonZeroKeyFrames(void) const;
00274 
00276         virtual void optimise(void);
00277 
00278     protected:
00280         KeyFrame* createKeyFrameImpl(Real time);
00281         // Flag indicating we need to rebuild the splines next time
00282         virtual void buildInterpolationSplines(void) const;
00283 
00284         Node* mTargetNode;
00285         // Prebuilt splines, must be mutable since lazy-update in const method
00286         mutable bool mSplineBuildNeeded;
00287         mutable SimpleSpline mPositionSpline;
00288         mutable SimpleSpline mScaleSpline;
00289         mutable RotationalSpline mRotationSpline;
00291         mutable bool mUseShortestRotationPath ;
00292 
00293 
00294     };
00295 
00354     enum VertexAnimationType
00355     {
00357         VAT_NONE = 0,
00359         VAT_MORPH = 1,
00361         VAT_POSE = 2
00362     };
00363 
00367     class _OgreExport VertexAnimationTrack : public AnimationTrack
00368     {
00369     public:
00371         enum TargetMode
00372         {
00374             TM_SOFTWARE, 
00377             TM_HARDWARE
00378         };
00380         VertexAnimationTrack(Animation* parent, unsigned short handle, VertexAnimationType animType);
00382         VertexAnimationTrack(Animation* parent, unsigned short handle, VertexAnimationType animType, 
00383             VertexData* targetData, TargetMode target = TM_SOFTWARE);
00384 
00386         VertexAnimationType getAnimationType(void) const { return mAnimationType; }
00387 
00395         virtual VertexMorphKeyFrame* createVertexMorphKeyFrame(Real timePos);
00396 
00399         virtual VertexPoseKeyFrame* createVertexPoseKeyFrame(Real timePos);
00400 
00404         void getInterpolatedKeyFrame(Real timeIndex, KeyFrame* kf) const {}
00405 
00407         void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00408             Real scale = 1.0f);
00409 
00412         virtual void applyToVertexData(VertexData* data, 
00413             Real timePos, Real weight = 1.0, 
00414             const PoseList* poseList = 0);
00415 
00416 
00418         VertexMorphKeyFrame* getVertexMorphKeyFrame(unsigned short index) const;
00419 
00421         VertexPoseKeyFrame* getVertexPoseKeyFrame(unsigned short index) const;
00422 
00424         void setAssociatedVertexData(VertexData* data) { mTargetVertexData = data; }
00426         VertexData* getAssociatedVertexData(void) const { return mTargetVertexData; }
00427 
00429         void setTargetMode(TargetMode m) { mTargetMode = m; }
00431         TargetMode getTargetMode(void) const { return mTargetMode; }
00432 
00437         virtual bool hasNonZeroKeyFrames(void) const;
00438 
00440         virtual void optimise(void);
00441 
00442 
00443     protected:
00445         VertexAnimationType mAnimationType;
00447         VertexData* mTargetVertexData;
00449         TargetMode mTargetMode;
00450 
00452         KeyFrame* createKeyFrameImpl(Real time);
00453 
00455         void applyPoseToVertexData(const Pose* pose, VertexData* data, Real influence);
00456 
00457 
00458     };
00459 
00460 
00461 }
00462 
00463 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 23 10:05:36 2006