Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreKeyFrame.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 8.3 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29
30#ifndef __KeyFrame_H__
31#define __KeyFrame_H__
32
33#include "OgrePrerequisites.h"
34#include "OgreVector3.h"
35#include "OgreQuaternion.h"
36#include "OgreAny.h"
37#include "OgreHardwareVertexBuffer.h"
38#include "OgreIteratorWrappers.h"
39
40namespace Ogre
41{
42
43    /** A key frame in an animation sequence defined by an AnimationTrack.
44    @remarks
45        This class can be used as a basis for all kinds of key frames.
46        The unifying principle is that multiple KeyFrames define an
47        animation sequence, with the exact state of the animation being an
48        interpolation between these key frames.
49    */
50    class _OgreExport KeyFrame
51    {
52    public:
53
54        /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */
55        KeyFrame(const AnimationTrack* parent, Real time);
56
57                virtual ~KeyFrame() {}
58
59        /** Gets the time of this keyframe in the animation sequence. */
60        Real getTime(void) const { return mTime; }
61
62                /** Clone a keyframe (internal use only) */
63                virtual KeyFrame* _clone(AnimationTrack* newParent) const;
64
65
66    protected:
67        Real mTime;
68        const AnimationTrack* mParentTrack;
69    };
70
71
72        /** Specialised KeyFrame which stores any numeric value.
73        */
74        class _OgreExport NumericKeyFrame : public KeyFrame
75        {
76        public:
77                /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */
78                NumericKeyFrame(const AnimationTrack* parent, Real time);
79                ~NumericKeyFrame() {}
80
81                /** Get the value at this keyframe. */
82                virtual const AnyNumeric& getValue(void) const;
83                /** Set the value at this keyframe.
84                @remarks
85                        All keyframe values must have a consistent type.
86                */
87                virtual void setValue(const AnyNumeric& val);
88
89                /** Clone a keyframe (internal use only) */
90                KeyFrame* _clone(AnimationTrack* newParent) const;
91        protected:
92                AnyNumeric mValue;
93        };
94
95
96        /** Specialised KeyFrame which stores a full transform. */
97        class _OgreExport TransformKeyFrame : public KeyFrame
98        {
99        public:
100                /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */
101                TransformKeyFrame(const AnimationTrack* parent, Real time);
102                ~TransformKeyFrame() {}
103                /** Sets the translation associated with this keyframe.
104                @remarks   
105                The translation factor affects how much the keyframe translates (moves) it's animable
106                object at it's time index.
107                @param trans The vector to translate by
108                */
109                virtual void setTranslate(const Vector3& trans);
110
111                /** Gets the translation applied by this keyframe. */
112                const Vector3& getTranslate(void) const;
113
114                /** Sets the scaling factor applied by this keyframe to the animable
115                object at it's time index.
116                @param scale The vector to scale by (beware of supplying zero values for any component of this
117                vector, it will scale the object to zero dimensions)
118                */
119                virtual void setScale(const Vector3& scale);
120
121                /** Gets the scaling factor applied by this keyframe. */
122                virtual const Vector3& getScale(void) const;
123
124                /** Sets the rotation applied by this keyframe.
125                @param rot The rotation applied; use Quaternion methods to convert from angle/axis or Matrix3 if
126                you don't like using Quaternions directly.
127                */
128                virtual void setRotation(const Quaternion& rot);
129
130                /** Gets the rotation applied by this keyframe. */
131                virtual const Quaternion& getRotation(void) const;
132
133                /** Clone a keyframe (internal use only) */
134                KeyFrame* _clone(AnimationTrack* newParent) const;
135        protected:
136                Vector3 mTranslate;
137                Vector3 mScale;
138                Quaternion mRotate;
139
140
141        };
142
143
144
145        /** Specialised KeyFrame which stores absolute vertex positions for a complete
146                buffer, designed to be interpolated with other keys in the same track.
147        */
148        class _OgreExport VertexMorphKeyFrame : public KeyFrame
149        {
150        public:
151                /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */
152                VertexMorphKeyFrame(const AnimationTrack* parent, Real time);
153                ~VertexMorphKeyFrame() {}
154                /** Sets the vertex buffer containing the source positions for this keyframe.
155                @remarks   
156                        We assume that positions are the first 3 float elements in this buffer,
157                        although we don't necessarily assume they're the only ones in there.
158                @param buf Vertex buffer link; will not be modified so can be shared
159                        read-only data
160                */
161                void setVertexBuffer(const HardwareVertexBufferSharedPtr& buf);
162
163                /** Gets the vertex buffer containing positions for this keyframe. */
164                const HardwareVertexBufferSharedPtr& getVertexBuffer(void) const;
165
166                /** Clone a keyframe (internal use only) */
167                KeyFrame* _clone(AnimationTrack* newParent) const;             
168
169        protected:
170                HardwareVertexBufferSharedPtr mBuffer;
171
172        };
173
174        /** Specialised KeyFrame which references a Mesh::Pose at a certain influence
175                level, which stores offsets for a subset of the vertices
176                in a buffer to provide a blendable pose.
177        */
178        class _OgreExport VertexPoseKeyFrame : public KeyFrame
179        {
180        public:
181                /** Default constructor, you should not call this but use AnimationTrack::createKeyFrame instead. */
182                VertexPoseKeyFrame(const AnimationTrack* parent, Real time);
183                ~VertexPoseKeyFrame() {}
184
185                /** Reference to a pose at a given influence level
186                @remarks
187                        Each keyframe can refer to many poses each at a given influence level.
188                **/
189                struct PoseRef
190                {
191                        /** The linked pose index.
192                        @remarks
193                                The Mesh contains all poses for all vertex data in one list, both
194                                for the shared vertex data and the dedicated vertex data on submeshes.
195                                The 'target' on the parent track must match the 'target' on the
196                                linked pose.
197                        */
198                        ushort poseIndex;
199                        /** Influence level of the linked pose.
200                                1.0 for full influence (full offset), 0.0 for no influence.
201                        */
202                        Real influence;
203
204                        PoseRef(ushort p, Real i) : poseIndex(p), influence(i) {}
205                };
206                typedef std::vector<PoseRef> PoseRefList;
207
208                /** Add a new pose reference.
209                @see PoseRef
210                */
211                void addPoseReference(ushort poseIndex, Real influence);
212                /** Update the influence of a pose reference.
213                @see PoseRef
214                */
215                void updatePoseReference(ushort poseIndex, Real influence);
216                /** Remove reference to a given pose.
217                @param poseIndex The pose index (not the index of the reference)
218                */
219                void removePoseReference(ushort poseIndex);
220                /** Remove all pose references. */
221                void removeAllPoseReferences(void);
222
223
224                /** Get a const reference to the list of pose references. */
225                const PoseRefList& getPoseReferences(void) const;
226
227                typedef VectorIterator<PoseRefList> PoseRefIterator;
228                typedef ConstVectorIterator<PoseRefList> ConstPoseRefIterator;
229
230                /** Get an iterator over the pose references. */
231                PoseRefIterator getPoseReferenceIterator(void);
232
233                /** Get a const iterator over the pose references. */
234                ConstPoseRefIterator getPoseReferenceIterator(void) const;
235
236                /** Clone a keyframe (internal use only) */
237                KeyFrame* _clone(AnimationTrack* newParent) const;
238               
239        protected:
240                PoseRefList mPoseRefs;
241
242        };
243
244}
245
246
247#endif
248
Note: See TracBrowser for help on using the repository browser.