# 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  

animation_optimizer.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000-2002 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_ANIMATION_OPTIMIZER_H
00027 #define NL_ANIMATION_OPTIMIZER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/quat.h"
00031 #include "nel/misc/vectord.h"
00032 
00033 
00034 namespace NL3D 
00035 {
00036 
00037 using   NLMISC::CQuat;
00038 using   NLMISC::CQuatD;
00039 using   NLMISC::CVector;
00040 using   NLMISC::CVectorD;
00041 
00042 class   CAnimation;
00043 class   ITrack;
00044 
00045 // ***************************************************************************
00054 class CAnimationOptimizer
00055 {
00056 public:
00057 
00059         CAnimationOptimizer();
00060 
00070         void            setQuaternionThreshold(double lowPrecThre, double highPrecThre);
00071 
00079         void            setVectorThreshold(double lowPrecThre, double highPrecThre);
00080 
00086         void            addLowPrecisionTrack(const std::string &name);
00087 
00089         void            clearLowPrecisionTracks();
00090 
00094         void            setSampleFrameRate(float frameRate);
00095 
00096 
00101         void            optimize(const CAnimation &animIn, CAnimation &animOut);
00102 
00103 
00104 // ******************
00105 private:
00106         float           _SampleFrameRate;
00107         double          _QuaternionThresholdLowPrec;
00108         double          _QuaternionThresholdHighPrec;
00109         double          _QuaternionThreshold;
00110         double          _VectorThresholdLowPrec;
00111         double          _VectorThresholdHighPrec;
00112         double          _VectorThreshold;
00113 
00114 
00115         // see addLowPrecisionTrack
00116         std::vector<std::string>        _LowPrecTrackKeyName;
00117 
00118         // For Sampling of Quaternion Tracks.
00119         std::vector<uint16>             _TimeList;
00120         std::vector<CQuat>              _QuatKeyList;
00121 
00122         // For Sampling of Vector Tracks.
00123         std::vector<CVector>    _VectorKeyList;
00124 
00125 private:
00126 
00127         // Clone a ITrack (using a CMemStream)
00128         ITrack          *cloneTrack(const ITrack        *trackIn);
00129 
00130         // true if the track can be optimized.
00131         bool            isTrackOptimisable(const ITrack *trackIn);
00132 
00133         // return an optimized version of trackIn. Type returned should be different (eg: CTrackSampledQuat)
00134         ITrack          *optimizeTrack(const ITrack     *trackIn);
00135 
00136         // see addLowPrecisionTrack()
00137         bool            isLowPrecisionTrack(const std::string &trackName);
00138 
00139 
00141         // @{
00142 
00147         void            sampleQuatTrack(const ITrack *trackIn, float beginTime, float endTime, uint numSamples);
00148 
00152         bool            testConstantQuatTrack();
00153 
00156         void            optimizeQuatTrack();
00157 
00161         bool            nearlySameQuaternion(const CQuatD &quat0, const CQuatD &quat1);
00162 
00163         // @}
00164 
00165 
00167         // @{
00168 
00172         void            sampleVectorTrack(const ITrack *trackIn, float beginTime, float endTime, uint numSamples);
00173 
00176         bool            testConstantVectorTrack();
00177 
00180         void            optimizeVectorTrack();
00181 
00184         bool            nearlySameVector(const CVectorD &v0, const CVectorD &v1);
00185 
00186         // @}
00187 
00188 };
00189 
00190 
00191 } // NL3D
00192 
00193 
00194 #endif // NL_ANIMATION_OPTIMIZER_H
00195 
00196 /* End of animation_optimizer.h */