# 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  

ps_plane_basis_maker.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_PLANE_BASIS_MAKER_H
00027 #define NL_PLANE_BASIS_MAKER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/ps_attrib_maker_template.h"
00031 #include "3d/ps_attrib_maker_bin_op.h"
00032 #include "3d/ps_plane_basis.h"
00033 #include "3d/fast_floor.h"
00034 
00035 
00036 namespace NL3D {
00037 
00038 const char *CPSAttribMaker<CPlaneBasis>::getType() { return "CPlaneBasis";}
00039 
00045 class CPSPlaneBasisBlender : public CPSValueBlender<CPlaneBasis>
00046 {
00047 public:
00048         NLMISC_DECLARE_CLASS(CPSPlaneBasisBlender);
00049 
00050         CPSPlaneBasisBlender(const CPlaneBasis &startBasis = CPlaneBasis(NLMISC::CVector::I), const CPlaneBasis &endBasis = CPlaneBasis(NLMISC::CVector::J), float nbCycles = 1.0f) : CPSValueBlender<CPlaneBasis>(nbCycles)
00051         {
00052                 _F.setValues(startBasis, endBasis);
00053         }
00054         CPSAttribMakerBase *clone() const { return new CPSPlaneBasisBlender(*this); }
00055 };
00056 
00057 
00059 class CPSPlaneBasisGradient : public CPSValueGradient<CPlaneBasis>
00060 {
00061 public:
00062         NLMISC_DECLARE_CLASS(CPSPlaneBasisGradient);
00063 
00070         CPSPlaneBasisGradient(const CPlaneBasis *basisTab = CPSPlaneBasisGradient::DefaultPlaneBasisTab
00071                 , uint32 nbValues = 2, uint32 nbStages = 16, float nbCycles = 1.0f) : CPSValueGradient<CPlaneBasis>(nbCycles)
00072         {
00073                 _F.setValues(basisTab, nbValues, nbStages);
00074         }
00075         CPSAttribMakerBase *clone() const { return new CPSPlaneBasisGradient(*this); }
00076         static CPlaneBasis DefaultPlaneBasisTab[];      
00077 };
00078 
00079 
00080 
00085 class CPSPlaneBasisFollowSpeed : public CPSAttribMaker<CPlaneBasis>
00086 {
00087         public:
00088 
00089                 CPSPlaneBasisFollowSpeed() : CPSAttribMaker<CPlaneBasis>(1) {}
00090 
00092                 virtual CPlaneBasis get(CPSLocated *loc, uint32 index);
00093 
00099                 virtual void *make(CPSLocated *loc,
00100                                                    uint32 startIndex,
00101                                                    void *tab,
00102                                                    uint32 stride,
00103                                                    uint32 numAttrib,
00104                                                    bool enableNoCopy = false,
00105                                                    uint32 srcStep = (1 << 16)
00106                                                   ) const;
00107 
00111                 virtual void make4(CPSLocated *loc,
00112                                                    uint32 startIndex,
00113                                                    void *tab,
00114                                                    uint32 stride,
00115                                                    uint32 numAttrib,
00116                                                    uint32 srcStep = (1 << 16)
00117                                                   ) const;
00118 
00119 
00123                 virtual void makeN(CPSLocated *loc,
00124                                                    uint32 startIndex,
00125                                                    void *tab,
00126                                                    uint32 stride,
00127                                                    uint32 numAttrib,
00128                                                    uint32 nbReplicate,
00129                                                    uint32 srcStep = (1 << 16)                                              
00130                                                   ) const;
00131 
00132                 NLMISC_DECLARE_CLASS(CPSPlaneBasisFollowSpeed);
00133 
00135                 virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream)
00136                 {
00137                         // nothing to save here
00138                         f.serialVersion(1);
00139                 }
00140                 CPSAttribMakerBase *clone() const { return new CPSPlaneBasisFollowSpeed(*this); }
00141 };
00142 
00143 
00144 
00145 
00150 class CPSPlaneBasisMemory : public CPSAttribMakerMemory<CPlaneBasis>
00151 {
00152 public:
00153         CPSPlaneBasisMemory() { setDefaultValue(CPlaneBasis(NLMISC::CVector::K)); }
00154         NLMISC_DECLARE_CLASS(CPSPlaneBasisMemory);
00155         CPSAttribMakerBase *clone() const { return new CPSPlaneBasisMemory(*this); }
00156 };
00157 
00158 
00162 class CPSPlaneBasisBinOp : public CPSAttribMakerBinOp<CPlaneBasis>
00163 {
00164 public:
00165         NLMISC_DECLARE_CLASS(CPSPlaneBasisBinOp);
00166         CPSAttribMakerBase *clone() const { return new CPSPlaneBasisBinOp(*this); }
00167 };
00168 
00169 
00170 // a functor object that produce basis by applying a rotation over a fixed axis
00171 class CSpinnerFunctor
00172 {
00173 public:
00174         CSpinnerFunctor();
00175         const CPlaneBasis &operator()(float date) const { return _PBTab[OptFastFloor(date * _NbSamples)]; }
00177         void                                    setAxis(const NLMISC::CVector &axis);
00179         const NLMISC::CVector   getAxis(void) const { return _Axis;}
00181         const void setNumSamples(uint32 nbSamples);
00183         const uint32 getNumSamples(void) const;
00185         void serial(NLMISC::IStream &f) throw(NLMISC::EStream); 
00186 protected:
00187         std::vector<CPlaneBasis>        _PBTab;
00188         uint32                                          _NbSamples;
00189         NLMISC::CVector                         _Axis;
00191         void                                            updateSamples(void);
00192 };
00193 
00194 
00195 
00197 class CPSBasisSpinner : public CPSAttribMakerT<CPlaneBasis, CSpinnerFunctor>
00198 {
00199 public:
00200         CPSBasisSpinner() : CPSAttribMakerT<CPlaneBasis, CSpinnerFunctor>(1) {}
00201         NLMISC_DECLARE_CLASS(CPSBasisSpinner);
00202         CPSAttribMakerBase *clone() const { return new CPSBasisSpinner(*this); }
00203 };
00204 
00205 
00206 
00207 } // NL3D
00208 
00209 
00210 #endif // NL_PLANE_BASIS_MAKER_H
00211 
00212 /* End of plane_basis_maker.h */