source: OGRE/trunk/ogrenew/OgreMain/include/OgreKeyFrame.h @ 692

Revision 692, 7.6 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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