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/a02988.html | 1475 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1475 insertions(+) create mode 100644 docs/doxygen/nel/a02988.html (limited to 'docs/doxygen/nel/a02988.html') diff --git a/docs/doxygen/nel/a02988.html b/docs/doxygen/nel/a02988.html new file mode 100644 index 00000000..6ca78bd4 --- /dev/null +++ b/docs/doxygen/nel/a02988.html @@ -0,0 +1,1475 @@ + + +NeL: NL3D::CNoise3d class Reference + + + +
+

NL3D::CNoise3d Class Reference

#include <noise_3d.h> +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

 CNoise3d (NL3D::IDriver *pDriver)
void flush ()
void flush2passes ()
uint32 getDepth ()
uint32 getHeight ()
uint32 getWidth ()
void init (uint32 w=64, uint32 h=64, uint32 d=32)
void render (NLMISC::CQuadUV &qc, float wpos, float intensity)
void render2passes (NLMISC::CQuadUV &qc, float wpos, float intensity)
void renderGrid (uint32 nbw, uint32 nbh, uint32 w, uint32 h, float UStart, float VStart, float WStart, float dU, float dV, float dW, float intensity)
void renderGrid2passes (uint32 nbw, uint32 nbh, uint32 w, uint32 h, float UStart, float VStart, float WStart, float dU, float dV, float dW, float intensity)
 ~CNoise3d ()

Private Attributes

uint32 _Depth
NL3D::IDriver_Driver
uint32 _Height
float _Intensity
bool _IsDriverSupportCloudSinglePass
NL3D::CMaterial_Mat
uint8_Mem
uint32 _NbSliceH
uint32 _NbSliceW
uint32 _NbVertices
NLMISC::CUV_OffS
float _ScaleH
float _ScaleW
NLMISC::CSmartPtr< NL3D::CTextureMem_Tex
NL3D::CVertexBuffer _VertexBuffer
uint32 _Width
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + +
NL3D::CNoise3d::CNoise3d NL3D::IDriver pDriver  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 36 of file noise_3d.cpp. +

+References _IsDriverSupportCloudSinglePass, _Mat, _Mem, _NbVertices, and _OffS. +

+

00037 {
+00038         _Mem = NULL;
+00039         _Mat = NULL;
+00040         _OffS = NULL;
+00041         _Driver = pDriver;
+00042         _NbVertices = 0;
+00043         _IsDriverSupportCloudSinglePass = pDriver->supportCloudRenderSinglePass();
+00044 }
+
+

+ + + + +
+ + + + + + + + + +
NL3D::CNoise3d::~CNoise3d  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 47 of file noise_3d.cpp. +

+References _Mat, and _OffS. +

+

