OGRE  1.9.0
OgreAnimable.h
Go to the documentation of this file.
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-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __ANIMABLE_H__
29#define __ANIMABLE_H__
30
31#include "OgrePrerequisites.h"
32#include "OgreVector2.h"
33#include "OgreVector3.h"
34#include "OgreVector4.h"
35#include "OgreQuaternion.h"
36#include "OgreColourValue.h"
37#include "OgreSharedPtr.h"
38#include "OgreStringVector.h"
39#include "OgreException.h"
40#include "OgreAny.h"
41#include "OgreHeaderPrefix.h"
42
43namespace Ogre {
47
51
73 {
74 public:
88 protected:
91
93 union
94 {
97 };
98
100 virtual void setAsBaseValue(int val) { mBaseValueInt = val; }
102 virtual void setAsBaseValue(Real val) { mBaseValueReal[0] = val; }
104 virtual void setAsBaseValue(const Vector2& val)
105 { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*2); }
106
107 virtual void setAsBaseValue(const Vector3& val)
108 { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*3); }
109
110 virtual void setAsBaseValue(const Vector4& val)
111 { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
112
113 virtual void setAsBaseValue(const Quaternion& val)
114 { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
115
116 virtual void setAsBaseValue(const Any& val);
118 virtual void setAsBaseValue(const ColourValue& val)
119 {
120 mBaseValueReal[0] = val.r;
121 mBaseValueReal[1] = val.g;
122 mBaseValueReal[2] = val.b;
123 mBaseValueReal[3] = val.a;
124 }
125
126 virtual void setAsBaseValue(const Radian& val)
127 {
128 mBaseValueReal[0] = val.valueRadians();
129 }
130
131 virtual void setAsBaseValue(const Degree& val)
132 {
133 mBaseValueReal[0] = val.valueRadians();
134 }
135
136
137 public:
139 virtual ~AnimableValue() {}
140
142 ValueType getType(void) const { return mType; }
143
145 virtual void setCurrentStateAsBaseValue(void) = 0;
146
148 virtual void setValue(int) {
150 }
151
152 virtual void setValue(Real) {
154 }
155
156 virtual void setValue(const Vector2&) {
158 }
159
160 virtual void setValue(const Vector3&) {
162 }
163
164 virtual void setValue(const Vector4&) {
166 }
167
168 virtual void setValue(const Quaternion&) {
170 }
171
172 virtual void setValue(const ColourValue&) {
174 }
175
176 virtual void setValue(const Radian&) {
178 }
179
180 virtual void setValue(const Degree&) {
182 }
183
184 virtual void setValue(const Any& val);
185
186 // reset to base value
187 virtual void resetToBaseValue(void);
188
190 virtual void applyDeltaValue(int) {
192 }
193
197
198 virtual void applyDeltaValue(const Vector2&) {
200 }
201
202 virtual void applyDeltaValue(const Vector3&) {
204 }
205
206 virtual void applyDeltaValue(const Vector4&) {
208 }
209
210 virtual void applyDeltaValue(const Quaternion&) {
212 }
213
214 virtual void applyDeltaValue(const ColourValue&) {
216 }
217
218 virtual void applyDeltaValue(const Degree&) {
220 }
221
222 virtual void applyDeltaValue(const Radian&) {
224 }
225
226 virtual void applyDeltaValue(const Any& val);
227
228
229 };
230
232
233
234
239 {
240 protected:
249 virtual const String& getAnimableDictionaryName(void) const
250 { return StringUtil::BLANK; }
251
265
268 {
269 AnimableDictionaryMap::iterator i =
271 if (i != msAnimableDictionary.end())
272 {
273 return i->second;
274 }
275 else
276 {
278 "Animable value list not found for " + getAnimableDictionaryName(),
279 "AnimableObject::getAnimableValueNames");
280 }
281
282 }
283
288
289
290 public:
292 virtual ~AnimableObject() {}
293
296 {
298
299 AnimableDictionaryMap::iterator i =
301 if (i != msAnimableDictionary.end())
302 {
303 return i->second;
304 }
305 else
306 {
308 "Animable value list not found for " + getAnimableDictionaryName(),
309 "AnimableObject::getAnimableValueNames");
310 }
311
312 }
313
321 {
323 "No animable value named '" + valueName + "' present.",
324 "AnimableObject::createAnimableValue");
325 }
326
327
328
329 };
330
333
334}
335
336#include "OgreHeaderSuffix.h"
337
338#endif
339
#define _OgreExport
static AnimableDictionaryMap msAnimableDictionary
Static map of class name to list of animable value names.
map< String, StringVector >::type AnimableDictionaryMap
virtual void initialiseAnimableDictionary(StringVector &) const
Internal method for initialising dictionary; should be implemented by subclasses wanting to expose an...
virtual const String & getAnimableDictionaryName(void) const
Get the name of the animable dictionary for this class.
void createAnimableDictionary(void) const
Internal method for creating a dictionary of animable value names for the class, if it does not alrea...
const StringVector & getAnimableValueNames(void) const
Gets a list of animable value names for this object.
virtual AnimableValuePtr createAnimableValue(const String &valueName)
Create a reference-counted AnimableValuePtr for the named value.
StringVector & _getAnimableValueNames(void)
Get an updateable reference to animable value list.
virtual void applyDeltaValue(int)
Apply delta value.
virtual void setValue(const Radian &)
Set value.
virtual void setAsBaseValue(const ColourValue &val)
Internal method to set a value as base.
AnimableValue(ValueType t)
virtual void setAsBaseValue(const Degree &val)
Internal method to set a value as base.
virtual void setValue(const ColourValue &)
Set value.
virtual void setValue(const Vector2 &)
Set value.
virtual void setAsBaseValue(const Vector2 &val)
Internal method to set a value as base.
virtual void applyDeltaValue(const Vector4 &)
Apply delta value.
virtual void setAsBaseValue(Real val)
Internal method to set a value as base.
virtual void applyDeltaValue(const Vector2 &)
Apply delta value.
virtual void setValue(const Quaternion &)
Set value.
virtual void applyDeltaValue(const Any &val)
Apply delta value.
virtual void setAsBaseValue(const Vector3 &val)
Internal method to set a value as base.
virtual void setValue(int)
Set value.
virtual void applyDeltaValue(const Quaternion &)
Apply delta value.
virtual void setAsBaseValue(const Any &val)
Internal method to set a value as base.
virtual void applyDeltaValue(const Radian &)
Apply delta value.
virtual void applyDeltaValue(Real)
Set value.
virtual void applyDeltaValue(const Degree &)
Apply delta value.
virtual void setValue(const Vector3 &)
Set value.
virtual void setValue(const Vector4 &)
Set value.
virtual void setValue(Real)
Set value.
ValueType mType
Value type.
virtual void setAsBaseValue(int val)
Internal method to set a value as base.
virtual void setCurrentStateAsBaseValue(void)=0
Sets the current state as the 'base' value; used for delta animation.
virtual void applyDeltaValue(const Vector3 &)
Apply delta value.
virtual void setValue(const Any &val)
Set value.
ValueType getType(void) const
Gets the value type of this animable value.
virtual void applyDeltaValue(const ColourValue &)
Apply delta value.
virtual void setAsBaseValue(const Vector4 &val)
Internal method to set a value as base.
virtual void setAsBaseValue(const Quaternion &val)
Internal method to set a value as base.
ValueType
The type of the value being animated.
virtual void setValue(const Degree &)
Set value.
virtual void resetToBaseValue(void)
virtual void setAsBaseValue(const Radian &val)
Internal method to set a value as base.
Variant type that can hold Any other type.
Definition OgreAny.h:57
Class representing colour.
Wrapper class which indicates a given angle value is in Degrees.
Definition OgreMath.h:99
Implementation of a Quaternion, i.e.
Real * ptr()
Pointer accessor for direct copying.
Wrapper class which indicates a given angle value is in Radians.
Definition OgreMath.h:48
Real valueRadians() const
Definition OgreMath.h:59
Reference-counted shared pointer, used for objects where implicit destruction is required.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition OgreString.h:196
Standard 2-dimensional vector.
Definition OgreVector2.h:52
Real * ptr()
Pointer accessor for direct copying.
Standard 3-dimensional vector.
Definition OgreVector3.h:52
Real * ptr()
Pointer accessor for direct copying.
4-dimensional homogeneous vector.
Definition OgreVector4.h:46
Real * ptr()
Pointer accessor for direct copying.
SharedPtr< AnimableValue > AnimableValuePtr
vector< String >::type StringVector
#define OGRE_EXCEPT(code, desc, src)
Real valueRadians() const
Definition OgreMath.h:727
float Real
Software floating point type.
AnimationAllocatedObject AnimableAlloc
_StringBase String
std::map< K, V, P, A > type