# 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  

meshvp_wind_tree.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_MESHVP_WIND_TREE_H
00027 #define NL_MESHVP_WIND_TREE_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/mesh_vertex_program.h"
00031 #include "3d/vertex_program.h"
00032 
00033 
00034 namespace NL3D {
00035 
00036 
00037 // ***************************************************************************
00044 class CMeshVPWindTree : public IMeshVertexProgram
00045 {
00046 public:
00047         
00048 
00049         enum    {HrcDepth= 3};
00050 
00052         // @{
00053 
00055         float           Frequency[HrcDepth];
00057         float           FrequencyWindFactor[HrcDepth];
00059         float           PowerXY[HrcDepth];
00061         float           PowerZ[HrcDepth];
00063         float           Bias[HrcDepth];
00064 
00066         bool            SpecularLighting;
00067 
00068         // @}
00069 
00070 public:
00071 
00073         CMeshVPWindTree();
00074         virtual ~CMeshVPWindTree();
00075 
00076 
00078         // @{
00079 
00081         virtual void    initInstance(CMeshBaseInstance *mbi);
00083         virtual bool    begin(IDriver *drv,
00084                                                   CScene *scene,
00085                                                   CMeshBaseInstance *mbi,
00086                                                   const NLMISC::CMatrix &invertedModelMat,
00087                                                   const NLMISC::CVector & /*viewerPos*/);
00089         virtual void    end(IDriver *drv);      
00090 
00091         // Setup this shader for the given material. 
00092         virtual void    setupForMaterial(const CMaterial &mat,
00093                                                                          IDriver *drv,
00094                                                                          CScene *scene,
00095                                                                          CVertexBuffer *vb);
00096         // hard vb version
00097         virtual void    setupForMaterial(const CMaterial &mat,
00098                                                                          IDriver *drv,
00099                                                                          CScene *scene,
00100                                                                          IVertexBufferHard *vb);
00101 
00102 
00103 
00104         // Serial.
00105         virtual void    serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00106         NLMISC_DECLARE_CLASS(CMeshVPWindTree);
00107 
00108         // @}
00109 
00110 private:
00111         void    setupLighting(CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat);
00112 private:
00113 
00114         enum { NumVp = 16};     
00115 
00119         static  std::auto_ptr<CVertexProgram>   _VertexProgram[NumVp];
00120 
00121         // WindTree Time for this mesh param setup. Stored in mesh because same for all instances.
00122         float           _CurrentTime[HrcDepth];
00123         double          _LastSceneTime;
00124 
00125         // maximum amplitude vector for each level. Stored in mesh because same for all instances.
00126         CVector         _MaxDeltaPos[HrcDepth];
00127 
00128 
00129         // Compute a cosinus with an angle given in 0-1 <=> 0-2Pi. Actual values goes from 0 to 2.
00130         static float    speedCos(float angle);
00131 
00132         
00133         
00134         
00135 };
00136 
00137 
00138 } // NL3D
00139 
00140 
00141 #endif // NL_MESHVP_WIND_TREE_H
00142 
00143 /* End of meshvp_wind_tree.h */