00048 {
+00049         //      delete _Mem; // done by CTertureMem destructor
+00050         delete _Mat;
+00051         delete [] _OffS;
+00052 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + +
void NL3D::CNoise3d::flush  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 421 of file noise_3d.cpp. +

+References _IsDriverSupportCloudSinglePass, _Mat, _NbVertices, NL3D::IDriver::activeVertexBuffer(), flush2passes(), NL3D::IDriver::renderQuads(), NL3D::CMaterial::setColor(), and uint8. +

+Referenced by NL3D::CCloud::generate(). +

+

00422 {
+00423         if (!_IsDriverSupportCloudSinglePass)
+00424         {
+00425                 flush2passes ();
+00426                 return;
+00427         }
+00428         
+00429         _Mat->setColor(CRGBA(0,0,0,(uint8)(255*_Intensity)));
+00430         _Driver->activeVertexBuffer (_VertexBuffer);
+00431         _Driver->renderQuads (*_Mat, 0, _NbVertices/4);
+00432         _NbVertices = 0;
+00433 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CNoise3d::flush2passes  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 436 of file noise_3d.cpp. +

+References _Mat, _NbVertices, NL3D::IDriver::activeVertexBuffer(), and NL3D::IDriver::renderQuads(). +

+Referenced by flush(). +

+

00437 {
+00438         _Driver->activeVertexBuffer (_VertexBuffer);
+00439         _Driver->renderQuads (*_Mat, 0, _NbVertices/4);
+00440         _NbVertices = 0;
+00441 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CNoise3d::getDepth  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 457 of file noise_3d.cpp. +

+References uint32. +

+Referenced by NL3D::CCloud::generate(). +

+

00458 {
+00459         return _Depth;
+00460 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CNoise3d::getHeight  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 451 of file noise_3d.cpp. +

+References uint32. +

+Referenced by NL3D::CCloud::generate(). +

+

00452 {
+00453         return _Height;
+00454 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CNoise3d::getWidth  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 445 of file noise_3d.cpp. +

+References uint32. +

+Referenced by NL3D::CCloud::generate(). +

+

00446 {
+00447         return _Width;
+00448 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CNoise3d::init uint32  w = 64,
uint32  h = 64,
uint32  d = 32
+
+ + + + + +
+   + + +

+ +

+Definition at line 55 of file noise_3d.cpp. +

+References _IsDriverSupportCloudSinglePass, _Mat, _Mem, _NbSliceH, _NbSliceW, _OffS, _ScaleH, _ScaleW, NLMISC::getPowerOf2(), NL3D::CMaterial::initUnlit(), NLMISC::raiseToNextPowerOf2(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), NL3D::CMaterial::setColor(), NL3D::CMaterial::setShader(), NL3D::CMaterial::setTexture(), NL3D::CVertexBuffer::setVertexFormat(), NL3D::CMaterial::setZFunc(), NL3D::CMaterial::setZWrite(), NLMISC::CUV::U, uint32, uint8, NLMISC::CUV::V, and w. +

+Referenced by NL3D::CCloudScape::init(). +

+

00056 {
+00057         uint32 i;
+00058 
+00059         if (_Mem != NULL)
+00060                 return;
+00061 
+00062         w = raiseToNextPowerOf2 (w);
+00063         h = raiseToNextPowerOf2 (h);
+00064         d = raiseToNextPowerOf2 (d);
+00065         if (w > 64) w = 64;
+00066         if (h > 64) h = 64;
+00067         if (d > 64) d = 64;
+00068         if (w < 4) w = 4;
+00069         if (h < 4) h = 4;
+00070         if (d < 4) d = 4;
+00071         _Width = w;
+00072         _Height = h;
+00073         _Depth = d;
+00074         uint32 vdpo2 = getPowerOf2(_Depth);
+00075 
+00076         _NbSliceW = 1 << (vdpo2 / 2);
+00077         if ((vdpo2 & 1) != 0)
+00078                 _NbSliceH = 2 << (vdpo2 / 2);
+00079         else
+00080                 _NbSliceH = 1 << (vdpo2 / 2);
+00081 
+00082         _ScaleW = 1.0f / _NbSliceW;
+00083         _ScaleH = 1.0f / _NbSliceH;
+00084 
+00085         _Mem = new uint8[w*h*d];
+00086 
+00087         // Create initial noise
+00088         for (i = 0; i < (w*h*d); i++)
+00089                 _Mem[i] = (uint8)(256.0f*rand()/RAND_MAX);
+00090 
+00091         _OffS = new CUV [_Depth];
+00092         for (i = 0; i < _Depth; i++)
+00093         {
+00094                 _OffS[i].U = ((float)rand())/RAND_MAX;
+00095                 _OffS[i].V = ((float)rand())/RAND_MAX;
+00096         }
+00097 
+00098         _Tex = new CTextureMem (_Mem, _Width*_NbSliceW*_Height*_NbSliceH, true, false, _Width*_NbSliceW, _Height*_NbSliceH,
+00099                                                         CBitmap::Alpha);
+00100         _Tex->setWrapS(ITexture::Repeat);
+00101         _Tex->setWrapT(ITexture::Repeat);
+00102         _Tex->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
+00103         _Tex->touch();
+00104         _Tex->generate();
+00105 
+00106         if (_IsDriverSupportCloudSinglePass)
+00107         {
+00108                 _Mat = new CMaterial();
+00109                 _Mat->initUnlit();
+00110                 _Mat->setShader (CMaterial::Cloud);
+00111                 _Mat->setTexture (0, _Tex);
+00112                 _Mat->setTexture (1, _Tex);
+00113                 _Mat->setColor (CRGBA(255,255,255,255));
+00114                 _Mat->setBlend (true);
+00115                 _Mat->setBlendFunc(CMaterial::one, CMaterial::one);
+00116                 _Mat->setZFunc (CMaterial::always);
+00117                 _Mat->setZWrite (false);
+00118                 _VertexBuffer.setVertexFormat (CVertexBuffer::PositionFlag | CVertexBuffer::PrimaryColorFlag |
+00119                                                                                 CVertexBuffer::TexCoord0Flag | CVertexBuffer::TexCoord1Flag);
+00120         }
+00121         else
+00122         {
+00123                 _Mat = new CMaterial();
+00124                 _Mat->initUnlit();
+00125                 _Mat->setShader (CMaterial::Normal);
+00126                 _Mat->setTexture (0, _Tex);
+00127                 _Mat->setColor (CRGBA(255,255,255,255));
+00128                 _Mat->setBlend (true);
+00129                 _Mat->setBlendFunc(CMaterial::one, CMaterial::one);
+00130                 _Mat->setZFunc (CMaterial::always);
+00131                 _Mat->setZWrite (false);
+00132                 _VertexBuffer.setVertexFormat (CVertexBuffer::PositionFlag | CVertexBuffer::PrimaryColorFlag |
+00133                                                                                 CVertexBuffer::TexCoord0Flag);
+00134         }
+00135 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CNoise3d::render NLMISC::CQuadUV qc,
float  wpos,
float  intensity
+
+ + + + + +
+   + + +

+ +

+Definition at line 207 of file noise_3d.cpp. +

+References _IsDriverSupportCloudSinglePass, _NbSliceW, _NbVertices, _OffS, _ScaleH, _ScaleW, NL3D::CVertexBuffer::getColorPointer(), NL3D::CVertexBuffer::getNumVertices(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), render2passes(), NL3D::CVertexBuffer::setNumVertices(), NLMISC::CUV::U, uint32, uint8, NLMISC::CQuadUV::Uv0, NLMISC::CQuadUV::Uv1, NLMISC::CQuadUV::Uv2, NLMISC::CQuadUV::Uv3, NLMISC::CUV::V, NLMISC::CQuad::V0, NLMISC::CQuad::V1, NLMISC::CQuad::V2, and NLMISC::CQuad::V3. +

+

00208 {
+00209         // [ At0*wpos+At1*(1-wpos) ] * alpha
+00210 
+00211         if (!_IsDriverSupportCloudSinglePass)
+00212         {
+00213                 render2passes (qc, wpos, intensity);
+00214                 return;
+00215         }
+00216 
+00217         _Intensity = intensity;
+00218 
+00219         wpos = wpos - floorf (wpos);
+00220         uint32 nSlice1 = (uint32)(wpos * _Depth), nSlice2;
+00221         if (nSlice1 == (_Depth-1))
+00222                 nSlice2 = 0;
+00223         else
+00224                 nSlice2 = 1 + nSlice1;
+00225         // If wpos is just on slice1 alpha must be one
+00226         float alphaPos = 1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth));
+00227 
+00228         uint8 nAlphaPos = (uint8)(255*alphaPos);
+00229 
+00230         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00231 
+00232         if (_NbVertices == _VertexBuffer.getNumVertices())
+00233         {
+00234                 _VertexBuffer.setNumVertices (_NbVertices+4);
+00235         }
+00236 
+00237         CVector *pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(_NbVertices);
+00238         *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00239         *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00240         *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00241         *pVertices = qc.V3;
+00242 
+00243         CUV *pUV = (CUV*)_VertexBuffer.getTexCoordPointer (_NbVertices, 0);
+00244         *pUV = CUV(qc.Uv0.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv0.V*_ScaleH+_OffS[nSlice1].V); 
+00245         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00246         *pUV = CUV(qc.Uv1.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv1.V*_ScaleH+_OffS[nSlice1].V); 
+00247         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00248         *pUV = CUV(qc.Uv2.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv2.V*_ScaleH+_OffS[nSlice1].V); 
+00249         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00250         *pUV = CUV(qc.Uv3.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv3.V*_ScaleH+_OffS[nSlice1].V); 
+00251 
+00252         pUV = (CUV*)_VertexBuffer.getTexCoordPointer (_NbVertices, 1);
+00253         *pUV = CUV(qc.Uv0.U*_ScaleW+_OffS[nSlice2].U, qc.Uv0.V*_ScaleH+_OffS[nSlice2].V); 
+00254         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00255         *pUV = CUV(qc.Uv1.U*_ScaleW+_OffS[nSlice2].U, qc.Uv1.V*_ScaleH+_OffS[nSlice2].V); 
+00256         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00257         *pUV = CUV(qc.Uv2.U*_ScaleW+_OffS[nSlice2].U, qc.Uv2.V*_ScaleH+_OffS[nSlice2].V); 
+00258         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00259         *pUV = CUV(qc.Uv3.U*_ScaleW+_OffS[nSlice2].U, qc.Uv3.V*_ScaleH+_OffS[nSlice2].V); 
+00260 
+00261         uint8 *pColA = (uint8*)_VertexBuffer.getColorPointer(_NbVertices) + 3;
+00262         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00263         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00264         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00265         *pColA = nAlphaPos;
+00266 
+00267         _NbVertices += 4;
+00268 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CNoise3d::render2passes NLMISC::CQuadUV qc,
float  wpos,
float  intensity
+
+ + + + + +
+   + + +

+ +

+Definition at line 138 of file noise_3d.cpp. +

+References _NbVertices, _OffS, _ScaleH, _ScaleW, alpha, NL3D::CVertexBuffer::getColorPointer(), NL3D::CVertexBuffer::getNumVertices(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::CVertexBuffer::setNumVertices(), NLMISC::CUV::U, uint32, uint8, NLMISC::CQuadUV::Uv0, NLMISC::CQuadUV::Uv1, NLMISC::CQuadUV::Uv2, NLMISC::CQuadUV::Uv3, NLMISC::CUV::V, NLMISC::CQuad::V0, NLMISC::CQuad::V1, NLMISC::CQuad::V2, and NLMISC::CQuad::V3. +

+Referenced by render(). +

+

00139 {
+00140         // For the moment we do it in 2 passes : because wpos is a position between slice we have to do :
+00141         // [ At0*wpos+At1*(1-wpos) ] * alpha
+00142         // this is done like that :
+00143         // At0*[wpos*alpha] + At1*[(1-wpos)*alpha] 
+00144 
+00145         wpos = fmodf (wpos, 1.0f);
+00146         uint32 nSlice1 = (uint32)(wpos * _Depth), nSlice2;
+00147         if (nSlice1 == (_Depth-1))
+00148                 nSlice2 = 0;
+00149         else
+00150                 nSlice2 = 1 + nSlice1;
+00151         // If wpos is just on slice1 alpha must be one
+00152         float alphaPos = 1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth));
+00153 
+00154         if (_NbVertices == _VertexBuffer.getNumVertices())
+00155         {
+00156                 _VertexBuffer.setNumVertices(_NbVertices+8);
+00157         }
+00158 
+00159         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00160         CVector *pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(_NbVertices);
+00161         *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00162         *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00163         *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00164         *pVertices = qc.V3; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00165         *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00166         *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00167         *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00168         *pVertices = qc.V3;
+00169 
+00170         CUV *pUV = (CUV*)_VertexBuffer.getTexCoordPointer (_NbVertices, 0);
+00171         *pUV = CUV(qc.Uv0.U*_ScaleW+_OffS[nSlice1].U, qc.Uv0.V*_ScaleH+_OffS[nSlice1].V); 
+00172         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00173         *pUV = CUV(qc.Uv1.U*_ScaleW+_OffS[nSlice1].U, qc.Uv1.V*_ScaleH+_OffS[nSlice1].V); 
+00174         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00175         *pUV = CUV(qc.Uv2.U*_ScaleW+_OffS[nSlice1].U, qc.Uv2.V*_ScaleH+_OffS[nSlice1].V); 
+00176         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00177         *pUV = CUV(qc.Uv3.U*_ScaleW+_OffS[nSlice1].U, qc.Uv3.V*_ScaleH+_OffS[nSlice1].V); 
+00178         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00179 
+00180         *pUV = CUV(qc.Uv0.U*_ScaleW+_OffS[nSlice2].U, qc.Uv0.V*_ScaleH+_OffS[nSlice2].V); 
+00181         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00182         *pUV = CUV(qc.Uv1.U*_ScaleW+_OffS[nSlice2].U, qc.Uv1.V*_ScaleH+_OffS[nSlice2].V); 
+00183         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00184         *pUV = CUV(qc.Uv2.U*_ScaleW+_OffS[nSlice2].U, qc.Uv2.V*_ScaleH+_OffS[nSlice2].V); 
+00185         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00186         *pUV = CUV(qc.Uv3.U*_ScaleW+_OffS[nSlice2].U, qc.Uv3.V*_ScaleH+_OffS[nSlice2].V); 
+00187 
+00188         uint8 finalAlpha = (uint8)(255*alphaPos*alpha);
+00189 
+00190         uint8 *pColA = (uint8*)_VertexBuffer.getColorPointer(_NbVertices) + 3;
+00191         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00192         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00193         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00194         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00195 
+00196         finalAlpha = (uint8)(255*(1.0f-alphaPos)*alpha);
+00197 
+00198         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00199         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00200         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00201         *pColA = finalAlpha;
+00202 
+00203         _NbVertices += 8;
+00204 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CNoise3d::renderGrid uint32  nbw,
uint32  nbh,
uint32  w,
uint32  h,
float  UStart,
float  VStart,
float  WStart,
float  dU,
float  dV,
float  dW,
float  intensity
+
+ + + + + +
+   + + +

+ +

+Definition at line 271 of file noise_3d.cpp. +

+References _IsDriverSupportCloudSinglePass, _NbSliceH, _NbSliceW, _NbVertices, _OffS, NL3D::CVertexBuffer::getColorPointer(), NL3D::CVertexBuffer::getNumVertices(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), renderGrid2passes(), NL3D::CVertexBuffer::setNumVertices(), NLMISC::CUV::U, uint32, uint8, NLMISC::CUV::V, and w. +

+Referenced by NL3D::CCloud::generate(). +

+

00273 {
+00274 
+00275         if (!_IsDriverSupportCloudSinglePass)
+00276         {
+00277                 renderGrid2passes (nbw, nbh, w, h, UStart, VStart, WStart, dU, dV, dW, intensity);
+00278                 return;
+00279         }
+00280 
+00281         _Intensity = intensity;
+00282 
+00283         uint32 i, j, nSlice1, nSlice2;
+00284         float wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
+00285         CVector *pVertices;
+00286         CUV *pUV0, *pUV1;
+00287         uint8 *pColA, nAlphaPos;
+00288         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00289 
+00290         if (_VertexBuffer.getNumVertices() < nbw*nbh*4)
+00291         {
+00292                 _VertexBuffer.setNumVertices (nbw*nbh*4);
+00293         }
+00294 
+00295         dU = (UStart+dU) /_NbSliceW;
+00296         dV = (VStart+dV) /_NbSliceH;
+00297         UStart = UStart / _NbSliceW;
+00298         VStart = VStart / _NbSliceH;
+00299 
+00300         pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(0);
+00301         pUV0 = (CUV*)_VertexBuffer.getTexCoordPointer (0, 0);
+00302         pUV1 = (CUV*)_VertexBuffer.getTexCoordPointer (0, 1);
+00303         pColA = (uint8*)_VertexBuffer.getColorPointer(0) + 3;
+00304 
+00305         for (j = 0; j < nbh; ++j)
+00306         {
+00307                 for (i = 0; i < nbw; ++i)
+00308                 {
+00309                         wpos = (float)WStart+dW*(i+(float)j*nbw)*oneOverNbWNbH;
+00310                         wpos = wpos - floorf (wpos);
+00311                         nSlice1 = (uint32)(wpos * _Depth);
+00312                         if (nSlice1 == (_Depth-1))
+00313                                 nSlice2 = 0;
+00314                         else
+00315                                 nSlice2 = 1 + nSlice1;
+00316                         // If wpos is just on slice1 alpha must be one
+00317                         nAlphaPos = (uint8)( 255*(1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth))) );
+00318 
+00319                         *pVertices = CVector((float)i*w,         (float)j*h,     0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00320                         *pVertices = CVector((float)(i+1)*w, (float)j*h,         0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00321                         *pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00322                         *pVertices = CVector((float)i*w,         (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00323 
+00324                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00325                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00326                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00327                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00328 
+00329                         pUV1->U = UStart+_OffS[nSlice2].U;      pUV1->V = VStart+_OffS[nSlice2].V;      pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00330                         pUV1->U = dU+_OffS[nSlice2].U;          pUV1->V = VStart+_OffS[nSlice2].V;      pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00331                         pUV1->U = dU+_OffS[nSlice2].U;          pUV1->V = dV+_OffS[nSlice2].V;          pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00332                         pUV1->U = UStart+_OffS[nSlice2].U;      pUV1->V = dV+_OffS[nSlice2].V;          pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00333 
+00334                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00335                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00336                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00337                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00338                 }
+00339         }
+00340 
+00341         _NbVertices = nbw*nbh*4;
+00342 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CNoise3d::renderGrid2passes uint32  nbw,
uint32  nbh,
uint32  w,
uint32  h,
float  UStart,
float  VStart,
float  WStart,
float  dU,
float  dV,
float  dW,
float  intensity
+
+ + + + + +
+   + + +

+ +

+Definition at line 345 of file noise_3d.cpp. +

+References _NbSliceH, _NbSliceW, _NbVertices, _OffS, NL3D::CVertexBuffer::getColorPointer(), NL3D::CVertexBuffer::getNumVertices(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::CVertexBuffer::setNumVertices(), NLMISC::CUV::U, uint32, uint8, NLMISC::CUV::V, and w. +

+Referenced by renderGrid(). +

+

00347 {
+00348         uint32 i, j, nSlice1, nSlice2;
+00349         float wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
+00350         CVector *pVertices;
+00351         CUV *pUV0;
+00352         uint8 *pColA, nFinalAlpha;
+00353         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00354         
+00355         if (_VertexBuffer.getNumVertices() < 2*nbw*nbh*4)
+00356         {
+00357                 _VertexBuffer.setNumVertices (2*nbw*nbh*4);
+00358         }
+00359 
+00360         dU = (UStart+dU) /_NbSliceW;
+00361         dV = (VStart+dV) /_NbSliceH;
+00362         UStart = UStart / _NbSliceW;
+00363         VStart = VStart / _NbSliceH;
+00364 
+00365         pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(0);
+00366         pUV0 = (CUV*)_VertexBuffer.getTexCoordPointer (0, 0);
+00367         pColA = (uint8*)_VertexBuffer.getColorPointer(0) + 3;
+00368 
+00369         for (j = 0; j < nbh; ++j)
+00370         {
+00371                 for (i = 0; i < nbw; ++i)
+00372                 {
+00373                         wpos = (float)WStart+dW*(i+(float)j*nbw)*oneOverNbWNbH;
+00374                         wpos = fmodf (wpos, 1.0f);
+00375                         nSlice1 = (uint32)(wpos * _Depth);
+00376                         if (nSlice1 == (_Depth-1))
+00377                                 nSlice2 = 0;
+00378                         else
+00379                                 nSlice2 = 1 + nSlice1;
+00380                         // If wpos is just on slice1 alpha must be one
+00381                         float alphaPos = 1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth));
+00382 
+00383                         *pVertices = CVector((float)i*w,         (float)j*h,     0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00384                         *pVertices = CVector((float)(i+1)*w, (float)j*h,         0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00385                         *pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00386                         *pVertices = CVector((float)i*w,         (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00387                         *pVertices = CVector((float)i*w,         (float)j*h,     0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00388                         *pVertices = CVector((float)(i+1)*w, (float)j*h,         0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00389                         *pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00390                         *pVertices = CVector((float)i*w,         (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00391 
+00392                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00393                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00394                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00395                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00396 
+00397                         pUV0->U = UStart+_OffS[nSlice2].U;      pUV0->V = VStart+_OffS[nSlice2].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00398                         pUV0->U = dU+_OffS[nSlice2].U;          pUV0->V = VStart+_OffS[nSlice2].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00399                         pUV0->U = dU+_OffS[nSlice2].U;          pUV0->V = dV+_OffS[nSlice2].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00400                         pUV0->U = UStart+_OffS[nSlice2].U;      pUV0->V = dV+_OffS[nSlice2].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00401 
+00402                         nFinalAlpha = (uint8)(255*alphaPos*intensity);
+00403 
+00404                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00405                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00406                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00407                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00408 
+00409                         nFinalAlpha = (uint8)(255*(1.0f-alphaPos)*intensity);
+00410 
+00411                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00412                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00413                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00414                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00415                 }
+00416         }
+00417         _NbVertices = 2*4*nbw*nbh;
+00418 }
+
+


Field Documentation

+

+ + + + +
+ + +
uint32 NL3D::CNoise3d::_Depth [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 74 of file noise_3d.h.

+

+ + + + +
+ + +
NL3D::IDriver* NL3D::CNoise3d::_Driver [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 88 of file noise_3d.h.

+

+ + + + +
+ + +
uint32 NL3D::CNoise3d::_Height [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 74 of file noise_3d.h.

+

+ + + + +
+ + +
float NL3D::CNoise3d::_Intensity [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 80 of file noise_3d.h.

+

+ + + + +
+ + +
bool NL3D::CNoise3d::_IsDriverSupportCloudSinglePass [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 89 of file noise_3d.h. +

+Referenced by CNoise3d(), flush(), init(), render(), and renderGrid().

+

+ + + + +
+ + +
NL3D::CMaterial* NL3D::CNoise3d::_Mat [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 86 of file noise_3d.h. +

+Referenced by CNoise3d(), flush(), flush2passes(), init(), and ~CNoise3d().

+

+ + + + +
+ + +
uint8* NL3D::CNoise3d::_Mem [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 77 of file noise_3d.h. +

+Referenced by CNoise3d(), and init().

+

+ + + + +
+ + +
uint32 NL3D::CNoise3d::_NbSliceH [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 75 of file noise_3d.h. +

+Referenced by init(), renderGrid(), and renderGrid2passes().

+

+ + + + +
+ + +
uint32 NL3D::CNoise3d::_NbSliceW [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 75 of file noise_3d.h. +

+Referenced by init(), render(), renderGrid(), and renderGrid2passes().

+

+ + + + +
+ + +
uint32 NL3D::CNoise3d::_NbVertices [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 84 of file noise_3d.h. +

+Referenced by CNoise3d(), flush(), flush2passes(), render(), render2passes(), renderGrid(), and renderGrid2passes().

+

+ + + + +
+ + +
NLMISC::CUV* NL3D::CNoise3d::_OffS [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 81 of file noise_3d.h. +

+Referenced by CNoise3d(), init(), render(), render2passes(), renderGrid(), renderGrid2passes(), and ~CNoise3d().

+

+ + + + +
+ + +
float NL3D::CNoise3d::_ScaleH [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 82 of file noise_3d.h. +

+Referenced by init(), render(), and render2passes().

+

+ + + + +
+ + +
float NL3D::CNoise3d::_ScaleW [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 82 of file noise_3d.h. +

+Referenced by init(), render(), and render2passes().

+

+ + + + +
+ + +
NLMISC::CSmartPtr<NL3D::CTextureMem> NL3D::CNoise3d::_Tex [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 78 of file noise_3d.h.

+

+ + + + +
+ + +
NL3D::CVertexBuffer NL3D::CNoise3d::_VertexBuffer [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 85 of file noise_3d.h.

+

+ + + + +
+ + +
uint32 NL3D::CNoise3d::_Width [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 74 of file noise_3d.h.

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 06:57:20 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1