# 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  

key.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_KEY_H
00027 #define NL_KEY_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/stream.h"
00033 #include "nel/misc/rgba.h"
00034 
00035 // NOT TESTED, JUST COMPILED. FOR PURPOSE ONLY.
00036 
00037 namespace NL3D 
00038 {
00039 
00040 
00041 // ***************************************************************************
00049 template<class T>
00050 class CKey
00051 {
00052 public:
00054         typedef T       TValueType;
00055 
00056 public:
00057 
00059         void serial (NLMISC::IStream& f) throw (NLMISC::EStream)
00060         {
00061                 // Version number
00062                 (void)f.serialVersion (0);
00063 
00064                 // Serial the value
00065                 f.serial (Value);
00066         };
00067 
00069         T                                       Value;
00070 
00071 
00072 // *********************
00073 public:
00074         // PRIVATE. used by ITrackKeyFramer, not serialised (compiled).
00075         // 1/(nextKeyTime-thisKeyTime).
00076         float                           OODeltaTime;
00077 
00078 };
00079 
00080 
00081 // ***************************************************************************
00089 template<class T>
00090 class CKeyTCB : public CKey<T>
00091 {
00092 public:
00093 
00095         void serial (NLMISC::IStream& f) throw (NLMISC::EStream)
00096         {
00097                 // Version number
00098                 (void)f.serialVersion (0);
00099 
00100                 // Serial the value
00101                 f.serial (Value);
00102                 f.serial (Tension);
00103                 f.serial (Continuity);
00104                 f.serial (Bias);
00105                 f.serial (EaseTo);
00106                 f.serial (EaseFrom);
00107         };
00108 
00109         float   Tension;
00110         float   Continuity;
00111         float   Bias;
00112         float   EaseTo;
00113         float   EaseFrom;
00114 
00115 
00116 // *********************
00117 public:
00118         // PRIVATE. used by ITrackKeyFramer, not serialised (compiled).
00119         // computed tangents.
00120         T               TanTo, TanFrom;
00121         // computed ease parameters, with next key.
00122         float   Ease0, Ease1;
00123         float   EaseK, EaseKOverEase0, EaseKOverEase1;
00124 
00125 };
00126 
00127 
00128 // ***************************************************************************
00136 template<class T>
00137 class CKeyBezier : public CKey<T>
00138 {
00139 public:
00140 
00142         void serial (NLMISC::IStream& f) throw (NLMISC::EStream)
00143         {
00144                 // Version number
00145                 (void)f.serialVersion (0);
00146 
00147                 // Serial the value
00148                 f.serial (Value);
00149                 f.serial (InTan);
00150                 f.serial (OutTan);
00151                 f.serial (Step);
00152         };
00153 
00155 
00164         // @{
00165         T               InTan;
00166         T               OutTan;
00167         bool    Step;
00168         // @}
00169 };
00170 
00171 
00172 // ***************************************************************************
00173 // Special implementation for Quaternions.
00174 // ***************************************************************************
00175 
00176 
00177 // ***************************************************************************
00187 class   CKeyTCB<NLMISC::CAngleAxis> : public CKey<NLMISC::CAngleAxis>
00188 {
00189 public:
00190 
00192         void serial (NLMISC::IStream& f) throw (NLMISC::EStream)
00193         {
00194                 // Version number
00195                 (void)f.serialVersion (0);
00196 
00197                 // Serial the value
00198                 f.serial (Value);
00199                 f.serial (Tension);
00200                 f.serial (Continuity);
00201                 f.serial (Bias);
00202                 f.serial (EaseTo);
00203                 f.serial (EaseFrom);
00204         };
00205 
00206         float   Tension;
00207         float   Continuity;
00208         float   Bias;
00209         float   EaseTo;
00210         float   EaseFrom;
00211 
00212 
00213 // *********************
00214 public:
00215         // PRIVATE. used by ITrackKeyFramer, not serialised (compiled).
00216         // Local AngleAxis to the preceding Key (axis is in local basis, unlike "Value" where the axis is in World space ).
00217         NLMISC::CAngleAxis      LocalAngleAxis;
00218         // computed quaternions/tangents.
00219         NLMISC::CQuat           Quat, A, B;
00220         // computed ease parameters, with next key.
00221         float   Ease0, Ease1;
00222         float   EaseK, EaseKOverEase0, EaseKOverEase1;
00223 };
00224 
00225 
00226 // ***************************************************************************
00235 class   CKeyBezier<NLMISC::CQuat> : public CKey<NLMISC::CQuat>
00236 {
00237 public:
00238 
00240         void serial (NLMISC::IStream& f) throw (NLMISC::EStream)
00241         {
00242                 // Version number
00243                 (void)f.serialVersion (0);
00244 
00245                 // Serial the value
00246                 f.serial (Value);
00247         };
00248 
00249 
00250 // *********************
00251 public:
00252         // PRIVATE. used by ITrackKeyFramer, not serialised (compiled).
00253         // computed quaternions/tangents.
00254         NLMISC::CQuat           A;
00255 };
00256 
00257 
00258 // ***************************************************************************
00259 // Predefined types
00260 // ***************************************************************************
00261 
00262 // ** Const - Linear keys
00263 typedef CKey<std::string>               CKeyString;
00264 typedef CKey<bool>                              CKeyBool;
00265 typedef CKey<float>                             CKeyFloat;
00266 typedef CKey<NLMISC::CVector>   CKeyVector;
00267 typedef CKey<NLMISC::CQuat>             CKeyQuat;
00268 typedef CKey<NLMISC::CRGBA>             CKeyRGBA;
00269 typedef CKey<sint32>                    CKeyInt;
00270 // NB: For precision and optimisation (space/speed), RGBA and sint32 const/linear tracks use CKeyRGBA and CKeyInt keys repsectively.
00271 
00272 
00273 // ** TCB keys
00274 typedef CKeyTCB<float>                          CKeyTCBFloat;
00275 typedef CKeyTCB<NLMISC::CVector>        CKeyTCBVector;
00276 typedef CKeyTCB<NLMISC::CAngleAxis>     CKeyTCBQuat;
00277 // NB: RGBA and sint32 TCB tracks use CKeyTCBVector and CKeyTCBFloat respectively.
00278 
00279 // ** Bezier keys
00280 typedef CKeyBezier<float>                       CKeyBezierFloat;
00281 typedef CKeyBezier<NLMISC::CVector>     CKeyBezierVector;
00282 typedef CKeyBezier<NLMISC::CQuat>       CKeyBezierQuat;
00283 // NB: RGBA and sint32 bezier tracks use CKeyBezierVector and CKeyBezierFloat respectively.
00284 
00285 
00286 
00287 } // NL3D
00288 
00289 
00290 #endif // NL_KEY_H
00291 
00292 /* End of key.h */