OGRE: OgreAnimable.h Source File - OGRE Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# OgreAnimable.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __ANIMABLE_H__
    00030 #define __ANIMABLE_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreVector2.h"
    00034 #include "OgreVector3.h"
    00035 #include "OgreVector4.h"
    00036 #include "OgreQuaternion.h"
    00037 #include "OgreColourValue.h"
    00038 #include "OgreSharedPtr.h"
    00039 #include "OgreStringVector.h"
    00040 #include "OgreException.h"
    00041 #include "OgreAny.h"
    00042
    00043 namespace Ogre {
    00044
    00065     class _OgreExport AnimableValue
    00066     {
    00067     public:
    00069         enum ValueType
    00070         {
    00071             INT,
    00072             REAL,
    00073             VECTOR2,
    00074             VECTOR3,
    00075             VECTOR4,
    00076             QUATERNION,
    00077             COLOUR
    00078         };
    00079     protected:
    00081         ValueType mType;
    00082
    00084         union
    00085         {
    00086             int mBaseValueInt;
    00087             Real mBaseValueReal[4];
    00088         };
    00089
    00091         virtual void setAsBaseValue(int val) { mBaseValueInt = val; }
    00093         virtual void setAsBaseValue(Real val) { mBaseValueReal[0] = val; }
    00095         virtual void setAsBaseValue(const Vector2& val)
    00096         { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*2); }
    00098         virtual void setAsBaseValue(const Vector3& val)
    00099         { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*3); }
    00101         virtual void setAsBaseValue(const Vector4& val)
    00102         { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
    00104         virtual void setAsBaseValue(const Quaternion& val)
    00105         { memcpy(mBaseValueReal, val.ptr(), sizeof(Real)*4); }
    00107         virtual void setAsBaseValue(const Any& val);
    00109         virtual void setAsBaseValue(const ColourValue& val)
    00110         {
    00111             mBaseValueReal[0] = val.r;
    00112             mBaseValueReal[1] = val.g;
    00113             mBaseValueReal[2] = val.b;
    00114             mBaseValueReal[3] = val.a;
    00115         }
    00116
    00117
    00118     public:
    00119         AnimableValue(ValueType t) : mType(t) {}
    00120         virtual ~AnimableValue() {}
    00121
    00123         ValueType getType(void) const { return mType; }
    00124
    00126         virtual void setCurrentStateAsBaseValue(void) = 0;
    00127
    00129         virtual void setValue(int) {
    00130             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00131         }
    00133         virtual void setValue(Real) {
    00134             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00135         }
    00137         virtual void setValue(const Vector2&) {
    00138             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00139         }
    00141         virtual void setValue(const Vector3&) {
    00142             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00143         }
    00145         virtual void setValue(const Vector4&) {
    00146             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00147         }
    00149         virtual void setValue(const Quaternion&) {
    00150             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00151         }
    00153         virtual void setValue(const ColourValue&) {
    00154             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00155         }
    00157         virtual void setValue(const Any& val);
    00158
    00159         // reset to base value
    00160         virtual void resetToBaseValue(void);
    00161
    00163         virtual void applyDeltaValue(int) {
    00164             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00165         }
    00167         virtual void applyDeltaValue(Real) {
    00168             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00169         }
    00171         virtual void applyDeltaValue(const Vector2&) {
    00172             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00173         }
    00175         virtual void applyDeltaValue(const Vector3&) {
    00176             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00177         }
    00179         virtual void applyDeltaValue(const Vector4&) {
    00180             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00181         }
    00183         virtual void applyDeltaValue(const Quaternion&) {
    00184             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00185         }
    00187         virtual void applyDeltaValue(const ColourValue&) {
    00188             OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "", "");
    00189         }
    00191         virtual void applyDeltaValue(const Any& val);
    00192
    00193
    00194     };
    00195
    00196     typedef SharedPtr<AnimableValue> AnimableValuePtr;
    00197
    00198
    00199
    00203     class _OgreExport AnimableObject
    00204     {
    00205     protected:
    00206         typedef std::map<String, StringVector> AnimableDictionaryMap;
    00208         static AnimableDictionaryMap msAnimableDictionary;
    00214         virtual const String& getAnimableDictionaryName(void) const
    00215         { return StringUtil::BLANK; }
    00219         void createAnimableDictionary(void) const
    00220         {
    00221             if (msAnimableDictionary.find(getAnimableDictionaryName())
    00222                 == msAnimableDictionary.end())
    00223             {
    00224                 StringVector vec;
    00225                 initialiseAnimableDictionary(vec);
    00226                 msAnimableDictionary[getAnimableDictionaryName()] = vec;
    00227             }
    00228
    00229         }
    00230
    00232         StringVector& _getAnimableValueNames(void)
    00233         {
    00234             AnimableDictionaryMap::iterator i =
    00235                 msAnimableDictionary.find(getAnimableDictionaryName());
    00236             if (i != msAnimableDictionary.end())
    00237             {
    00238                 return i->second;
    00239             }
    00240             else
    00241             {
    00242                 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
    00243                     "Animable value list not found for " + getAnimableDictionaryName(),
    00244                     "AnimableObject::getAnimableValueNames");
    00245             }
    00246
    00247         }
    00248
    00252         virtual void initialiseAnimableDictionary(StringVector&) const {}
    00253
    00254
    00255     public:
    00256         AnimableObject() {}
    00257         virtual ~AnimableObject() {}
    00258
    00260         const StringVector& getAnimableValueNames(void) const
    00261         {
    00262             createAnimableDictionary();
    00263
    00264             AnimableDictionaryMap::iterator i =
    00265                 msAnimableDictionary.find(getAnimableDictionaryName());
    00266             if (i != msAnimableDictionary.end())
    00267             {
    00268                 return i->second;
    00269             }
    00270             else
    00271             {
    00272                 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
    00273                     "Animable value list not found for " + getAnimableDictionaryName(),
    00274                     "AnimableObject::getAnimableValueNames");
    00275             }
    00276
    00277         }
    00278
    00285         virtual AnimableValuePtr createAnimableValue(const String& valueName)
    00286         {
    00287             OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
    00288                 "No animable value named '" + valueName + "' present.",
    00289                 "AnimableObject::createAnimableValue");
    00290         }
    00291
    00292
    00293
    00294     };
    00295
    00296
    00297 }
    00298 #endif
    00299

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:25 2008