Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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         Real mMaxKeyFrameTime;
00154         Animation* mParent;
00155         unsigned short mHandle;
00156 
00158         virtual KeyFrame* createKeyFrameImpl(Real time) = 0;
00159 
00160 
00161     };
00162 
00165     class _OgreExport NumericAnimationTrack : public AnimationTrack
00166     {
00167     public:
00169         NumericAnimationTrack(Animation* parent, unsigned short handle);
00171         NumericAnimationTrack(Animation* parent, unsigned short handle, 
00172             AnimableValuePtr& target);
00173 
00181         virtual NumericKeyFrame* createNumericKeyFrame(Real timePos);
00182 
00184         void getInterpolatedKeyFrame(Real timeIndex, KeyFrame* kf) const;
00185 
00187         void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00188             Real scale = 1.0f);
00189 
00198         void applyToAnimable(const AnimableValuePtr& anim, Real timePos, 
00199             Real weight = 1.0, Real scale = 1.0f);
00200 
00202         virtual const AnimableValuePtr& getAssociatedAnimable(void) const;
00203 
00206         virtual void setAssociatedAnimable(const AnimableValuePtr& val);
00207 
00209         NumericKeyFrame* getNumericKeyFrame(unsigned short index) const;
00210 
00211 
00212     protected:
00214         AnimableValuePtr mTargetAnim;
00215 
00217         KeyFrame* createKeyFrameImpl(Real time);
00218 
00219 
00220     };
00221 
00224     class _OgreExport NodeAnimationTrack : public AnimationTrack
00225     {
00226     public:
00228         NodeAnimationTrack(Animation* parent, unsigned short handle);
00230         NodeAnimationTrack(Animation* parent, unsigned short handle, 
00231             Node* targetNode);
00239         virtual TransformKeyFrame* createNodeKeyFrame(Real timePos);
00241         virtual Node* getAssociatedNode(void) const;
00242 
00244         virtual void setAssociatedNode(Node* node);
00245 
00247         virtual void applyToNode(Node* node, Real timePos, Real weight = 1.0, 
00248             bool accumulate = false, Real scale = 1.0f);
00249 
00251         virtual void setUseShortestRotationPath(bool useShortestPath);
00252 
00254         virtual bool getUseShortestRotationPath() const;
00255 
00257         void getInterpolatedKeyFrame(Real timeIndex, KeyFrame* kf) const;
00258 
00260         void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00261             Real scale = 1.0f);
00262 
00264         void _keyFrameDataChanged(void) const;
00265 
00267         virtual TransformKeyFrame* getNodeKeyFrame(unsigned short index) const;
00268 
00269 
00274         virtual bool hasNonZeroKeyFrames(void) const;
00275 
00277         virtual void optimise(void);
00278 
00279     protected:
00281         KeyFrame* createKeyFrameImpl(Real time);
00282         // Flag indicating we need to rebuild the splines next time
00283         virtual void buildInterpolationSplines(void) const;
00284 
00285         Node* mTargetNode;
00286         // Prebuilt splines, must be mutable since lazy-update in const method
00287         mutable bool mSplineBuildNeeded;
00288         mutable SimpleSpline mPositionSpline;
00289         mutable SimpleSpline mScaleSpline;
00290         mutable RotationalSpline mRotationSpline;
00292         mutable bool mUseShortestRotationPath ;
00293 
00294 
00295     };
00296 
00355     enum VertexAnimationType
00356     {
00358         VAT_NONE = 0,
00360         VAT_MORPH = 1,
00362         VAT_POSE = 2
00363     };
00364 
00368     class _OgreExport VertexAnimationTrack : public AnimationTrack
00369     {
00370     public:
00372         enum TargetMode
00373         {
00375             TM_SOFTWARE, 
00378             TM_HARDWARE
00379         };
00381         VertexAnimationTrack(Animation* parent, unsigned short handle, VertexAnimationType animType);
00383         VertexAnimationTrack(Animation* parent, unsigned short handle, VertexAnimationType animType, 
00384             VertexData* targetData, TargetMode target = TM_SOFTWARE);
00385 
00387         VertexAnimationType getAnimationType(void) const { return mAnimationType; }
00388 
00396         virtual VertexMorphKeyFrame* createVertexMorphKeyFrame(Real timePos);
00397 
00400         virtual VertexPoseKeyFrame* createVertexPoseKeyFrame(Real timePos);
00401 
00405         void getInterpolatedKeyFrame(Real timeIndex, KeyFrame* kf) const {}
00406 
00408         void apply(Real timePos, Real weight = 1.0, bool accumulate = false, 
00409             Real scale = 1.0f);
00410 
00413         virtual void applyToVertexData(VertexData* data, 
00414             Real timePos, Real weight = 1.0, 
00415             const PoseList* poseList = 0);
00416 
00417 
00419         VertexMorphKeyFrame* getVertexMorphKeyFrame(unsigned short index) const;
00420 
00422         VertexPoseKeyFrame* getVertexPoseKeyFrame(unsigned short index) const;
00423 
00425         void setAssociatedVertexData(VertexData* data) { mTargetVertexData = data; }
00427         VertexData* getAssociatedVertexData(void) const { return mTargetVertexData; }
00428 
00430         void setTargetMode(TargetMode m) { mTargetMode = m; }
00432         TargetMode getTargetMode(void) const { return mTargetMode; }
00433 
00438         virtual bool hasNonZeroKeyFrames(void) const;
00439 
00441         virtual void optimise(void);
00442 
00443 
00444     protected:
00446         VertexAnimationType mAnimationType;
00448         VertexData* mTargetVertexData;
00450         TargetMode mTargetMode;
00451 
00453         KeyFrame* createKeyFrameImpl(Real time);
00454 
00456         void applyPoseToVertexData(const Pose* pose, VertexData* data, Real influence);
00457 
00458 
00459     };
00460 
00461 
00462 }
00463 
00464 #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 Mar 12 14:37:36 2006