/usr/include/OGRE/OgreAnimable.h is in libogre-dev 1.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2011 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"
namespace Ogre {
/** \addtogroup Core
* @{
*/
/** \addtogroup Animation
* @{
*/
/** Defines an object property which is animable, i.e. may be keyframed.
@remarks
Animable properties are those which can be altered over time by a
predefined keyframe sequence. They may be set directly, or they may
be modified from their existing state (common if multiple animations
are expected to apply at once). Implementors of this interface are
expected to override the 'setValue', 'setCurrentStateAsBaseValue' and
'applyDeltaValue' methods appropriate to the type in question, and to
initialise the type.
@par
AnimableValue instances are accessible through any class which extends
AnimableObject in order to expose it's animable properties.
@note
This class is an instance of the Adapter pattern, since it generalises
access to a particular property. Whilst it could have been templated
such that the type which was being referenced was compiled in, this would
make it more difficult to aggregated generically, and since animations
are often comprised of multiple properties it helps to be able to deal
with all values through a single class.
*/
class _OgreExport AnimableValue : public AnimableAlloc
{
public:
/// The type of the value being animated
enum ValueType
{
INT,
REAL,
VECTOR2,
VECTOR3,
VECTOR4,
QUATERNION,
COLOUR,
RADIAN,
DEGREE
};
protected:
/// Value type
ValueType mType;
/// Base value data
union
{
int mBaseValueInt;
Real mBaseValueReal[4];
};
/// Internal method to set a value as base
virtual void setAsBaseValue(int val) { mBaseValueInt = val; }
/// Internal method to set a value as base
virtual void setAsBaseValue(Real val) { mBaseValueReal[0] = val; }
/// Internal method to set a value as base
virtual void setAsBaseValue(const Vector2& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*2); }
/// Internal method to set a value as base
virtual void setAsBaseValue(const Vector3& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*3); }
/// Internal method to set a value as base
virtual void setAsBaseValue(const Vector4& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
/// Internal method to set a value as base
virtual void setAsBaseValue(const Quaternion& val)
{ memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
/// Internal method to set a value as base
virtual void setAsBaseValue(const Any& val);
/// Internal method to set a value as base
virtual void setAsBaseValue(const ColourValue& val)
{
mBaseValueReal[0] = val.r;
mBaseValueReal[1] = val.g;
mBaseValueReal[2] = val.b;
mBaseValueReal[3] = val.a;
}
/// Internal method to set a value as base
virtual void setAsBaseValue(const Radian& val)
{
mBaseValueReal[0] = val.valueRadians();
}
/// Internal method to set a value as base
virtual void setAsBaseValue(const Degree& val)
{
mBaseValueReal[0] = val.valueRadians();
}
public:
AnimableValue(ValueType t) : mType(t) {}
virtual ~AnimableValue() {}
/// Gets the value type of this animable value
ValueType getType(void) const { return mType; }
/// Sets the current state as the 'base' value; used for delta animation
virtual void setCurrentStateAsBaseValue(void) = 0;
/// Set value
virtual void setValue(int) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(Real) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const Vector2&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const Vector3&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const Vector4&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const Quaternion&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const ColourValue&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const Radian&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const Degree&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void setValue(const Any& val);
// reset to base value
virtual void resetToBaseValue(void);
/// Apply delta value
virtual void applyDeltaValue(int) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Set value
virtual void applyDeltaValue(Real) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const Vector2&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const Vector3&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const Vector4&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const Quaternion&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const ColourValue&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const Degree&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const Radian&) {
OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
}
/// Apply delta value
virtual void applyDeltaValue(const Any& val);
};
typedef SharedPtr<AnimableValue> AnimableValuePtr;
/** Defines an interface to classes which have one or more AnimableValue
instances to expose.
*/
class _OgreExport AnimableObject
{
protected:
typedef map<String, StringVector>::type AnimableDictionaryMap;
/// Static map of class name to list of animable value names
static AnimableDictionaryMap msAnimableDictionary;
/** Get the name of the animable dictionary for this class.
@remarks
Subclasses must override this if they want to support animation of
their values.
*/
virtual const String& getAnimableDictionaryName(void) const
{ return StringUtil::BLANK; }
/** Internal method for creating a dictionary of animable value names
for the class, if it does not already exist.
*/
void createAnimableDictionary(void) const
{
if (msAnimableDictionary.find(getAnimableDictionaryName())
== msAnimableDictionary.end())
{
StringVector vec;
initialiseAnimableDictionary(vec);
msAnimableDictionary[getAnimableDictionaryName()] = vec;
}
}
/// Get an updateable reference to animable value list
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");
}
}
/** Internal method for initialising dictionary; should be implemented by
subclasses wanting to expose animable parameters.
*/
virtual void initialiseAnimableDictionary(StringVector&) const {}
public:
AnimableObject() {}
virtual ~AnimableObject() {}
/** Gets a list of animable value names for this object. */
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");
}
}
/** Create a reference-counted AnimableValuePtr for the named value.
@remarks
You can use the returned object to animate a value on this object,
using AnimationTrack. Subclasses must override this if they wish
to support animation of their values.
*/
virtual AnimableValuePtr createAnimableValue(const String& valueName)
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"No animable value named '" + valueName + "' present.",
"AnimableObject::createAnimableValue");
}
};
/** @} */
/** @} */
}
#endif
|