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/water__shape_8h-source.html | 335 +++++++++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 docs/doxygen/nel/water__shape_8h-source.html (limited to 'docs/doxygen/nel/water__shape_8h-source.html') diff --git a/docs/doxygen/nel/water__shape_8h-source.html b/docs/doxygen/nel/water__shape_8h-source.html new file mode 100644 index 00000000..983ca171 --- /dev/null +++ b/docs/doxygen/nel/water__shape_8h-source.html @@ -0,0 +1,335 @@ + + + + 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  
+

water_shape.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000, 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_WATER_SHAPE_H
+00027 #define NL_WATER_SHAPE_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/smart_ptr.h"
+00031 #include "nel/misc/aabbox.h"
+00032 #include "nel/misc/class_id.h"
+00033 #include "nel/misc/vector_2f.h"
+00034 #include "nel/misc/polygon.h"
+00035 #include "3d/track.h"
+00036 #include "nel/3d/animation_time.h"
+00037 
+00038 
+00039 
+00040 
+00041 
+00042 
+00043 
+00044 #include "3d/shape.h"
+00045 #include "3d/vertex_buffer.h"
+00046 #include "3d/driver.h"
+00047 
+00048 #include <memory>
+00049 
+00050 namespace NL3D {
+00051 
+00052 // defines
+00053 const CVertexBuffer::TValue   WATER_VB_POS  = CVertexBuffer::Position;
+00054 const CVertexBuffer::TValue   WATER_VB_DX   = CVertexBuffer::TexCoord0;
+00055 
+00056 
+00057 
+00058 // class id for water
+00059 const NLMISC::CClassId WaterModelClassId =  NLMISC::CClassId(0x41a0732e, 0x6c664506);
+00060 
+00061 // class id for wave maker
+00062 const NLMISC::CClassId WaveMakerModelClassId =  NLMISC::CClassId(0x16da3356, 0x7dec65fd);
+00063 
+00079 class CWaterShape : public IShape
+00080 {
+00081 public:
+00082         NLMISC_DECLARE_CLASS(CWaterShape);
+00083 
+00085 
+00086 
+00087         CWaterShape();
+00088 
+00090         ~CWaterShape();
+00091 
+00092 
+00094         void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
+00096 
+00097 
+00099         virtual CTransformShape         *createInstance(CScene &scene);
+00100 
+00102         virtual bool                            clip(const std::vector<CPlane>  &pyramid, const CMatrix &worldMatrix);
+00103 
+00105         virtual void                            render(IDriver *drv, CTransformShape *trans, bool opaquePass) {}
+00106 
+00108         virtual void                            getAABBox(NLMISC::CAABBox &bbox) const { bbox = _BBox; }
+00109 
+00111         virtual float                           getNumTriangles (float distance);
+00112 
+00114         virtual void                            flushTextures (IDriver &driver);
+00115 
+00116 
+00118 
+00119 
+00120                 void                    setWaterPoolID(uint32 id) { _WaterPoolID = id; }                
+00121                 uint32                  getWaterPoolID() const    { return _WaterPoolID; }
+00123                 static void             setScreenGridSize(uint32 x, uint32 y);
+00125                 static void             setGridBorderSize(uint32 x, uint32 y);          
+00126                 static uint32   getScreenXGridSize()  { return _XScreenGridSize; }
+00127                 static uint32   getScreenYGridSize()  { return _YScreenGridSize; }
+00128                 static uint32   getXGridBorder()  { return _XGridBorder; }
+00129                 static uint32   getYGridBorder()  { return _YGridBorder; }
+00130 
+00131         
+00132                 // set a polygon that represent this shape. It must be a 2d polygon, with z kzpt to 0 everywhere
+00133                 void                                    setShape(const NLMISC::CPolygon2D &poly);
+00134 
+00136                 const NLMISC::CPolygon2D &getShape() const { return _Poly; }
+00137 
+00139                 void getShapeInWorldSpace(NLMISC::CPolygon &poly) const;
+00140 
+00142                 void    setWaveHeightFactor(float f) { _WaveHeightFactor = f; }
+00143 
+00145                 float   getWaveHeightFactor() const { return _WaveHeightFactor; }
+00146 
+00148 
+00149 
+00151 
+00152                  // set the environment reflected by water. Index should be 0 for the above texture and 1 for the below texture
+00153                 void                            setEnvMap(uint index, ITexture *envMap);
+00154                 ITexture                        *getEnvMap(uint index) { nlassert(index < 2); return (ITexture *) _EnvMap[index];}
+00155                 const ITexture          *getEnvMap(uint index) const { nlassert(index < 2); return (const ITexture *) _EnvMap[index];}
+00156 
+00160                 void                            setHeightMap(uint k, ITexture *hm);
+00161                 ITexture                        *getHeightMap(uint k);
+00162                 const ITexture          *getHeightMap(uint k) const;
+00163                 void                            setHeightMapScale(uint k, const NLMISC::CVector2f &scale);
+00164                 NLMISC::CVector2f       getHeightMapScale(uint k) const;
+00165                 void                        setHeightMapSpeed(uint k, const NLMISC::CVector2f &speed);  // speed given in texture units
+00166                 NLMISC::CVector2f   getHeightMapSpeed(uint k) const;    
+00167 
+00168 
+00169 
+00170                 // set a color map
+00171                 void                            setColorMap(ITexture *map);
+00172                 ITexture                        *getColorMap() { return _ColorMap; }
+00173                 const ITexture          *getColorMap() const { return _ColorMap; }
+00174                 // set A 2x3 matrix used to compute position in colormap, from the x and y coordinates in world space
+00175                 void                            setColorMapMat(const NLMISC::CVector2f &column0, const NLMISC::CVector2f &column1, const NLMISC::CVector2f &pos);
+00176                 void                            getColorMapMat(NLMISC::CVector2f &column0, NLMISC::CVector2f &column1, NLMISC::CVector2f &pos);
+00178 
+00180 
+00181                 void    setTransitionRatio(float percent) { _TransitionRatio = percent; }               
+00182                 float   getTransitionRatio() const                 {  return _TransitionRatio; }                
+00184 
+00186         // @{
+00187         CTrackDefaultVector*    getDefaultPos ()                {return &_DefaultPos;}
+00188         CTrackDefaultVector*    getDefaultScale ()              {return &_DefaultScale;}
+00189         CTrackDefaultQuat*              getDefaultRotQuat ()    {return &_DefaultRotQuat;}
+00190 
+00191         // @}
+00192 
+00194         // @{
+00196         void                            enableLightMapping(bool enable = true) { _ComputeLightmap = enable; }
+00197         bool                            isLightMappingEnabled() const  { return _ComputeLightmap; }     
+00198 
+00199 private:
+00200         friend class    CWaterModel;    
+00201         friend class    CWaterRenderObs;
+00202         void                                                            computeBBox();
+00203         void                                                            envMapUpdate();
+00204         void                                                            updateHeightMapNormalizationFactors();
+00205         static void                                                     initVertexProgram();
+00206         static void                                                     setupVertexBuffer();    
+00207 private:
+00208         NLMISC::CAABBox                                         _BBox;  // computed from the poly
+00209         NLMISC::CPolygon2D                                      _Poly;
+00210         uint32                                                          _WaterPoolID;   
+00211         NLMISC::CSmartPtr<ITexture>                     _EnvMap[2];     
+00212         NLMISC::CSmartPtr<ITexture>                     _BumpMap[2];    
+00213         NLMISC::CSmartPtr<ITexture>                     _ColorMap;
+00214 
+00215         NLMISC::CVector2f                                       _HeightMapScale[2];             
+00216         NLMISC::CVector2f                                       _HeightMapSpeed[2];             
+00217         NLMISC::CVector2f                                       _ColorMapMatColumn0, _ColorMapMatColumn1, _ColorMapMatPos;      
+00218 
+00219         CTrackDefaultVector                                     _DefaultPos;
+00220         CTrackDefaultVector                                     _DefaultScale;
+00221         CTrackDefaultQuat                                       _DefaultRotQuat;
+00222         float                                                           _TransitionRatio;       
+00223         float                                                           _WaveHeightFactor;
+00224         bool                                                            _ComputeLightmap;
+00225         bool                                                            _HeightMapTouch[2];
+00226         float                                                           _HeightMapNormalizationFactor[2];
+00227                 
+00228         static uint32                                                   _XScreenGridSize; // size with y rotation = 0
+00229         static uint32                                                   _YScreenGridSize;
+00230         static uint32                                                   _MaxGridSize; // size with max rotation around y (without borders)
+00231         static uint32                                                   _XGridBorder;
+00232         static uint32                                                   _YGridBorder;
+00233 
+00234         static CVertexBuffer                                    _VB;
+00235         static std::vector<uint32>                              _IBUpDown;
+00236         static std::vector<uint32>                              _IBDownUp;      
+00237         static bool                                                             _GridSizeTouched;
+00238         //
+00239         static std::auto_ptr<CVertexProgram>    _VertexProgramBump1;
+00240         static std::auto_ptr<CVertexProgram>    _VertexProgramBump2;
+00241         //
+00242         static std::auto_ptr<CVertexProgram>    _VertexProgramBump1Diffuse;
+00243         static std::auto_ptr<CVertexProgram>    _VertexProgramBump2Diffuse;
+00244         //
+00245         static std::auto_ptr<CVertexProgram>    _VertexProgramNoBump;
+00246         static std::auto_ptr<CVertexProgram>    _VertexProgramNoBumpDiffuse;
+00247 };
+00248 
+00249 
+00251 class CWaveMakerShape : public IShape
+00252 {
+00253 public: 
+00254         NLMISC_DECLARE_CLASS(CWaveMakerShape);
+00256 
+00257 
+00258                 CWaveMakerShape();
+00259 
+00261                 ~CWaveMakerShape();
+00262 
+00263 
+00265                 void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
+00267 
+00268 
+00270         virtual CTransformShape         *createInstance(CScene &scene);
+00271 
+00273         virtual bool                            clip(const std::vector<CPlane>  &pyramid, const CMatrix &worldMatrix);
+00274 
+00276         virtual void                            render(IDriver *drv, CTransformShape *trans, bool opaquePass) {}
+00277 
+00279         virtual void                            getAABBox(NLMISC::CAABBox &bbox) const;
+00280 
+00282         virtual float                           getNumTriangles (float distance) { return 0; }
+00283 
+00285         virtual void                            flushTextures (IDriver &driver) {}
+00286 
+00287 
+00289         void                    setPeriod(TAnimationTime period) { _Period = period; }
+00290         TAnimationTime  getPeriod() const { return _Period; }
+00291 
+00293         void                    setIntensity(float intensity) { _Intensity = intensity; }
+00294         float                   getIntensity() const { return _Intensity; }
+00295 
+00297         void            setRadius(float radius) { _Radius = radius; }
+00298         float                   getRadius() const { return _Radius; }
+00299 
+00301         void                    setWaterPoolID(uint32 id) { _PoolID = id; }
+00302         uint32                  getWaterPoolID() const    { return _PoolID; }
+00303 
+00305         void                    setImpulsionMode(bool on = true) { _ImpulsionMode = on; }
+00306         bool                    getImpulsionMode() const { return _ImpulsionMode; }
+00307 
+00308         CTrackDefaultVector*    getDefaultPos ()                {return &_DefaultPos;}
+00309 private:
+00310         friend  class   CWaveMakerDetailObs;
+00311         TAnimationTime                                          _Period;
+00312         float                                                           _Radius;
+00313         uint32                                                          _PoolID;
+00314         float                                                           _Intensity;
+00315         bool                                                            _ImpulsionMode;
+00316         CTrackDefaultVector                                     _DefaultPos;
+00317 };
+00318 
+00319 
+00320 } // NL3D
+00321 
+00322 
+00323 #endif // NL_WATER_SHAPE_H
+00324 
+00325 /* End of water_shape.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1