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

noise_3d.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 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 #include "std3d.h"
+00027 #include "noise_3d.h"
+00028 #include "3d/driver.h"
+00029 
+00030 using namespace NLMISC;
+00031 
+00032 namespace NL3D
+00033 {
+00034 
+00035 // ------------------------------------------------------------------------------------------------
+00036 CNoise3d::CNoise3d (IDriver *pDriver)
+00037 {
+00038         _Mat = NULL;
+00039         _Driver = pDriver;
+00040         _NbVertices = 0;
+00041         _IsDriverSupportEnvCombine4 = true;
+00042 }
+00043 
+00044 // ------------------------------------------------------------------------------------------------
+00045 CNoise3d::~CNoise3d ()
+00046 {
+00047         //      delete _Mem; // done by CTertureMem destructor
+00048         delete _Mat;
+00049         delete [] _OffS;
+00050 }
+00051 
+00052 // ------------------------------------------------------------------------------------------------
+00053 void CNoise3d::init (uint32 w, uint32 h, uint32 d)
+00054 {
+00055         uint32 i;
+00056 
+00057         w = raiseToNextPowerOf2 (w);
+00058         h = raiseToNextPowerOf2 (h);
+00059         d = raiseToNextPowerOf2 (d);
+00060         if (w > 64) w = 64;
+00061         if (h > 64) h = 64;
+00062         if (d > 64) d = 64;
+00063         if (w < 4) w = 4;
+00064         if (h < 4) h = 4;
+00065         if (d < 4) d = 4;
+00066         _Width = w;
+00067         _Height = h;
+00068         _Depth = d;
+00069         uint32 vdpo2 = getPowerOf2(_Depth);
+00070 
+00071         _NbSliceW = 1 << (vdpo2 / 2);
+00072         if ((vdpo2 & 1) != 0)
+00073                 _NbSliceH = 2 << (vdpo2 / 2);
+00074         else
+00075                 _NbSliceH = 1 << (vdpo2 / 2);
+00076 
+00077         _ScaleW = 1.0f / _NbSliceW;
+00078         _ScaleH = 1.0f / _NbSliceH;
+00079 
+00080         _Mem = new uint8[w*h*d];
+00081 
+00082         // Create initial noise
+00083         for (i = 0; i < (w*h*d); i++)
+00084                 _Mem[i] = (uint8)(256.0f*rand()/RAND_MAX);
+00085 
+00086         _OffS = new CUV [_Depth];
+00087         for (i = 0; i < _Depth; i++)
+00088         {
+00089                 _OffS[i].U = ((float)rand())/RAND_MAX;
+00090                 _OffS[i].V = ((float)rand())/RAND_MAX;
+00091         }
+00092 
+00093         _Tex = new CTextureMem (_Mem, _Width*_NbSliceW*_Height*_NbSliceH, true, false, _Width*_NbSliceW, _Height*_NbSliceH,
+00094                                                         CBitmap::Alpha);
+00095         _Tex->setWrapS(ITexture::Repeat);
+00096         _Tex->setWrapT(ITexture::Repeat);
+00097         _Tex->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
+00098         _Tex->touch();
+00099         _Tex->generate();
+00100 
+00101         if (_IsDriverSupportEnvCombine4)
+00102         {
+00103                 _Mat = new CMaterial();
+00104                 _Mat->initUnlit();
+00105                 _Mat->setShader (CMaterial::Cloud);
+00106                 _Mat->setTexture (0, _Tex);
+00107                 _Mat->setTexture (1, _Tex);
+00108                 _Mat->setColor (CRGBA(255,255,255,255));
+00109                 _Mat->setBlend (true);
+00110                 _Mat->setBlendFunc(CMaterial::one, CMaterial::one);
+00111                 _Mat->setZFunc (CMaterial::always);
+00112                 _Mat->setZWrite (false);
+00113                 _VertexBuffer.setVertexFormat (CVertexBuffer::PositionFlag | CVertexBuffer::PrimaryColorFlag |
+00114                                                                                 CVertexBuffer::TexCoord0Flag | CVertexBuffer::TexCoord1Flag);
+00115         }
+00116         else
+00117         {
+00118                 _Mat = new CMaterial();
+00119                 _Mat->initUnlit();
+00120                 _Mat->setShader (CMaterial::Normal);
+00121                 _Mat->setTexture (0, _Tex);
+00122                 _Mat->setColor (CRGBA(255,255,255,255));
+00123                 _Mat->setBlend (true);
+00124                 _Mat->setBlendFunc(CMaterial::one, CMaterial::one);
+00125                 _Mat->setZFunc (CMaterial::always);
+00126                 _Mat->setZWrite (false);
+00127                 _VertexBuffer.setVertexFormat (CVertexBuffer::PositionFlag | CVertexBuffer::PrimaryColorFlag |
+00128                                                                                 CVertexBuffer::TexCoord0Flag);
+00129         }
+00130 }
+00131 
+00132 // ------------------------------------------------------------------------------------------------
+00133 void CNoise3d::render2passes (CQuadUV &qc, float wpos, float alpha)
+00134 {
+00135         // For the moment we do it in 2 passes : because wpos is a position between slice we have to do :
+00136         // [ At0*wpos+At1*(1-wpos) ] * alpha
+00137         // this is done like that :
+00138         // At0*[wpos*alpha] + At1*[(1-wpos)*alpha] 
+00139 
+00140         wpos = fmodf (wpos, 1.0f);
+00141         uint32 nSlice1 = (uint32)(wpos * _Depth), nSlice2;
+00142         if (nSlice1 == (_Depth-1))
+00143                 nSlice2 = 0;
+00144         else
+00145                 nSlice2 = 1 + nSlice1;
+00146         // If wpos is just on slice1 alpha must be one
+00147         float alphaPos = 1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth));
+00148 
+00149         if (_NbVertices == _VertexBuffer.getNumVertices())
+00150         {
+00151                 _VertexBuffer.setNumVertices(_NbVertices+8);
+00152         }
+00153 
+00154         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00155         CVector *pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(_NbVertices);
+00156         *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00157         *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00158         *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00159         *pVertices = qc.V3; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00160         *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00161         *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00162         *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00163         *pVertices = qc.V3;
+00164 
+00165         CUV *pUV = (CUV*)_VertexBuffer.getTexCoordPointer (_NbVertices, 0);
+00166         *pUV = CUV(qc.Uv0.U*_ScaleW+_OffS[nSlice1].U, qc.Uv0.V*_ScaleH+_OffS[nSlice1].V); 
+00167         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00168         *pUV = CUV(qc.Uv1.U*_ScaleW+_OffS[nSlice1].U, qc.Uv1.V*_ScaleH+_OffS[nSlice1].V); 
+00169         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00170         *pUV = CUV(qc.Uv2.U*_ScaleW+_OffS[nSlice1].U, qc.Uv2.V*_ScaleH+_OffS[nSlice1].V); 
+00171         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00172         *pUV = CUV(qc.Uv3.U*_ScaleW+_OffS[nSlice1].U, qc.Uv3.V*_ScaleH+_OffS[nSlice1].V); 
+00173         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00174 
+00175         *pUV = CUV(qc.Uv0.U*_ScaleW+_OffS[nSlice2].U, qc.Uv0.V*_ScaleH+_OffS[nSlice2].V); 
+00176         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00177         *pUV = CUV(qc.Uv1.U*_ScaleW+_OffS[nSlice2].U, qc.Uv1.V*_ScaleH+_OffS[nSlice2].V); 
+00178         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00179         *pUV = CUV(qc.Uv2.U*_ScaleW+_OffS[nSlice2].U, qc.Uv2.V*_ScaleH+_OffS[nSlice2].V); 
+00180         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00181         *pUV = CUV(qc.Uv3.U*_ScaleW+_OffS[nSlice2].U, qc.Uv3.V*_ScaleH+_OffS[nSlice2].V); 
+00182 
+00183         uint8 finalAlpha = (uint8)(255*alphaPos*alpha);
+00184 
+00185         uint8 *pColA = (uint8*)_VertexBuffer.getColorPointer(_NbVertices) + 3;
+00186         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00187         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00188         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00189         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00190 
+00191         finalAlpha = (uint8)(255*(1.0f-alphaPos)*alpha);
+00192 
+00193         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00194         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00195         *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00196         *pColA = finalAlpha;
+00197 
+00198         _NbVertices += 8;
+00199 }
+00200 
+00201 // ------------------------------------------------------------------------------------------------
+00202 void CNoise3d::render (CQuadUV &qc, float wpos, float intensity)
+00203 {
+00204         // [ At0*wpos+At1*(1-wpos) ] * alpha
+00205 
+00206         if (!_IsDriverSupportEnvCombine4)
+00207         {
+00208                 render2passes (qc, wpos, intensity);
+00209                 return;
+00210         }
+00211 
+00212         _Intensity = intensity;
+00213 
+00214         wpos = wpos - floorf (wpos);
+00215         uint32 nSlice1 = (uint32)(wpos * _Depth), nSlice2;
+00216         if (nSlice1 == (_Depth-1))
+00217                 nSlice2 = 0;
+00218         else
+00219                 nSlice2 = 1 + nSlice1;
+00220         // If wpos is just on slice1 alpha must be one
+00221         float alphaPos = 1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth));
+00222 
+00223         uint8 nAlphaPos = (uint8)(255*alphaPos);
+00224 
+00225         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00226 
+00227         if (_NbVertices == _VertexBuffer.getNumVertices())
+00228         {
+00229                 _VertexBuffer.setNumVertices (_NbVertices+4);
+00230         }
+00231 
+00232         CVector *pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(_NbVertices);
+00233         *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00234         *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00235         *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00236         *pVertices = qc.V3;
+00237 
+00238         CUV *pUV = (CUV*)_VertexBuffer.getTexCoordPointer (_NbVertices, 0);
+00239         *pUV = CUV(qc.Uv0.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv0.V*_ScaleH+_OffS[nSlice1].V); 
+00240         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00241         *pUV = CUV(qc.Uv1.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv1.V*_ScaleH+_OffS[nSlice1].V); 
+00242         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00243         *pUV = CUV(qc.Uv2.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv2.V*_ScaleH+_OffS[nSlice1].V); 
+00244         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00245         *pUV = CUV(qc.Uv3.U/_NbSliceW+_OffS[nSlice1].U, qc.Uv3.V*_ScaleH+_OffS[nSlice1].V); 
+00246 
+00247         pUV = (CUV*)_VertexBuffer.getTexCoordPointer (_NbVertices, 1);
+00248         *pUV = CUV(qc.Uv0.U*_ScaleW+_OffS[nSlice2].U, qc.Uv0.V*_ScaleH+_OffS[nSlice2].V); 
+00249         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00250         *pUV = CUV(qc.Uv1.U*_ScaleW+_OffS[nSlice2].U, qc.Uv1.V*_ScaleH+_OffS[nSlice2].V); 
+00251         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00252         *pUV = CUV(qc.Uv2.U*_ScaleW+_OffS[nSlice2].U, qc.Uv2.V*_ScaleH+_OffS[nSlice2].V); 
+00253         pUV = (CUV*)( ((uint8*)pUV) + nVSize );
+00254         *pUV = CUV(qc.Uv3.U*_ScaleW+_OffS[nSlice2].U, qc.Uv3.V*_ScaleH+_OffS[nSlice2].V); 
+00255 
+00256         uint8 *pColA = (uint8*)_VertexBuffer.getColorPointer(_NbVertices) + 3;
+00257         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00258         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00259         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00260         *pColA = nAlphaPos;
+00261 
+00262         _NbVertices += 4;
+00263 }
+00264 
+00265 // ------------------------------------------------------------------------------------------------
+00266 void CNoise3d::renderGrid (uint32 nbw, uint32 nbh, uint32 w, uint32 h, 
+00267                                         float UStart, float VStart, float WStart, float dU, float dV, float dW, float intensity)
+00268 {
+00269 
+00270         if (!_IsDriverSupportEnvCombine4)
+00271         {
+00272                 renderGrid2passes (nbw, nbh, w, h, UStart, VStart, WStart, dU, dV, dW, intensity);
+00273                 return;
+00274         }
+00275 
+00276         _Intensity = intensity;
+00277 
+00278         uint32 i, j, nSlice1, nSlice2;
+00279         float wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
+00280         CVector *pVertices;
+00281         CUV *pUV0, *pUV1;
+00282         uint8 *pColA, nAlphaPos;
+00283         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00284 
+00285         if (_VertexBuffer.getNumVertices() < nbw*nbh*4)
+00286         {
+00287                 _VertexBuffer.setNumVertices (nbw*nbh*4);
+00288         }
+00289 
+00290         dU = (UStart+dU) /_NbSliceW;
+00291         dV = (VStart+dV) /_NbSliceH;
+00292         UStart = UStart / _NbSliceW;
+00293         VStart = VStart / _NbSliceH;
+00294 
+00295         pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(0);
+00296         pUV0 = (CUV*)_VertexBuffer.getTexCoordPointer (0, 0);
+00297         pUV1 = (CUV*)_VertexBuffer.getTexCoordPointer (0, 1);
+00298         pColA = (uint8*)_VertexBuffer.getColorPointer(0) + 3;
+00299 
+00300         for (j = 0; j < nbh; ++j)
+00301         {
+00302                 for (i = 0; i < nbw; ++i)
+00303                 {
+00304                         wpos = (float)WStart+dW*(i+(float)j*nbw)*oneOverNbWNbH;
+00305                         wpos = wpos - floorf (wpos);
+00306                         nSlice1 = (uint32)(wpos * _Depth);
+00307                         if (nSlice1 == (_Depth-1))
+00308                                 nSlice2 = 0;
+00309                         else
+00310                                 nSlice2 = 1 + nSlice1;
+00311                         // If wpos is just on slice1 alpha must be one
+00312                         nAlphaPos = (uint8)( 255*(1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth))) );
+00313 
+00314                         *pVertices = CVector((float)i*w,         (float)j*h,     0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00315                         *pVertices = CVector((float)(i+1)*w, (float)j*h,         0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00316                         *pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00317                         *pVertices = CVector((float)i*w,         (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00318 
+00319                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00320                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00321                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00322                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00323 
+00324                         pUV1->U = UStart+_OffS[nSlice2].U;      pUV1->V = VStart+_OffS[nSlice2].V;      pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00325                         pUV1->U = dU+_OffS[nSlice2].U;          pUV1->V = VStart+_OffS[nSlice2].V;      pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00326                         pUV1->U = dU+_OffS[nSlice2].U;          pUV1->V = dV+_OffS[nSlice2].V;          pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00327                         pUV1->U = UStart+_OffS[nSlice2].U;      pUV1->V = dV+_OffS[nSlice2].V;          pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
+00328 
+00329                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00330                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00331                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00332                         *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
+00333                 }
+00334         }
+00335 
+00336         _NbVertices = nbw*nbh*4;
+00337 }
+00338 
+00339 // ------------------------------------------------------------------------------------------------
+00340 void CNoise3d::renderGrid2passes (uint32 nbw, uint32 nbh, uint32 w, uint32 h, 
+00341                                         float UStart, float VStart, float WStart, float dU, float dV, float dW, float intensity)
+00342 {
+00343         uint32 i, j, nSlice1, nSlice2;
+00344         float wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
+00345         CVector *pVertices;
+00346         CUV *pUV0;
+00347         uint8 *pColA, nFinalAlpha;
+00348         uint32 nVSize = _VertexBuffer.getVertexSize ();
+00349         
+00350         if (_VertexBuffer.getNumVertices() < 2*nbw*nbh*4)
+00351         {
+00352                 _VertexBuffer.setNumVertices (2*nbw*nbh*4);
+00353         }
+00354 
+00355         dU = (UStart+dU) /_NbSliceW;
+00356         dV = (VStart+dV) /_NbSliceH;
+00357         UStart = UStart / _NbSliceW;
+00358         VStart = VStart / _NbSliceH;
+00359 
+00360         pVertices = (CVector*)_VertexBuffer.getVertexCoordPointer(0);
+00361         pUV0 = (CUV*)_VertexBuffer.getTexCoordPointer (0, 0);
+00362         pColA = (uint8*)_VertexBuffer.getColorPointer(0) + 3;
+00363 
+00364         for (j = 0; j < nbh; ++j)
+00365         {
+00366                 for (i = 0; i < nbw; ++i)
+00367                 {
+00368                         wpos = (float)WStart+dW*(i+(float)j*nbw)*oneOverNbWNbH;
+00369                         wpos = fmodf (wpos, 1.0f);
+00370                         nSlice1 = (uint32)(wpos * _Depth);
+00371                         if (nSlice1 == (_Depth-1))
+00372                                 nSlice2 = 0;
+00373                         else
+00374                                 nSlice2 = 1 + nSlice1;
+00375                         // If wpos is just on slice1 alpha must be one
+00376                         float alphaPos = 1.0f - _Depth*(wpos - (((float)nSlice1) / _Depth));
+00377 
+00378                         *pVertices = CVector((float)i*w,         (float)j*h,     0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00379                         *pVertices = CVector((float)(i+1)*w, (float)j*h,         0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00380                         *pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00381                         *pVertices = CVector((float)i*w,         (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00382                         *pVertices = CVector((float)i*w,         (float)j*h,     0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00383                         *pVertices = CVector((float)(i+1)*w, (float)j*h,         0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00384                         *pVertices = CVector((float)(i+1)*w, (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00385                         *pVertices = CVector((float)i*w,         (float)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
+00386 
+00387                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00388                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = VStart+_OffS[nSlice1].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00389                         pUV0->U = dU+_OffS[nSlice1].U;          pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00390                         pUV0->U = UStart+_OffS[nSlice1].U;      pUV0->V = dV+_OffS[nSlice1].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00391 
+00392                         pUV0->U = UStart+_OffS[nSlice2].U;      pUV0->V = VStart+_OffS[nSlice2].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00393                         pUV0->U = dU+_OffS[nSlice2].U;          pUV0->V = VStart+_OffS[nSlice2].V;      pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00394                         pUV0->U = dU+_OffS[nSlice2].U;          pUV0->V = dV+_OffS[nSlice2].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00395                         pUV0->U = UStart+_OffS[nSlice2].U;      pUV0->V = dV+_OffS[nSlice2].V;          pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
+00396 
+00397                         nFinalAlpha = (uint8)(255*alphaPos*intensity);
+00398 
+00399                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00400                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00401                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00402                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00403 
+00404                         nFinalAlpha = (uint8)(255*(1.0f-alphaPos)*intensity);
+00405 
+00406                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00407                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00408                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00409                         *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
+00410                 }
+00411         }
+00412         _NbVertices = 2*4*nbw*nbh;
+00413 }
+00414 
+00415 // ------------------------------------------------------------------------------------------------
+00416 void CNoise3d::flush ()
+00417 {
+00418         if (!_IsDriverSupportEnvCombine4)
+00419         {
+00420                 flush2passes ();
+00421                 return;
+00422         }
+00423         
+00424         _Mat->setColor(CRGBA(0,0,0,(uint8)(255*_Intensity)));
+00425         _Driver->activeVertexBuffer (_VertexBuffer);
+00426         _Driver->renderQuads (*_Mat, 0, _NbVertices/4);
+00427         _NbVertices = 0;
+00428 }
+00429 
+00430 // ------------------------------------------------------------------------------------------------
+00431 void CNoise3d::flush2passes ()
+00432 {
+00433         _Driver->activeVertexBuffer (_VertexBuffer);
+00434         _Driver->renderQuads (*_Mat, 0, _NbVertices/4);
+00435         _NbVertices = 0;
+00436 }
+00437 
+00438 // Accessors
+00439 // ------------------------------------------------------------------------------------------------
+00440 uint32 CNoise3d::getWidth ()
+00441 {
+00442         return _Width;
+00443 }
+00444 
+00445 // ------------------------------------------------------------------------------------------------
+00446 uint32 CNoise3d::getHeight ()
+00447 {
+00448         return _Height;
+00449 }
+00450 
+00451 // ------------------------------------------------------------------------------------------------
+00452 uint32 CNoise3d::getDepth ()
+00453 {
+00454         return _Depth;
+00455 }
+00456 
+00457 } // namespace NL3D
+00458 
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1