OgreAnimable.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __ANIMABLE_H__
#define __ANIMABLE_H__
#include "OgrePrerequisites.h"
#include "OgreVector2.h"
#include "OgreVector3.h"
#include "OgreVector4.h"
#include "OgreQuaternion.h"
#include "OgreColourValue.h"
#include "OgreSharedPtr.h"
#include "OgreStringVector.h"
#include "OgreException.h"
#include "OgreAny.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport AnimableValue : public AnimableAlloc
{
public:
enum ValueType
{
INT,
REAL,
VECTOR2,
VECTOR3,
VECTOR4,
QUATERNION,
COLOUR,
RADIAN,
DEGREE
};
protected:
ValueType mType;
union
{
int mBaseValueInt;
Real mBaseValueReal[4];
};
virtual void setAsBaseValue(int val) { mBaseValueInt = val; }
virtual void setAsBaseValue(Real val) { mBaseValueReal[0] = val; }
virtual void setAsBaseValue(const Vector2& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*2); }
virtual void setAsBaseValue(const Vector3& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*3); }
virtual void setAsBaseValue(const Vector4& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
virtual void setAsBaseValue(const Quaternion& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
virtual void setAsBaseValue(const Any& val);
virtual void setAsBaseValue(const ColourValue& val)
{
mBaseValueReal[0] = val.r;
mBaseValueReal[1] = val.g;
mBaseValueReal[2] = val.b;
mBaseValueReal[3] = val.a;
}
virtual void setAsBaseValue(const Radian& val)
{
mBaseValueReal[0] = val.valueRadians();
}
virtual void setAsBaseValue(const Degree& val)
{
mBaseValueReal[0] = val.valueRadians();
}
public:
AnimableValue(ValueType t) : mType(t) {}
virtual ~AnimableValue() {}
ValueType getType(void) const { return mType; }
virtual void setCurrentStateAsBaseValue(void) = 0;
virtual void setValue(int) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(Real) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const Vector2&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const Vector3&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const Vector4&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const Quaternion&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const ColourValue&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const Radian&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const Degree&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void setValue(const Any& val);
// reset to base value
virtual void resetToBaseValue(void);
virtual void applyDeltaValue(int) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(Real) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const Vector2&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const Vector3&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const Vector4&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const Quaternion&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const ColourValue&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const Degree&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const Radian&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
virtual void applyDeltaValue(const Any& val);
};
typedef SharedPtr<AnimableValue> AnimableValuePtr;
class _OgreExport AnimableObject
{
protected:
typedef map<String, StringVector>::type AnimableDictionaryMap;
static AnimableDictionaryMap msAnimableDictionary;
virtual const String& getAnimableDictionaryName(void) const
{ return StringUtil::BLANK; }
void createAnimableDictionary(void) const
{
if (msAnimableDictionary.find(getAnimableDictionaryName())
== msAnimableDictionary.end())
{
StringVector vec;
initialiseAnimableDictionary(vec);
msAnimableDictionary[getAnimableDictionaryName()] = vec;
}
}
StringVector& _getAnimableValueNames(void)
{
AnimableDictionaryMap::iterator i =
msAnimableDictionary.find(getAnimableDictionaryName());
if (i != msAnimableDictionary.end())
{
return i->second;
}
else
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Animable value list not found for " + getAnimableDictionaryName(),
"AnimableObject::getAnimableValueNames");
}
}
virtual void initialiseAnimableDictionary(StringVector&) const {}
public:
AnimableObject() {}
virtual ~AnimableObject() {}
const StringVector& getAnimableValueNames(void) const
{
createAnimableDictionary();
AnimableDictionaryMap::iterator i =
msAnimableDictionary.find(getAnimableDictionaryName());
if (i != msAnimableDictionary.end())
{
return i->second;
}
else
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Animable value list not found for " + getAnimableDictionaryName(),
"AnimableObject::getAnimableValueNames");
}
}
virtual AnimableValuePtr createAnimableValue(const String& valueName)
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"No animable value named '" + valueName + "' present.",
"AnimableObject::createAnimableValue");
}
};
}
#include "OgreHeaderSuffix.h"
#endif
OgreVector4.h
Ogre::AnimableValue::VECTOR2
Definition: OgreAnimable.h:80
Ogre::Vector3::ptr
Real * ptr()
Pointer accessor for direct copying.
Definition: OgreVector3.h:120
Ogre::AnimableValue::setValue
virtual void setValue(const Vector2 &)
Set value.
Definition: OgreAnimable.h:156
OgreQuaternion.h
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(const Vector3 &val)
Internal method to set a value as base.
Definition: OgreAnimable.h:107
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(const Quaternion &val)
Internal method to set a value as base.
Definition: OgreAnimable.h:113
Ogre::AnimableObject::initialiseAnimableDictionary
virtual void initialiseAnimableDictionary(StringVector &) const
Internal method for initialising dictionary; should be implemented by subclasses wanting to expose an...
Definition: OgreAnimable.h:287
Ogre::ColourValue::r
float r
Definition: OgreColourValue.h:76
Ogre::AnimableObject::createAnimableValue
virtual AnimableValuePtr createAnimableValue(const String &valueName)
Create a reference-counted AnimableValuePtr for the named value.
Definition: OgreAnimable.h:320
Ogre::AnimableValue
Defines an object property which is animable, i.e.
Definition: OgreAnimable.h:72
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(const Vector2 &val)
Internal method to set a value as base.
Definition: OgreAnimable.h:104
OgreSharedPtr.h
Ogre::Quaternion::ptr
Real * ptr()
Pointer accessor for direct copying.
Definition: OgreQuaternion.h:125
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(int val)
Internal method to set a value as base.
Definition: OgreAnimable.h:100
Ogre::AnimableValue::setValue
virtual void setValue(const Vector3 &)
Set value.
Definition: OgreAnimable.h:160
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
Ogre::AnimableObject::getAnimableValueNames
const StringVector & getAnimableValueNames(void) const
Gets a list of animable value names for this object.
Definition: OgreAnimable.h:295
Ogre::AnimableValue::VECTOR4
Definition: OgreAnimable.h:82
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(const Radian &)
Apply delta value.
Definition: OgreAnimable.h:222
Ogre::Vector2
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::AnimableValue::ValueType
ValueType
The type of the value being animated.
Definition: OgreAnimable.h:76
Ogre::ColourValue::a
float a
Definition: OgreColourValue.h:76
Ogre::ColourValue::g
float g
Definition: OgreColourValue.h:76
Ogre::AnimableValue::COLOUR
Definition: OgreAnimable.h:84
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
Ogre::AnimableValue::setValue
virtual void setValue(const Radian &)
Set value.
Definition: OgreAnimable.h:176
Ogre::AnimableValue::setValue
virtual void setValue(const ColourValue &)
Set value.
Definition: OgreAnimable.h:172
Ogre::AnimableValue::setValue
virtual void setValue(const Degree &)
Set value.
Definition: OgreAnimable.h:180
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(const Degree &)
Apply delta value.
Definition: OgreAnimable.h:218
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(const Vector2 &)
Apply delta value.
Definition: OgreAnimable.h:198
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(const Quaternion &)
Apply delta value.
Definition: OgreAnimable.h:210
Ogre::Any
Variant type that can hold Any other type.
Definition: OgreAny.h:56
Ogre::AnimableValue::setValue
virtual void setValue(const Vector4 &)
Set value.
Definition: OgreAnimable.h:164
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(const ColourValue &)
Apply delta value.
Definition: OgreAnimable.h:214
Ogre::ColourValue::b
float b
Definition: OgreColourValue.h:76
Ogre::AnimableValue::setValue
virtual void setValue(int)
Set value.
Definition: OgreAnimable.h:148
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(const Vector3 &)
Apply delta value.
Definition: OgreAnimable.h:202
Ogre::AnimableValue::RADIAN
Definition: OgreAnimable.h:85
OgrePrerequisites.h
Ogre::map::type
std::map< K, V, P, A > type
Definition: OgrePrerequisites.h:536
Ogre::AnimableValue::mType
ValueType mType
Value type.
Definition: OgreAnimable.h:90
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(const ColourValue &val)
Internal method to set a value as base.
Definition: OgreAnimable.h:118
Ogre::Radian::valueRadians
Real valueRadians() const
Definition: OgreMath.h:59
Ogre::AnimableObject::_getAnimableValueNames
StringVector & _getAnimableValueNames(void)
Get an updateable reference to animable value list.
Definition: OgreAnimable.h:267
Ogre::AnimableObject::getAnimableDictionaryName
virtual const String & getAnimableDictionaryName(void) const
Get the name of the animable dictionary for this class.
Definition: OgreAnimable.h:249
Ogre::AnimableValue::~AnimableValue
virtual ~AnimableValue()
Definition: OgreAnimable.h:139
Ogre::AnimableValue::setValue
virtual void setValue(const Quaternion &)
Set value.
Definition: OgreAnimable.h:168
OgreStringVector.h
Ogre::AnimableValue::setValue
virtual void setValue(Real)
Set value.
Definition: OgreAnimable.h:152
Ogre::Vector2::ptr
Real * ptr()
Pointer accessor for direct copying.
Definition: OgreVector2.h:115
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::AnimableObject
Defines an interface to classes which have one or more AnimableValue instances to expose...
Definition: OgreAnimable.h:238
Ogre::AnimableValue::AnimableValue
AnimableValue(ValueType t)
Definition: OgreAnimable.h:138
Ogre::AnimableValue::getType
ValueType getType(void) const
Gets the value type of this animable value.
Definition: OgreAnimable.h:142
OgreHeaderSuffix.h
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(Real)
Set value.
Definition: OgreAnimable.h:194
Ogre::AnimableObject::~AnimableObject
virtual ~AnimableObject()
Definition: OgreAnimable.h:292
OgreAny.h
Ogre::Vector4::ptr
Real * ptr()
Pointer accessor for direct copying.
Definition: OgreVector4.h:123
OGRE_EXCEPT
#define OGRE_EXCEPT(num, desc, src)
Definition: OgreException.h:334
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(Real val)
Internal method to set a value as base.
Definition: OgreAnimable.h:102
Ogre::Exception::ERR_ITEM_NOT_FOUND
Definition: OgreException.h:106
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::AnimableObject::AnimableDictionaryMap
map< String, StringVector >::type AnimableDictionaryMap
Definition: OgreAnimable.h:241
OgreException.h
Ogre::AnimableValue::VECTOR3
Definition: OgreAnimable.h:81
Ogre::AnimableValue::QUATERNION
Definition: OgreAnimable.h:83
Ogre::SharedPtr< AnimableValue >
Ogre::AnimableObject::msAnimableDictionary
static AnimableDictionaryMap msAnimableDictionary
Static map of class name to list of animable value names.
Definition: OgreAnimable.h:243
OgreColourValue.h
Ogre::AnimableValue::INT
Definition: OgreAnimable.h:78
OgreHeaderPrefix.h
Ogre::AnimableValuePtr
SharedPtr< AnimableValue > AnimableValuePtr
Definition: OgreAnimable.h:231
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(const Radian &val)
Internal method to set a value as base.
Definition: OgreAnimable.h:126
Ogre::Exception::ERR_NOT_IMPLEMENTED
Definition: OgreException.h:110
Ogre::AnimableValue::mBaseValueInt
int mBaseValueInt
Definition: OgreAnimable.h:95
Ogre::Degree
Wrapper class which indicates a given angle value is in Degrees.
Definition: OgreMath.h:98
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(const Vector4 &)
Apply delta value.
Definition: OgreAnimable.h:206
OgreVector2.h
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(const Vector4 &val)
Internal method to set a value as base.
Definition: OgreAnimable.h:110
Ogre::AnimableObject::AnimableObject
AnimableObject()
Definition: OgreAnimable.h:291
Ogre::AnimableObject::createAnimableDictionary
void createAnimableDictionary(void) const
Internal method for creating a dictionary of animable value names for the class, if it does not alrea...
Definition: OgreAnimable.h:254
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Ogre::Degree::valueRadians
Real valueRadians() const
Definition: OgreMath.h:727
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::AnimableValue::REAL
Definition: OgreAnimable.h:79
Ogre::AnimableValue::setAsBaseValue
virtual void setAsBaseValue(const Degree &val)
Internal method to set a value as base.
Definition: OgreAnimable.h:131
Ogre::Radian
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47
Ogre::AnimableValue::applyDeltaValue
virtual void applyDeltaValue(int)
Apply delta value.
Definition: OgreAnimable.h:190

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.