source: OGRE/trunk/ogrenew/OgreMain/src/OgreKeyFrame.cpp @ 692

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

adding ogre 1.2 and dependencies

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-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#include "OgreStableHeaders.h"
26
27#include "OgreKeyFrame.h"
28#include "OgreAnimationTrack.h"
29#include "OgreHardwareBufferManager.h"
30
31namespace Ogre
32{
33    //---------------------------------------------------------------------
34    KeyFrame::KeyFrame(const AnimationTrack* parent, Real time)
35        : mTime(time), mParentTrack(parent)
36    {
37    }
38    //---------------------------------------------------------------------
39    Real KeyFrame::getTime(void) const
40    {
41        return mTime;
42    }
43        //---------------------------------------------------------------------
44        NumericKeyFrame::NumericKeyFrame(const AnimationTrack* parent, Real time)
45                :KeyFrame(parent, time)
46        {
47        }
48        //---------------------------------------------------------------------
49        const AnyNumeric& NumericKeyFrame::getValue(void) const
50        {
51                return mValue;
52        }
53        //---------------------------------------------------------------------
54        void NumericKeyFrame::setValue(const AnyNumeric& val)
55        {
56                mValue = val;
57        }
58    //---------------------------------------------------------------------
59        TransformKeyFrame::TransformKeyFrame(const AnimationTrack* parent, Real time)
60                :KeyFrame(parent, time), mTranslate(Vector3::ZERO),
61                mScale(Vector3::UNIT_SCALE), mRotate(Quaternion::IDENTITY)
62        {
63        }
64        //---------------------------------------------------------------------
65    void TransformKeyFrame::setTranslate(const Vector3& trans)
66    {
67        mTranslate = trans;
68        if (mParentTrack)
69            mParentTrack->_keyFrameDataChanged();
70    }
71    //---------------------------------------------------------------------
72    const Vector3& TransformKeyFrame::getTranslate(void) const
73    {
74        return mTranslate;
75    }
76    //---------------------------------------------------------------------
77    void TransformKeyFrame::setScale(const Vector3& scale)
78    {
79        mScale = scale;
80        if (mParentTrack)
81            mParentTrack->_keyFrameDataChanged();
82    }
83    //---------------------------------------------------------------------
84    const Vector3& TransformKeyFrame::getScale(void) const
85    {
86        return mScale;
87    }
88    //---------------------------------------------------------------------
89    void TransformKeyFrame::setRotation(const Quaternion& rot)
90    {
91        mRotate = rot;
92        if (mParentTrack)
93            mParentTrack->_keyFrameDataChanged();
94    }
95    //---------------------------------------------------------------------
96    const Quaternion& TransformKeyFrame::getRotation(void) const
97    {
98        return mRotate;
99    }
100        //---------------------------------------------------------------------
101        VertexMorphKeyFrame::VertexMorphKeyFrame(const AnimationTrack* parent, Real time)
102                : KeyFrame(parent, time)
103        {
104        }
105        //---------------------------------------------------------------------
106        void VertexMorphKeyFrame::setVertexBuffer(const HardwareVertexBufferSharedPtr& buf)
107        {
108                mBuffer = buf;
109        }
110        //---------------------------------------------------------------------
111        const HardwareVertexBufferSharedPtr&
112        VertexMorphKeyFrame::getVertexBuffer(void) const
113        {
114                return mBuffer;
115        }
116        //---------------------------------------------------------------------
117        VertexPoseKeyFrame::VertexPoseKeyFrame(const AnimationTrack* parent, Real time)
118                :KeyFrame(parent, time)
119        {
120        }
121        //---------------------------------------------------------------------
122        void VertexPoseKeyFrame::addPoseReference(ushort poseIndex, Real influence)
123        {
124                mPoseRefs.push_back(PoseRef(poseIndex, influence));
125        }
126        //---------------------------------------------------------------------
127        void VertexPoseKeyFrame::updatePoseReference(ushort poseIndex, Real influence)
128        {
129                for (PoseRefList::iterator i = mPoseRefs.begin(); i != mPoseRefs.end(); ++i)
130                {
131                        if (i->poseIndex == poseIndex)
132                        {
133                                i->influence = influence;
134                                return;
135                        }
136                }
137                // if we got here, we didn't find it
138                addPoseReference(poseIndex, influence);
139
140        }
141        //---------------------------------------------------------------------
142        void VertexPoseKeyFrame::removePoseReference(ushort poseIndex)
143        {
144                for (PoseRefList::iterator i = mPoseRefs.begin(); i != mPoseRefs.end(); ++i)
145                {
146                        if (i->poseIndex == poseIndex)
147                        {
148                                mPoseRefs.erase(i);
149                                return;
150                        }
151                }
152        }
153        //---------------------------------------------------------------------
154        void VertexPoseKeyFrame::removeAllPoseReferences(void)
155        {
156                mPoseRefs.clear();
157        }
158        //---------------------------------------------------------------------
159        const VertexPoseKeyFrame::PoseRefList&
160        VertexPoseKeyFrame::getPoseReferences(void) const
161        {
162                return mPoseRefs;
163        }
164        //---------------------------------------------------------------------
165        VertexPoseKeyFrame::PoseRefIterator
166        VertexPoseKeyFrame::getPoseReferenceIterator(void)
167        {
168                return PoseRefIterator(mPoseRefs.begin(), mPoseRefs.end());
169        }
170        //---------------------------------------------------------------------
171        VertexPoseKeyFrame::ConstPoseRefIterator
172        VertexPoseKeyFrame::getPoseReferenceIterator(void) const
173        {
174                return ConstPoseRefIterator(mPoseRefs.begin(), mPoseRefs.end());
175        }
176        //---------------------------------------------------------------------
177
178
179}
180
Note: See TracBrowser for help on using the repository browser.