From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/animated__value_8h-source.html | 268 ++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 docs/doxygen/nel/animated__value_8h-source.html (limited to 'docs/doxygen/nel/animated__value_8h-source.html') diff --git a/docs/doxygen/nel/animated__value_8h-source.html b/docs/doxygen/nel/animated__value_8h-source.html new file mode 100644 index 00000000..046e2e28 --- /dev/null +++ b/docs/doxygen/nel/animated__value_8h-source.html @@ -0,0 +1,268 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

animated_value.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_ANIMATED_VALUE_H
+00027 #define NL_ANIMATED_VALUE_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/vector.h"
+00031 #include "nel/misc/quat.h"
+00032 #include "nel/misc/rgba.h"
+00033 
+00034 
+00035 namespace NL3D 
+00036 {
+00037 
+00038 
+00047 class IAnimatedValue
+00048 {
+00049 public:
+00058         virtual void blend (const IAnimatedValue& value, float blendFactor) =0;
+00059 
+00065         virtual void affect (const IAnimatedValue& value) =0;
+00066 };
+00067 
+00068 
+00076 template<class T>
+00077 class CAnimatedValueBlendable : public IAnimatedValue
+00078 {
+00079 public:
+00080         // NOT TESTED, JUST COMPILED. FOR PURPOSE ONLY.
+00082         virtual void blend (const IAnimatedValue& value, float blendFactor)
+00083         {
+00084                 // Check types of value
+00085                 nlassert (typeid (value)==typeid(*this));
+00086 
+00087                 // Cast
+00088                 CAnimatedValueBlendable<T>      *pValue=(CAnimatedValueBlendable<T>*)&value;
+00089 
+00090                 // Blend
+00091                 Value=(T) (Value*blendFactor+pValue->Value*(1.f-blendFactor));
+00092         }
+00093         
+00099         virtual void affect (const IAnimatedValue& value)
+00100         {
+00101                 // Check types of value
+00102                 nlassert (typeid (value)==typeid(*this));
+00103 
+00104                 // Cast
+00105                 CAnimatedValueBlendable<T>      *pValue=(CAnimatedValueBlendable<T>*)&value;
+00106 
+00107                 // Blend
+00108                 Value=pValue->Value;
+00109         }
+00110 
+00111         // The value read and write
+00112         T       Value;
+00113 };
+00114 
+00115 
+00116 
+00124 class CAnimatedValueBlendable<NLMISC::CQuat> : public IAnimatedValue
+00125 {
+00126 public:
+00128         virtual void blend (const IAnimatedValue& value, float blendFactor)
+00129         {
+00130                 // Check types of value
+00131                 nlassert (typeid (value)==typeid(*this));
+00132 
+00133                 // Cast.
+00134                 CAnimatedValueBlendable<NLMISC::CQuat>  *pValue=(CAnimatedValueBlendable<NLMISC::CQuat>*)&value;
+00135 
+00136                 // blend.
+00137                 // Yoyo: no makeClosest is done, because the result seems to be better when done
+00138                 // before: for all blend values, and not one after one.
+00139                 Value= NLMISC::CQuat::slerp(Value, pValue->Value, 1-blendFactor);
+00140 
+00141         }
+00142 
+00148         virtual void affect (const IAnimatedValue& value)
+00149         {
+00150                 // Check types of value
+00151                 nlassert (typeid (value)==typeid(*this));
+00152 
+00153                 // Cast
+00154                 CAnimatedValueBlendable<NLMISC::CQuat>  *pValue=(CAnimatedValueBlendable<NLMISC::CQuat>*)&value;
+00155 
+00156                 // Blend
+00157                 Value=pValue->Value;
+00158         }
+00159 
+00160         // The value
+00161         NLMISC::CQuat   Value;
+00162 };
+00163 
+00164 
+00172 class CAnimatedValueBlendable<NLMISC::CRGBA> : public IAnimatedValue
+00173 {
+00174 public:
+00176         virtual void blend (const IAnimatedValue& value, float blendFactor)
+00177         {
+00178                 // Check types of value
+00179                 nlassert (typeid (value)==typeid(*this));
+00180 
+00181                 // Cast.
+00182                 CAnimatedValueBlendable<NLMISC::CRGBA>  *pValue=(CAnimatedValueBlendable<NLMISC::CRGBA>*)&value;
+00183 
+00184                 // blend.
+00185                 Value.blendFromui (pValue->Value, this->Value, (uint)(256.f*blendFactor));
+00186         }
+00187 
+00193         virtual void affect (const IAnimatedValue& value)
+00194         {
+00195                 // Check types of value
+00196                 nlassert (typeid (value)==typeid(*this));
+00197 
+00198                 // Cast
+00199                 CAnimatedValueBlendable<NLMISC::CRGBA>  *pValue=(CAnimatedValueBlendable<NLMISC::CRGBA>*)&value;
+00200 
+00201                 // Blend
+00202                 Value=pValue->Value;
+00203         }
+00204 
+00205         // The value
+00206         NLMISC::CRGBA   Value;
+00207 };
+00208 
+00209 
+00217 template<class T>
+00218 class CAnimatedValueNotBlendable : public IAnimatedValue
+00219 {
+00220 public:
+00221         virtual ~CAnimatedValueNotBlendable<T>() {}
+00223         virtual void blend (const IAnimatedValue& value, float blendFactor)
+00224         {
+00225                 // Check types of value
+00226                 nlassert (typeid (value)==typeid(*this));
+00227 
+00228                 // Cast
+00229                 CAnimatedValueNotBlendable<T>   *pValue=(CAnimatedValueNotBlendable<T>*)&value;
+00230 
+00231                 // Boolean blend
+00232                 if (blendFactor<0.5f)
+00233                         Value=pValue->Value;
+00234         }
+00235         
+00241         virtual void affect (const IAnimatedValue& value)
+00242         {
+00243                 // Check types of value
+00244                 nlassert (typeid (value)==typeid(*this));
+00245 
+00246                 // Cast
+00247                 CAnimatedValueNotBlendable<T>   *pValue=(CAnimatedValueNotBlendable<T>*)&value;
+00248 
+00249                 // Blend
+00250                 Value=pValue->Value;
+00251         }
+00252 
+00253         // The value
+00254         T       Value;
+00255 };
+00256 
+00257 
+00258 typedef CAnimatedValueNotBlendable<bool>                        CAnimatedValueBool;
+00259 typedef CAnimatedValueBlendable<sint32>                         CAnimatedValueInt;
+00260 typedef CAnimatedValueBlendable<float>                          CAnimatedValueFloat;
+00261 typedef CAnimatedValueBlendable<NLMISC::CVector>        CAnimatedValueVector;
+00262 typedef CAnimatedValueNotBlendable<std::string>         CAnimatedValueString;
+00263 typedef CAnimatedValueBlendable<NLMISC::CQuat>          CAnimatedValueQuat;
+00264 typedef CAnimatedValueBlendable<NLMISC::CRGBA>          CAnimatedValueRGBA;
+00265 
+00266 
+00267 } // NL3D
+00268 
+00269 
+00270 #endif // NL_ANIMATED_VALUE_H
+00271 
+00272 /* End of animated_value.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1