NL3D::CCloud Class Reference

#include <cloud.h>


Public Member Functions

void anim (double dt, double dt2)
 CCloud (CCloudScape *pCloudScape)
void disp ()
void dispBill (NL3D::CCamera *pViewer)
void dispXYZ (NL3D::CMaterial *pMat=NULL)
void genBill (NL3D::CCamera *pViewer, uint32 nBillSize=128)
void generate (CNoise3d &noise)
uint32 getBillSize ()
float getLastX ()
uint32 getMemSize ()
float getSizeX ()
float getSizeY ()
float getSizeZ ()
float getX ()
float getY ()
float getZ ()
void init (uint32 nVoxelW, uint32 nVoxelH, uint32 nVoxelD, float rBaseFreq, uint32 nNbOctave)
void light ()
void reset (NL3D::CCamera *pViewer)
void setLooping ()
void setSizeX (float x)
void setSizeY (float y)
void setSizeZ (float z)
void setTex3DTemp (SCloudTexture3D &t)
void setTexClamp (SCloudTextureClamp &t)
void setX (float x)
void setY (float y)
void setZ (float z)
 ~CCloud ()

Data Fields

NLMISC::CRGBA CloudAmbient
NLMISC::CRGBA CloudDiffuse
uint8 CloudDistAtt
uint8 CloudPower
double FuturTime
uint8 LastCloudPower
double Time

Private Member Functions

void calcBill (const NLMISC::CVector &Viewer, const NLMISC::CVector &Center, const NLMISC::CVector &Size, NLMISC::CVector &I, NLMISC::CVector &J, NLMISC::CVector &K, float &Left, float &Right, float &Top, float &Bottom, float &Near, float &Far)
void setMode2D ()

Private Attributes

float _BaseFreq
NLMISC::CVector _BillCenter
NLMISC::CVector _BillOldCenter
uint32 _BillSize
NLMISC::CVector _BillViewer
CCloudScape_CloudScape
SCloudTextureClamp_CloudTexClamp
SCloudTexture3D_CloudTexTmp
uint32 _Depth
NL3D::IDriver_Driver
uint32 _Height
float _LastX
uint8_MemBill
uint8_MemOldBill
uint32 _NbH
uint32 _NbOctave
uint32 _NbW
uint32 _OldBillSize
NLMISC::CVector _Pos
NLMISC::CVector _Size
NLMISC::CSmartPtr< NL3D::CTextureMem_TexBill
NLMISC::CSmartPtr< NL3D::CTextureMem_TexOldBill
double * _UStart
double * _VStart
uint8 _WaitState
uint32 _Width
double * _WStart


Constructor & Destructor Documentation

NL3D::CCloud::CCloud CCloudScape pCloudScape  ) 
 

Definition at line 41 of file cloud.cpp.

References _BillSize, _CloudScape, NL3D::CCloudScape::_Driver, _Driver, _OldBillSize, _UStart, _VStart, _WaitState, _WStart, CloudAmbient, CloudDiffuse, CloudDistAtt, CloudPower, and LastCloudPower.

00042 {
00043         _CloudScape = pCloudScape;
00044         _Driver = _CloudScape->_Driver;
00045         CloudPower = 255; // Max Power
00046         LastCloudPower = 255;
00047         CloudDistAtt = 0;
00048         CloudDiffuse = CRGBA(255,255,255,255);
00049         CloudAmbient = CRGBA(120,140,160,255);
00050         _WaitState = 0;
00051         _BillSize = 0;
00052         _OldBillSize = 0;
00053         _UStart = _VStart = _WStart = NULL;
00054 }

NL3D::CCloud::~CCloud  ) 
 

Definition at line 57 of file cloud.cpp.

References _UStart, _VStart, and _WStart.

00058 {
00059         delete _UStart;
00060         delete _VStart;
00061         delete _WStart;
00062 }


Member Function Documentation

void NL3D::CCloud::anim double  dt,
double  dt2
 

Definition at line 315 of file cloud.cpp.

References _NbOctave, _UStart, _VStart, _WStart, and uint32.

Referenced by NL3D::CCloudScape::makeHalfCloud().

00316 {
00317         for (uint32 nOct = 0; nOct < _NbOctave; ++nOct)
00318         {
00319                 _UStart[nOct] += dt*(1<<nOct) / 5000.0;
00320                 _VStart[nOct] += dt*(1<<nOct) / 5000.0;
00321                 _WStart[nOct] += dt*(1<<nOct) / 5000.0;
00322         }
00323         //_Pos.x += dt2;
00324         //Time += dt2;
00325 }

void NL3D::CCloud::calcBill const NLMISC::CVector Viewer,
const NLMISC::CVector Center,
const NLMISC::CVector Size,
NLMISC::CVector I,
NLMISC::CVector J,
NLMISC::CVector K,
float &  Left,
float &  Right,
float &  Top,
float &  Bottom,
float &  Near,
float &  Far
[private]
 

Definition at line 437 of file cloud.cpp.

References NLMISC::CMatrix::identity(), NLMISC::CMatrix::invert(), NLMISC::CMatrix::mulPoint(), NLMISC::CVector::norm(), NLMISC::CVector::normalize(), NLMISC::CVector::set(), NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), uint32, v, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by dispBill(), genBill(), and reset().

00439 {
00440         CVector ViewDir = Center - Viewer;
00441         float ViewDist = ViewDir.norm();
00442         ViewDir.normalize();
00443 
00444         Left = 1000.0f;
00445         Right = -1000.0f;
00446         Top = -1000.0f;
00447         Bottom = 1000.0f;
00448         Near = 1000.0f;
00449         Far = -1000.0f;
00450 
00451         if (fabsf(Center.y-Viewer.y) > fabsf(Center.z-Viewer.z))
00452         {
00453                 K.set(0, 0, 1);
00454                 J= ViewDir;
00455                 I= J^K;
00456                 K= I^J;
00457         }
00458         else
00459         {
00460                 K.set(0, 1, 0);
00461                 J= ViewDir;
00462                 I= J^K;
00463                 K= I^J;
00464         }
00465         I.normalize();
00466         J.normalize();
00467         K.normalize();
00468         
00469         CMatrix mat;
00470         mat.identity();
00471         mat.setRot(I,J,K, true);
00472         mat.setPos(CVector(Viewer.x, Viewer.y, Viewer.z));
00473         mat.invert();
00474 
00475         uint32 i, j, k;
00476         for (i = 0; i < 2; ++i)
00477         for (j = 0; j < 2; ++j)
00478         for (k = 0; k < 2; ++k)
00479         {
00480                 CVector v;
00481                 if (i == 0) v.x = Center.x-Size.x/2; else v.x = Center.x+Size.x/2;
00482                 if (j == 0) v.y = Center.y-Size.y/2; else v.y = Center.y+Size.y/2;
00483                 if (k == 0) v.z = Center.z-Size.z/2; else v.z = Center.z+Size.z/2;
00484                 v = mat.mulPoint(v);
00485                 if (v.y < Near)         Near = v.y;
00486                 if (v.y > Far)          Far = v.y;
00487         }
00488 
00489         for (i = 0; i < 2; ++i)
00490         for (j = 0; j < 2; ++j)
00491         for (k = 0; k < 2; ++k)
00492         {
00493                 CVector v;
00494                 if (i == 0) v.x = Center.x-Size.x/2; else v.x = Center.x+Size.x/2;
00495                 if (j == 0) v.y = Center.y-Size.y/2; else v.y = Center.y+Size.y/2;
00496                 if (k == 0) v.z = Center.z-Size.z/2; else v.z = Center.z+Size.z/2;
00497                 v = mat.mulPoint(v);
00498                 v.x = v.x / (v.y/Near);
00499                 v.z = v.z / (v.y/Near);
00500                 if (v.x < Left)         Left = v.x;
00501                 if (v.x > Right)        Right = v.x;
00502                 if (v.z < Bottom)       Bottom = v.z;
00503                 if (v.z > Top)          Top = v.z;
00504         }
00505 }

void NL3D::CCloud::disp  ) 
 

Definition at line 328 of file cloud.cpp.

References _CloudScape, _CloudTexTmp, _Driver, _Height, _NbH, _NbW, NL3D::CCloudScape::_VertexBuffer, _Width, NL3D::IDriver::activeVertexBuffer(), NLMISC::CMatrix::identity(), NL3D::CMaterial::initUnlit(), NL3D::IDriver::renderQuads(), s, NL3D::CMaterial::setBlend(), NL3D::CMaterial::setDoubleSided(), NL3D::IDriver::setFrustum(), NLMISC::CMatrix::setRot(), NL3D::CVertexBuffer::setTexCoord(), NL3D::CMaterial::setTexture(), NL3D::IDriver::setupModelMatrix(), NL3D::IDriver::setupScissor(), NL3D::IDriver::setupViewMatrix(), NL3D::IDriver::setupViewport(), NL3D::CVertexBuffer::setVertexCoord(), NL3D::CMaterial::setZFunc(), NL3D::CMaterial::setZWrite(), NL3D::SCloudTexture3D::Tex, NL3D::CMaterial::texEnvArg0RGB(), NL3D::CMaterial::texEnvOpRGB(), uint32, NLMISC::CQuadUV::Uv0, NLMISC::CQuadUV::Uv1, NLMISC::CQuadUV::Uv2, NLMISC::CQuadUV::Uv3, NLMISC::CQuad::V0, NLMISC::CQuad::V1, NLMISC::CQuad::V2, NLMISC::CQuad::V3, and w.

00329 {
00330         CQuadUV qc;
00331         qc.Uv0 = CUV(0.0f, 0.0f);
00332         qc.Uv1 = CUV(1.0f, 0.0f);
00333         qc.Uv2 = CUV(1.0f, 1.0f);
00334         qc.Uv3 = CUV(0.0f, 1.0f);
00335 
00337         CScissor s;
00338         s.initFullScreen();
00339         _Driver->setupScissor (s);
00340         _Driver->setupViewport (CViewport());
00341         _Driver->setFrustum (0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, false);
00342         CVector         I(1,0,0);
00343         CVector         J(0,0,1);
00344         CVector         K(0,-1,0);
00345         CMatrix ViewMatrix;
00346         ViewMatrix.identity();
00347         ViewMatrix.setRot(I,J,K, true);
00348         _Driver->setupViewMatrix(ViewMatrix);
00349         _Driver->setupModelMatrix(CMatrix::Identity);
00351 
00352         uint32 w = _NbW*_Width;
00353         uint32 h = _NbH*_Height;
00354         uint32 i = 0;
00355         qc.V0 = CVector(0.0f/800.0f,    0.0f/600.0f,    0.0f);
00356         qc.V1 = CVector(w/800.0f,               0.0f/600.0f,    0.0f);
00357         qc.V2 = CVector(w/800.0f,               h/600.0f,               0.0f);
00358         qc.V3 = CVector(0.0f/800.0f,    h/600.0f,               0.0f);
00359         static CMaterial *dispMat = NULL;
00360         if (dispMat == NULL)
00361         {
00362                 dispMat = new CMaterial;
00363                 dispMat->initUnlit();
00364                 dispMat->setTexture(0, _CloudTexTmp->Tex);
00365                 dispMat->texEnvOpRGB(0, CMaterial::Replace);
00366                 //dispMat->texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcAlpha);
00367                 dispMat->texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
00368                 dispMat->setZFunc(CMaterial::always);
00369                 dispMat->setZWrite(false);
00370                 dispMat->setDoubleSided(true);
00371                 dispMat->setBlend (false);
00372         }
00373 
00374         CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
00375         rVB.setVertexCoord (0, qc.V0);
00376         rVB.setVertexCoord (1, qc.V1);
00377         rVB.setVertexCoord (2, qc.V2);
00378         rVB.setVertexCoord (3, qc.V3);
00379         rVB.setTexCoord (0, 0, qc.Uv0);
00380         rVB.setTexCoord (1, 0, qc.Uv1);
00381         rVB.setTexCoord (2, 0, qc.Uv2);
00382         rVB.setTexCoord (3, 0, qc.Uv3);
00383         _Driver->activeVertexBuffer (rVB);
00384         _Driver->renderQuads (*dispMat, 0, 1);
00385 }

void NL3D::CCloud::dispBill NL3D::CCamera pViewer  ) 
 

Definition at line 606 of file cloud.cpp.

References _BillCenter, _BillOldCenter, _BillViewer, _CloudScape, _Driver, NL3D::CCloudScape::_MatBill, _MemBill, _MemOldBill, _Pos, _Size, _TexBill, _TexOldBill, NL3D::CCloudScape::_VertexBuffer, _WaitState, NL3D::IDriver::activeVertexBuffer(), calcBill(), FuturTime, NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::CCloudScape::isDebugQuadEnabled(), NL3D::IDriver::renderQuads(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setColor(), NL3D::CMaterial::setDoubleSided(), NL3D::IDriver::setPolygonMode(), NL3D::CMaterial::setTexture(), Time, 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, NLMISC::CQuad::V3, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NL3D::CCloudScape::render().

00607 {
00608 //      CMatrix CamMat = pCam->getMatrix();
00609 //      CVector Viewer = CamMat.getPos();
00610         CVector Viewer = CVector (0,0,0);
00611         CVector Center = CVector (_Pos.x+_Size.x/2, _Pos.y+_Size.y/2, _Pos.z+_Size.z/2);
00612         CVector Size = _Size;
00613 
00614         // Prepare vertices.
00615         CQuadUV qc;
00616         
00617         CVector I, J, K;
00618         float Left, Right, Top, Bottom, Near, Far;
00619 
00620         if ((_MemBill == NULL) || (_MemOldBill == NULL))
00621                 return;
00622 
00623         if (_WaitState > 0)
00624                 return;
00625 
00626         if (Time > FuturTime)
00627                 Time = FuturTime;
00628 
00629         // take old computed bill.
00630         Viewer= _BillViewer;
00631 /*              Center= _BillCenter*((float)(Trans)/(float)TransTotal) +
00632                         _BillOldCenter*((float)(TransTotal-Trans)/(float)TransTotal);
00633 
00634         calcBill (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far);
00635 
00636 
00637         CVector lct = Viewer + J*Near;
00638         qc.V0 = lct + I*Left    + K*Bottom;
00639         qc.V1 = lct + I*Right   + K*Bottom;
00640         qc.V2 = lct + I*Right   + K*Top;
00641         qc.V3 = lct + I*Left    + K*Top;*/
00642 
00643         Center= _BillCenter;
00644         calcBill (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far);
00645         CVector lct = Viewer + J*Near;
00646         CQuadUV qc0;
00647         qc0.V0 = lct + I*Left   + K*Bottom;
00648         qc0.V1 = lct + I*Right  + K*Bottom;
00649         qc0.V2 = lct + I*Right  + K*Top;
00650         qc0.V3 = lct + I*Left   + K*Top;
00651 
00652         Center= _BillOldCenter;
00653         calcBill (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far);
00654         lct = Viewer + J*Near;
00655         CQuadUV qc1;
00656         qc1.V0 = lct + I*Left   + K*Bottom;
00657         qc1.V1 = lct + I*Right  + K*Bottom;
00658         qc1.V2 = lct + I*Right  + K*Top;
00659         qc1.V3 = lct + I*Left   + K*Top;
00660 
00661         float   a0= ((float)(Time)/(float)FuturTime);
00662         float   a1= (float)(FuturTime-Time)/(float)FuturTime;
00663         qc.V0= qc0.V0*a0 + qc1.V0*a1;
00664         qc.V1= qc0.V1*a0 + qc1.V1*a1;
00665         qc.V2= qc0.V2*a0 + qc1.V2*a1;
00666         qc.V3= qc0.V3*a0 + qc1.V3*a1;
00667 
00668         qc.Uv0 = CUV(0, 0);
00669         qc.Uv1 = CUV(1, 0);
00670         qc.Uv2 = CUV(1, 1);
00671         qc.Uv3 = CUV(0, 1);
00672 
00673         // Display TexBill with intensity : Trans / TransTotal
00674         // and TexOldBill  with intensity : (TransTotal-Trans) / TransTotal
00675 
00676         _CloudScape->_MatBill.setTexture (0, _TexOldBill);
00677         _CloudScape->_MatBill.setTexture (1, _TexBill);
00678         _CloudScape->_MatBill.setColor (CRGBA(255, 255, 255, (uint8)(255*((float)Time/(float)FuturTime))));
00679         CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
00680         uint32 nVSize = rVB.getVertexSize ();
00681         CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0);
00682         *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00683         *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00684         *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00685         *pVertices = qc.V3;
00686 
00687         CUV *pUV = (CUV*)rVB.getTexCoordPointer (0, 0);
00688         pUV->U = 0;     pUV->V = 0;     pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00689         pUV->U = 1;     pUV->V = 0;     pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00690         pUV->U = 1;     pUV->V = 1;     pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00691         pUV->U = 0;     pUV->V = 1;
00692 
00693         pUV = (CUV*)rVB.getTexCoordPointer (0, 1);
00694         pUV->U = 0;     pUV->V = 0;     pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00695         pUV->U = 1;     pUV->V = 0;     pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00696         pUV->U = 1;     pUV->V = 1;     pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00697         pUV->U = 0;     pUV->V = 1;
00698 
00699         _Driver->activeVertexBuffer (rVB);
00700         _Driver->renderQuads (_CloudScape->_MatBill, 0, 1);
00701 
00702         //nlinfo ("ok");
00703         
00704 
00705         // Debug
00706         if (_CloudScape->isDebugQuadEnabled())
00707         {
00708                 static CMaterial *mTmp = NULL;
00709                 if (mTmp == NULL)
00710                 {
00711                         mTmp = new CMaterial();
00712                         mTmp->setBlend(false);
00713                         mTmp->setDoubleSided(true);
00714                 }
00715                 /*if (_BillSize <= 4)
00716                         mTmp->setColor(CRGBA(0,127,0,255));
00717                 else if (_BillSize == 8)
00718                         mTmp->setColor(CRGBA(0,255,0,255));
00719                 else if (_BillSize == 16)
00720                         mTmp->setColor(CRGBA(127,255,0,255));
00721                 else if (_BillSize == 32)
00722                         mTmp->setColor(CRGBA(255,255,0,255));
00723                 else if (_BillSize == 64)
00724                         mTmp->setColor(CRGBA(255,127,0,255));
00725                 else if (_BillSize == 128)
00726                         mTmp->setColor(CRGBA(255,0,0,255));
00727                 else if (_BillSize == 256)
00728                         mTmp->setColor(CRGBA(127,0,0,255));*/
00729 
00730                         if (FuturTime <= 4)
00731                         mTmp->setColor(CRGBA(0,127,0,255));
00732                 else if (FuturTime <= 8)
00733                         mTmp->setColor(CRGBA(0,255,0,255));
00734                 else if (FuturTime <= 12)
00735                         mTmp->setColor(CRGBA(127,255,0,255));
00736                 else if (FuturTime <= 16)
00737                         mTmp->setColor(CRGBA(255,255,0,255));
00738                 else if (FuturTime <= 20)
00739                         mTmp->setColor(CRGBA(255,127,0,255));
00740                 else
00741                         mTmp->setColor(CRGBA(255,0,0,255));
00742 
00743                 _Driver->setPolygonMode(IDriver::Line);
00744                 _Driver->renderQuads (*mTmp, 0, 1);
00745                 _Driver->setPolygonMode(IDriver::Filled);
00746         }
00747 
00748 }

void NL3D::CCloud::dispXYZ NL3D::CMaterial pMat = NULL  ) 
 

Definition at line 388 of file cloud.cpp.

References _CloudScape, _Driver, _NbH, _NbW, _Pos, _Size, NL3D::CCloudScape::_VertexBuffer, NL3D::IDriver::activeVertexBuffer(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::IDriver::renderQuads(), NLMISC::CUV::U, uint32, uint8, NLMISC::CUV::V, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by genBill().

00389 {
00390         CQuadUV qc;
00391         uint32 i,j;
00392 
00393         float oneOverNbW = 1.0f / _NbW;
00394         float oneOverNbH = 1.0f / _NbH;
00395         float oneOverNbWNbH = 1.0f / (_NbW*_NbH);
00396         CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
00397         uint32 nVSize = rVB.getVertexSize ();
00398         CVector *pVertices;
00399         CUV *pUV;
00400         _Driver->activeVertexBuffer (rVB);
00401 
00402         if (pMat == NULL)
00403                 return;
00404 
00405         for (j = 0; j < _NbH; ++j)
00406         {
00407                 for (i = 0; i < _NbW; ++i)
00408                 {
00409                         uint32 d = i+j*_NbW;
00410 
00411                         pVertices = (CVector*)rVB.getVertexCoordPointer (0);
00412                         *pVertices = CVector(_Pos.x,                    _Pos.y,                 _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00413                         *pVertices = CVector(_Pos.x+_Size.x,    _Pos.y,                 _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00414                         *pVertices = CVector(_Pos.x+_Size.x,    _Pos.y+_Size.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00415                         *pVertices = CVector(_Pos.x,                    _Pos.y+_Size.y, _Pos.z+_Size.z*(_NbW*_NbH-d)*oneOverNbWNbH);
00416 
00417                         pUV = (CUV*)rVB.getTexCoordPointer (0, 0);
00418                         pUV->U = i*oneOverNbW;          pUV->V = j*oneOverNbH;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00419                         pUV->U = (i+1)*oneOverNbW;      pUV->V = j*oneOverNbH;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00420                         pUV->U = (i+1)*oneOverNbW;      pUV->V = (j+1)*oneOverNbH;      pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00421                         pUV->U = i*oneOverNbW;          pUV->V = (j+1)*oneOverNbH;
00422 
00423                         pUV = (CUV*)rVB.getTexCoordPointer (0, 1);
00424                         pUV->U = i*oneOverNbW;          pUV->V = j*oneOverNbH;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00425                         pUV->U = (i+1)*oneOverNbW;      pUV->V = j*oneOverNbH;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00426                         pUV->U = (i+1)*oneOverNbW;      pUV->V = (j+1)*oneOverNbH;      pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00427                         pUV->U = i*oneOverNbW;          pUV->V = (j+1)*oneOverNbH;
00428 
00429                         _Driver->renderQuads (*pMat, 0, 1);
00430                 }
00431         }
00432 }

void NL3D::CCloud::genBill NL3D::CCamera pViewer,
uint32  nBillSize = 128
 

Definition at line 509 of file cloud.cpp.

References _BillCenter, _BillOldCenter, _BillSize, _BillViewer, _CloudScape, _CloudTexTmp, _Driver, _LastX, NL3D::CCloudScape::_MatClear, _MemBill, _MemOldBill, _OldBillSize, _Pos, _Size, _TexBill, _TexOldBill, NL3D::CCloudScape::_VertexBuffer, _WaitState, NL3D::IDriver::activeVertexBuffer(), calcBill(), CloudAmbient, NL3D::IDriver::copyFrameBufferToTexture(), dispXYZ(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::IDriver::getWindowSize(), NLMISC::CMatrix::identity(), NL3D::CViewport::init(), NL3D::CViewport::initFullScreen(), NLMISC::CMatrix::invert(), NL3D::IDriver::renderQuads(), NL3D::CMaterial::setColor(), NL3D::IDriver::setFrustum(), NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), NL3D::IDriver::setupModelMatrix(), NL3D::IDriver::setupViewMatrix(), NL3D::IDriver::setupViewport(), NL3D::SCloudTexture3D::ToBill, uint32, uint8, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NL3D::CCloudScape::makeHalfCloud().

00510 {
00511         // If minimized mode (screenW / H is 0) abort.
00512         uint32 nScreenW, nScreenH;
00513         _Driver->getWindowSize (nScreenW, nScreenH);
00514         if(nScreenW<=0 || nScreenH<=0)
00515                 return;
00516 
00517 
00518         // Compute the Bill
00519         uint32 sizeTMP = _OldBillSize;
00520         uint8 *MemTMP = _MemOldBill;
00521         CSmartPtr<CTextureMem>  TexTMP = _TexOldBill;
00522 
00523         _OldBillSize = _BillSize;
00524         _MemOldBill = _MemBill;
00525         _TexOldBill = _TexBill;
00526         _BillSize = sizeTMP;
00527         _MemBill = MemTMP;
00528         _TexBill = TexTMP;
00529 
00530         // Check the new size of the billboard
00531         if (nBillSize != _BillSize)
00532         {
00533                 _BillSize = nBillSize;
00534                 _MemBill = new uint8[4*_BillSize*_BillSize];
00535                 _TexBill = new CTextureMem (_MemBill, 4*_BillSize*_BillSize, true, false, _BillSize, _BillSize);
00536                 //for (i = 0; i < 4*_BillSize*_BillSize; ++i) _MemBill[i] = (uint8)i;
00537                 _TexBill->setWrapS (ITexture::Clamp);
00538                 _TexBill->setWrapT (ITexture::Clamp);
00539                 _TexBill->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff);
00540                 _TexBill->setReleasable (false);
00541                 _TexBill->generate();
00542         }
00543 
00544         CViewport viewport, viewportOLD;
00545         viewportOLD.initFullScreen();
00546         viewport.init(0.0f, 0.0f, ((float)_BillSize+1)/((float)nScreenW), ((float)_BillSize+1)/((float)nScreenH));
00547         _Driver->setupViewport (viewport);
00548 
00549         //CMatrix CamMat = pCam->getMatrix();
00550         //CVector Viewer = CamMat.getPos();
00551         CVector Viewer = CVector (0,0,0);
00552         CVector Center = CVector (_Pos.x+_Size.x/2, _Pos.y+_Size.y/2, _Pos.z+_Size.z/2);
00553         CVector Size = _Size;
00554         CVector I, J, K;
00555         float Left, Right, Top, Bottom, Near, Far;
00556 
00557         calcBill (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far);
00558 
00559         CMatrix mat;
00560         mat.identity();
00561         mat.setRot(I,J,K, true);
00562         mat.setPos(CVector(Viewer.x, Viewer.y, Viewer.z));
00563         mat.invert();
00564 
00565         // Clear background for cloud creation
00566         _Driver->setFrustum(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, false);
00567         _Driver->setupViewMatrix (CMatrix::Identity);
00568         _Driver->setupModelMatrix (CMatrix::Identity);
00569 
00570         CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
00571         uint32 nVSize = rVB.getVertexSize ();
00572         CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0);
00573         *pVertices = CVector(0.0f,      0.0f,   0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00574         *pVertices = CVector(1.0f,      0.0f,   0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00575         *pVertices = CVector(1.0f,      0.0f,   1.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00576         *pVertices = CVector(0.0f,      0.0f,   1.0f);
00577 
00578         _CloudScape->_MatClear.setColor (CRGBA(0,0,0,0));
00579         _Driver->activeVertexBuffer (rVB);
00580         _Driver->renderQuads (_CloudScape->_MatClear, 0, 1);
00581 
00582         // Render 
00583         _Driver->setFrustum(Left, Right, Bottom, Top, Near, Far);
00584         _Driver->setupViewMatrix(mat);
00585         _Driver->setupModelMatrix (CMatrix::Identity);
00586 
00587         _CloudTexTmp->ToBill.setColor (CloudAmbient);
00588         dispXYZ (&_CloudTexTmp->ToBill);
00589 
00590         _Driver->copyFrameBufferToTexture (_TexBill, 0, 0, 0, 0, 0, _BillSize, _BillSize);
00591 
00592         // This is the end of render to texture like so reset all stuff
00593         _Driver->setupViewport (viewportOLD);
00594 
00595         _BillOldCenter = _BillCenter;
00596         _BillViewer = Viewer;
00597         _BillCenter = Center;
00598 
00599         if (_WaitState > 0)
00600                 _WaitState = _WaitState - 1;
00601 
00602         _LastX = _Pos.x;
00603 }

void NL3D::CCloud::generate CNoise3d noise  ) 
 

Definition at line 110 of file cloud.cpp.

References _BaseFreq, _CloudScape, _CloudTexClamp, _CloudTexTmp, _Depth, _Driver, _Height, NL3D::CCloudScape::_MatClear, _NbH, _NbOctave, _NbW, _UStart, NL3D::CCloudScape::_VertexBuffer, _VStart, _Width, _WStart, NL3D::IDriver::activeVertexBuffer(), CloudDistAtt, CloudPower, NL3D::IDriver::copyFrameBufferToTexture(), NL3D::CNoise3d::flush(), NL3D::CNoise3d::getDepth(), NL3D::CNoise3d::getHeight(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::CNoise3d::getWidth(), NL3D::CNoise3d::renderGrid(), NL3D::IDriver::renderQuads(), NL3D::CMaterial::setColor(), setMode2D(), NL3D::SCloudTexture3D::Tex, NL3D::SCloudTextureClamp::ToClamp, NLMISC::CUV::U, uint32, uint8, and NLMISC::CUV::V.

Referenced by NL3D::CCloudScape::makeHalfCloud().

00111 {
00112         float dU, dV, dW;
00113         uint32 nOct;
00114         CQuadUV qc;
00115 
00116         // Setup the matrices view&model, viewport and frustum
00117         setMode2D ();
00118 
00119         // Clear background
00120         CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
00121         uint32 nVSize = rVB.getVertexSize ();
00122         CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0);
00123         *pVertices = CVector(0.0f,                              0.0f,                           0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00124         *pVertices = CVector((float)_NbW*_Width,0.0f,                           0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00125         *pVertices = CVector((float)_NbW*_Width,(float)_NbH*_Height,0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00126         *pVertices = CVector(0.0f,                              (float)_NbH*_Height,0.0f);
00127         _CloudScape->_MatClear.setColor (CRGBA(0,0,0,0));
00128         _Driver->activeVertexBuffer (rVB);
00129         _Driver->renderQuads (_CloudScape->_MatClear, 0, 1);
00130 
00131         // Create cloud from noise
00132         for (nOct = 0; nOct < _NbOctave; ++nOct)
00133         {
00134                 dU = (_BaseFreq*((float)_Width)/noise.getWidth())*(1<<nOct);
00135                 dV = (_BaseFreq*((float)_Height)/noise.getHeight())*(1<<nOct);
00136                 dW = (_BaseFreq*((float)_Depth)/noise.getDepth())*(1<<nOct);
00137 
00138 
00139                 noise.renderGrid (_NbW, _NbH, _Width, _Height, 
00140                                                 (float)_UStart[nOct], (float)_VStart[nOct], (float)_WStart[nOct], dU, dV, dW, 
00141                                                 1.0f/(2<<nOct));
00142 
00143                 /* This is the same thing as a renderGrid which is optimized to do that 
00144                 qc.Uv0 = CUV((float)_UStart[nOct],              (float)_VStart[nOct]);
00145                 qc.Uv1 = CUV((float)_UStart[nOct]+dU,   (float)_VStart[nOct]);
00146                 qc.Uv2 = CUV((float)_UStart[nOct]+dU,   (float)_VStart[nOct]+dV);
00147                 qc.Uv3 = CUV((float)_UStart[nOct],              (float)_VStart[nOct]+dV);
00148                 uint32 i,j;
00149                 for (j = 0; j < _NbH; ++j)
00150                 {
00151                         for (i = 0; i < _NbW; ++i)
00152                         {
00153                                 qc.V0 = CVector((float)i*_Width,                (float)j*_Height,               0.0f);
00154                                 qc.V1 = CVector((float)(i+1)*_Width,    (float)j*_Height,               0.0f);
00155                                 qc.V2 = CVector((float)(i+1)*_Width,    (float)(j+1)*_Height,   0.0f);
00156                                 qc.V3 = CVector((float)i*_Width,                (float)(j+1)*_Height,   0.0f);
00157                                 noise.render (qc, (float)_WStart[nOct]+dW*(i+(float)j*_NbW)/(((float)_NbW)*_NbH), 1.0f/(2<<nOct));
00158                         }
00159                 }*/
00160                 noise.flush ();
00161         }
00162 
00163         // Apply attenuation texture (not needed to resetup position again (done when clearing to black))
00164         CUV *pUV = (CUV*)rVB.getTexCoordPointer (0, 0);
00165         pUV->U = 0.0f;          pUV->V = 0.0f;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00166         pUV->U = 1.0f;          pUV->V = 0.0f;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00167         pUV->U = 1.0f;          pUV->V = 1.0f;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00168         pUV->U = 0.0f;          pUV->V = 1.0f;
00169         uint8 colpow = (uint8)(255-(((uint32)CloudPower*(255-(uint32)CloudDistAtt)) / 255));
00170         _CloudTexClamp->ToClamp.setColor (CRGBA(255, 255, 255, colpow));
00171         _Driver->activeVertexBuffer (rVB);
00172         _Driver->renderQuads (_CloudTexClamp->ToClamp, 0, 1);
00173 
00174         // We have generated to the screen the texture cloud so now copy from screen to the texture
00175         _Driver->copyFrameBufferToTexture (_CloudTexTmp->Tex, 0, 0, 0, 0, 0, _Width*_NbW, _Height*_NbH);
00176 
00177         _CloudTexTmp->Tex->setFilterMode (ITexture::Nearest, ITexture::NearestMipMapOff);
00178 }

uint32 NL3D::CCloud::getBillSize  )  [inline]
 

Definition at line 100 of file cloud.h.

References _BillSize, and uint32.

00100 { return _BillSize; }

float NL3D::CCloud::getLastX  )  [inline]
 

Definition at line 79 of file cloud.h.

References _LastX.

Referenced by NL3D::CCloudScape::makeHalfCloud().

00079 { return _LastX; }

uint32 NL3D::CCloud::getMemSize  )  [inline]
 

Definition at line 102 of file cloud.h.

References _BillSize, _OldBillSize, and uint32.

Referenced by NL3D::CCloudScape::getMemSize().

00103         {
00104                 return _OldBillSize*_OldBillSize*4 + _BillSize*_BillSize*4;
00105         }

float NL3D::CCloud::getSizeX  )  [inline]
 

Definition at line 83 of file cloud.h.

References _Size, and NLMISC::CVector::x.

Referenced by NL3D::CCloudScape::init(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

00083 { return _Size.x; }

float NL3D::CCloud::getSizeY  )  [inline]
 

Definition at line 84 of file cloud.h.

References _Size, and NLMISC::CVector::y.

Referenced by NL3D::CCloudScape::init(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

00084 { return _Size.y; }

float NL3D::CCloud::getSizeZ  )  [inline]
 

Definition at line 85 of file cloud.h.

References _Size, and NLMISC::CVector::z.

Referenced by NL3D::CCloudScape::init(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

00085 { return _Size.z; }

float NL3D::CCloud::getX  )  [inline]
 

Definition at line 78 of file cloud.h.

References _Pos, and NLMISC::CVector::x.

Referenced by NL3D::CCloudScape::init(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

00078 { return _Pos.x; }

float NL3D::CCloud::getY  )  [inline]
 

Definition at line 80 of file cloud.h.

References _Pos, and NLMISC::CVector::y.

Referenced by NL3D::CCloudScape::init(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

00080 { return _Pos.y; }

float NL3D::CCloud::getZ  )  [inline]
 

Definition at line 81 of file cloud.h.

References _Pos, and NLMISC::CVector::z.

Referenced by NL3D::CCloudScape::init(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

00081 { return _Pos.z; }

void NL3D::CCloud::init uint32  nVoxelW,
uint32  nVoxelH,
uint32  nVoxelD,
float  rBaseFreq,
uint32  nNbOctave
 

Definition at line 65 of file cloud.cpp.

References _BaseFreq, _BillSize, _Depth, _Height, _MemBill, _MemOldBill, _NbH, _NbOctave, _NbW, _OldBillSize, _Size, _UStart, _VStart, _Width, _WStart, NLMISC::getPowerOf2(), NLMISC::raiseToNextPowerOf2(), uint32, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

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

00066 {
00067         if (_UStart != NULL)
00068                 return;
00069         
00070         _BaseFreq = rBaseFreq;
00071         _BillSize = 0;
00072         _OldBillSize = 0;
00073 
00074         _NbOctave = nNbOctave;
00075         _UStart = new double[_NbOctave];
00076         _VStart = new double[_NbOctave];
00077         _WStart = new double[_NbOctave];
00078 
00079         uint32 i;
00080         for (i = 0; i < _NbOctave; ++i)
00081         {
00082                 _UStart[i] = ((double)rand())/RAND_MAX;
00083                 _VStart[i] = ((double)rand())/RAND_MAX;
00084                 _WStart[i] = ((double)rand())/RAND_MAX;
00085         }
00086 
00087         _Width = raiseToNextPowerOf2 (nVoxelW);
00088         _Height = raiseToNextPowerOf2 (nVoxelH);
00089         _Depth = raiseToNextPowerOf2 (nVoxelD);
00090         uint32 vdpo2 = getPowerOf2(_Depth);
00091         _NbW = 1 << (vdpo2 / 2);
00092         if ((vdpo2 & 1) != 0)
00093                 _NbH = 2 << (vdpo2 / 2);
00094         else
00095                 _NbH = 1 << (vdpo2 / 2);
00096 
00097         _MemBill = NULL;
00098         _MemOldBill = NULL;
00099 
00100         float scale = 20.0f + 10.0f*((float)rand())/RAND_MAX;;
00101         _Size.x = scale * _Width/_Depth;
00102         scale = 20.0f + 10.0f*((float)rand())/RAND_MAX;;
00103         _Size.y = scale * _Height/_Depth;
00104         scale = 20.0f + 10.0f*((float)rand())/RAND_MAX;;
00105         _Size.z = scale * _Depth/_Depth;
00106 
00107 }

void NL3D::CCloud::light  ) 
 

Definition at line 182 of file cloud.cpp.

References _CloudScape, _CloudTexTmp, _Driver, _Height, NL3D::CCloudScape::_MatClear, _NbH, _NbW, NL3D::CCloudScape::_VertexBuffer, _Width, NLMISC::CRGBA::A, NL3D::IDriver::activeVertexBuffer(), CloudDiffuse, NL3D::IDriver::copyFrameBufferToTexture(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::IDriver::renderQuads(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setColor(), NL3D::IDriver::setColorMask(), setMode2D(), NL3D::SCloudTexture3D::Tex, NL3D::SCloudTexture3D::ToLight, NLMISC::CUV::U, uint32, uint8, and NLMISC::CUV::V.

Referenced by NL3D::CCloudScape::makeHalfCloud().

00183 {
00184         uint32 i, j;
00185 
00186         // Setup the matrices view&model, viewport and frustum
00187         setMode2D ();
00188 
00189         // Destination position for lighting accumulation buffer from (0, 0) size (_Width, _Height)
00190         CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
00191         uint32 nVSize = rVB.getVertexSize ();
00192         CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0);
00193         *pVertices = CVector((float)0.0f,       (float)0.0f,    0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00194         *pVertices = CVector((float)_Width,     (float)0.0f,    0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00195         *pVertices = CVector((float)_Width,     (float)_Height, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00196         *pVertices = CVector((float)0.0f,       (float)_Height, 0.0f);
00197 
00198         // Clear the screen accumulatorfor lighting
00199         CloudDiffuse.A = 255;
00200         _CloudScape->_MatClear.setColor (CloudDiffuse);
00201         _Driver->activeVertexBuffer (rVB);
00202         _Driver->renderQuads (_CloudScape->_MatClear, 0, 1);
00203 
00204         CUV *pUV;
00205         // Lighting : render the alpha of one layer into rgb of the screen
00206         float oneOverNbW = 1.0f/_NbW;
00207         float oneOverNbH = 1.0f/_NbH;
00208         uint32 previ, prevj;
00209         _Driver->activeVertexBuffer (rVB);
00210         for (j = 0; j < _NbH; ++j)
00211         {
00212                 for (i = 0; i < _NbW; ++i)
00213                 {
00214                         // Add the alpha of the previous layer into the RGB of the destination
00215                         if ((i+j) > 0)
00216                         {
00217                                 _Driver->setColorMask (true, true, true, false);
00218                                 pUV = (CUV*)rVB.getTexCoordPointer (0, 0);
00219                                 pUV->U = previ*oneOverNbW;              pUV->V = prevj*oneOverNbH;              pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00220                                 pUV->U = (previ+1)*oneOverNbW;  pUV->V = prevj*oneOverNbH;              pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00221                                 pUV->U = (previ+1)*oneOverNbW;  pUV->V = (prevj+1)*oneOverNbH;  pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00222                                 pUV->U = previ*oneOverNbW;              pUV->V = (prevj+1)*oneOverNbH;
00223 
00224                                 _CloudTexTmp->ToLight.setBlend (true);
00225                                 _Driver->renderQuads (_CloudTexTmp->ToLight, 0, 1);
00226                         }
00227                         // Replace the alpha of the destination by the alpha of the current layer
00228                         _Driver->setColorMask (false, false, false, true);
00229 
00230                         pUV = (CUV*)rVB.getTexCoordPointer (0, 0);
00231                         pUV->U = i*oneOverNbW;          pUV->V = j*oneOverNbH;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00232                         pUV->U = (i+1)*oneOverNbW;      pUV->V = j*oneOverNbH;          pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00233                         pUV->U = (i+1)*oneOverNbW;      pUV->V = (j+1)*oneOverNbH;      pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00234                         pUV->U = i*oneOverNbW;          pUV->V = (j+1)*oneOverNbH;
00235 
00236                         _CloudTexTmp->ToLight.setBlend (false);
00237                         _Driver->renderQuads (_CloudTexTmp->ToLight, 0, 1);
00238 
00239                         // Copy from accumulator to the texture
00240                         _Driver->copyFrameBufferToTexture(_CloudTexTmp->Tex, 0, i*_Width, j*_Height, 0, 0, _Width, _Height);
00241                         previ = i;
00242                         prevj = j;
00243                 }
00244         }
00245         _Driver->setColorMask (true, true, true, true);
00246 
00247         _CloudTexTmp->Tex->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff);
00248 }

void NL3D::CCloud::reset NL3D::CCamera pViewer  ) 
 

Definition at line 251 of file cloud.cpp.

References _BillCenter, _BillOldCenter, _BillSize, _BillViewer, _CloudScape, _Driver, NL3D::CCloudScape::_MatClear, _MemBill, _MemOldBill, _OldBillSize, _Pos, _Size, _TexBill, _TexOldBill, NL3D::CCloudScape::_VertexBuffer, NL3D::IDriver::activeVertexBuffer(), calcBill(), NL3D::IDriver::copyFrameBufferToTexture(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), NL3D::IDriver::renderQuads(), NL3D::CMaterial::setColor(), setMode2D(), uint32, uint8, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

00252 {
00253         if (_BillSize != 4)
00254         {
00255                 _BillSize = 4;
00256                 _MemBill = new uint8[4*_BillSize*_BillSize];
00257                 _TexBill = new CTextureMem (_MemBill, 4*_BillSize*_BillSize, true, false, _BillSize, _BillSize);
00258                 _TexBill->setWrapS (ITexture::Clamp);
00259                 _TexBill->setWrapT (ITexture::Clamp);
00260                 _TexBill->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff);
00261                 _TexBill->generate();
00262                 _TexBill->setReleasable (false);
00263         }
00264         if (_OldBillSize != 4)
00265         {
00266                 _OldBillSize = 4;
00267                 _MemOldBill = new uint8[4*_OldBillSize*_OldBillSize];
00268                 _TexOldBill = new CTextureMem (_MemOldBill, 4*_OldBillSize*_OldBillSize, true, false, _OldBillSize, _OldBillSize);
00269                 _TexOldBill->setWrapS (ITexture::Clamp);
00270                 _TexOldBill->setWrapT (ITexture::Clamp);
00271                 _TexOldBill->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff);
00272                 _TexOldBill->generate();
00273                 _TexOldBill->setReleasable (false);
00274         }
00275         setMode2D ();
00276 
00277         // Clear background
00278         CVertexBuffer &rVB = _CloudScape->_VertexBuffer;
00279         uint32 nVSize = rVB.getVertexSize ();
00280         CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0);
00281         *pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00282         *pVertices = CVector(5.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00283         *pVertices = CVector(5.0f, 5.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00284         *pVertices = CVector(0.0f, 5.0f, 0.0f);
00285         _CloudScape->_MatClear.setColor (CRGBA(0,0,0,0));
00286         _Driver->activeVertexBuffer (rVB);
00287         _Driver->renderQuads (_CloudScape->_MatClear, 0, 1);
00288 
00289         _Driver->copyFrameBufferToTexture (_TexBill, 0, 0, 0, 0, 0, 4, 4);
00290         _Driver->copyFrameBufferToTexture (_TexOldBill, 0, 0, 0, 0, 0, 4, 4);
00291 
00292 //      CMatrix CamMat = pViewer->getMatrix();
00293 //      CVector Viewer = CamMat.getPos();
00294         CVector Viewer = CVector(0,0,0);
00295         CVector Center = CVector (_Pos.x+_Size.x/2, _Pos.y+_Size.y/2, _Pos.z+_Size.z/2);
00296         CVector Size = _Size;
00297         CVector I, J, K;
00298         float Left, Right, Top, Bottom, Near, Far;
00299 
00300         calcBill (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far);
00301 
00302         _BillOldCenter = _BillCenter;
00303         _BillViewer = Viewer;
00304         _BillCenter = Center;
00305 
00306         calcBill (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far);
00307 
00308         _BillOldCenter = _BillCenter;
00309         _BillViewer = Viewer;
00310         _BillCenter = Center;
00311 
00312 }

void NL3D::CCloud::setLooping  )  [inline]
 

Definition at line 98 of file cloud.h.

References _WaitState.

Referenced by NL3D::CCloudScape::makeHalfCloud().

00098 { _WaitState = 2; }

void NL3D::CCloud::setMode2D  )  [private]
 

Definition at line 751 of file cloud.cpp.

References _Driver, NL3D::IDriver::getWindowSize(), NLMISC::CMatrix::identity(), NL3D::CScissor::initFullScreen(), NL3D::IDriver::setFrustum(), NLMISC::CMatrix::setRot(), NL3D::IDriver::setupModelMatrix(), NL3D::IDriver::setupScissor(), NL3D::IDriver::setupViewMatrix(), NL3D::IDriver::setupViewport(), and uint32.

Referenced by generate(), light(), and reset().

00752 {
00753         CVector I(1,0,0), J(0,0,1), K(0,-1,0);
00754         CMatrix ViewMatrix;
00755         ViewMatrix.identity ();
00756         ViewMatrix.setRot (I,J,K, true);
00757         CScissor Scissor;
00758         Scissor.initFullScreen();
00759         _Driver->setupScissor (Scissor);
00760         _Driver->setupViewport (CViewport());
00761         uint32 nScreenW, nScreenH;
00762         _Driver->getWindowSize (nScreenW, nScreenH);
00763         _Driver->setFrustum (0, (float)nScreenW, 0, (float)nScreenH, -1, 1, false);
00764         _Driver->setupViewMatrix (ViewMatrix);
00765         _Driver->setupModelMatrix (CMatrix::Identity);
00766 }

void NL3D::CCloud::setSizeX float  x  )  [inline]
 

Definition at line 91 of file cloud.h.

References _Size, NLMISC::CVector::x, and x.

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

00091 { _Size.x = x; }

void NL3D::CCloud::setSizeY float  y  )  [inline]
 

Definition at line 92 of file cloud.h.

References _Size, NLMISC::CVector::y, and y.

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

00092 { _Size.y = y; }

void NL3D::CCloud::setSizeZ float  z  )  [inline]
 

Definition at line 93 of file cloud.h.

References _Size, NLMISC::CVector::z, and z.

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

00093 { _Size.z = z; }

void NL3D::CCloud::setTex3DTemp SCloudTexture3D t  )  [inline]
 

Definition at line 96 of file cloud.h.

References _CloudTexTmp, and t.

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

00096 { _CloudTexTmp = &t; }

void NL3D::CCloud::setTexClamp SCloudTextureClamp t  )  [inline]
 

Definition at line 95 of file cloud.h.

References _CloudTexClamp, and t.

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

00095 { _CloudTexClamp = &t; }

void NL3D::CCloud::setX float  x  )  [inline]
 

Definition at line 87 of file cloud.h.

References _LastX, _Pos, NLMISC::CVector::x, and x.

Referenced by NL3D::CCloudScape::init(), and NL3D::CCloudScape::makeHalfCloud().

00087 { _Pos.x = x; _LastX = x; }

void NL3D::CCloud::setY float  y  )  [inline]
 

Definition at line 88 of file cloud.h.

References _Pos, NLMISC::CVector::y, and y.

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

00088 { _Pos.y = y; }

void NL3D::CCloud::setZ float  z  )  [inline]
 

Definition at line 89 of file cloud.h.

References _Pos, NLMISC::CVector::z, and z.

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

00089 { _Pos.z = z; }


Field Documentation

float NL3D::CCloud::_BaseFreq [private]
 

Definition at line 135 of file cloud.h.

Referenced by generate(), and init().

NLMISC::CVector NL3D::CCloud::_BillCenter [private]
 

Definition at line 159 of file cloud.h.

Referenced by dispBill(), genBill(), and reset().

NLMISC::CVector NL3D::CCloud::_BillOldCenter [private]
 

Definition at line 159 of file cloud.h.

Referenced by dispBill(), genBill(), and reset().

uint32 NL3D::CCloud::_BillSize [private]
 

Definition at line 146 of file cloud.h.

Referenced by CCloud(), genBill(), getBillSize(), getMemSize(), init(), and reset().

NLMISC::CVector NL3D::CCloud::_BillViewer [private]
 

Definition at line 159 of file cloud.h.

Referenced by dispBill(), genBill(), and reset().

CCloudScape* NL3D::CCloud::_CloudScape [private]
 

Definition at line 139 of file cloud.h.

Referenced by CCloud(), disp(), dispBill(), dispXYZ(), genBill(), generate(), light(), and reset().

SCloudTextureClamp* NL3D::CCloud::_CloudTexClamp [private]
 

Definition at line 141 of file cloud.h.

Referenced by generate(), and setTexClamp().

SCloudTexture3D* NL3D::CCloud::_CloudTexTmp [private]
 

Definition at line 140 of file cloud.h.

Referenced by disp(), genBill(), generate(), light(), and setTex3DTemp().

uint32 NL3D::CCloud::_Depth [private]
 

Definition at line 128 of file cloud.h.

Referenced by generate(), and init().

NL3D::IDriver* NL3D::CCloud::_Driver [private]
 

Definition at line 163 of file cloud.h.

Referenced by CCloud(), disp(), dispBill(), dispXYZ(), genBill(), generate(), light(), reset(), and setMode2D().

uint32 NL3D::CCloud::_Height [private]
 

Definition at line 128 of file cloud.h.

Referenced by disp(), generate(), init(), and light().

float NL3D::CCloud::_LastX [private]
 

Definition at line 133 of file cloud.h.

Referenced by genBill(), getLastX(), and setX().

uint8* NL3D::CCloud::_MemBill [private]
 

Definition at line 147 of file cloud.h.

Referenced by dispBill(), genBill(), init(), and reset().

uint8* NL3D::CCloud::_MemOldBill [private]
 

Definition at line 152 of file cloud.h.

Referenced by dispBill(), genBill(), init(), and reset().

uint32 NL3D::CCloud::_NbH [private]
 

Definition at line 129 of file cloud.h.

Referenced by disp(), dispXYZ(), generate(), init(), and light().

uint32 NL3D::CCloud::_NbOctave [private]
 

Definition at line 136 of file cloud.h.

Referenced by anim(), generate(), and init().

uint32 NL3D::CCloud::_NbW [private]
 

Definition at line 129 of file cloud.h.

Referenced by disp(), dispXYZ(), generate(), init(), and light().

uint32 NL3D::CCloud::_OldBillSize [private]
 

Definition at line 151 of file cloud.h.

Referenced by CCloud(), genBill(), getMemSize(), init(), and reset().

NLMISC::CVector NL3D::CCloud::_Pos [private]
 

Definition at line 132 of file cloud.h.

Referenced by dispBill(), dispXYZ(), genBill(), getX(), getY(), getZ(), reset(), setX(), setY(), and setZ().

NLMISC::CVector NL3D::CCloud::_Size [private]
 

Definition at line 131 of file cloud.h.

Referenced by dispBill(), dispXYZ(), genBill(), getSizeX(), getSizeY(), getSizeZ(), init(), reset(), setSizeX(), setSizeY(), and setSizeZ().

NLMISC::CSmartPtr<NL3D::CTextureMem> NL3D::CCloud::_TexBill [private]
 

Definition at line 148 of file cloud.h.

Referenced by dispBill(), genBill(), and reset().

NLMISC::CSmartPtr<NL3D::CTextureMem> NL3D::CCloud::_TexOldBill [private]
 

Definition at line 153 of file cloud.h.

Referenced by dispBill(), genBill(), and reset().

double* NL3D::CCloud::_UStart [private]
 

Definition at line 137 of file cloud.h.

Referenced by anim(), CCloud(), generate(), init(), and ~CCloud().

double * NL3D::CCloud::_VStart [private]
 

Definition at line 137 of file cloud.h.

Referenced by anim(), CCloud(), generate(), init(), and ~CCloud().

uint8 NL3D::CCloud::_WaitState [private]
 

Definition at line 155 of file cloud.h.

Referenced by CCloud(), dispBill(), genBill(), and setLooping().

uint32 NL3D::CCloud::_Width [private]
 

Definition at line 128 of file cloud.h.

Referenced by disp(), generate(), init(), and light().

double * NL3D::CCloud::_WStart [private]
 

Definition at line 137 of file cloud.h.

Referenced by anim(), CCloud(), generate(), init(), and ~CCloud().

NLMISC::CRGBA NL3D::CCloud::CloudAmbient
 

Definition at line 111 of file cloud.h.

Referenced by CCloud(), genBill(), and NL3D::CCloudScape::makeHalfCloud().

NLMISC::CRGBA NL3D::CCloud::CloudDiffuse
 

Definition at line 110 of file cloud.h.

Referenced by CCloud(), light(), and NL3D::CCloudScape::makeHalfCloud().

uint8 NL3D::CCloud::CloudDistAtt
 

Definition at line 113 of file cloud.h.

Referenced by CCloud(), generate(), and NL3D::CCloudScape::makeHalfCloud().

uint8 NL3D::CCloud::CloudPower
 

Definition at line 112 of file cloud.h.

Referenced by NL3D::CCloudScape::anim(), CCloud(), generate(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

double NL3D::CCloud::FuturTime
 

Definition at line 108 of file cloud.h.

Referenced by dispBill(), NL3D::CCloudScape::init(), and NL3D::CCloudScape::makeHalfCloud().

uint8 NL3D::CCloud::LastCloudPower
 

Definition at line 115 of file cloud.h.

Referenced by CCloud(), NL3D::CCloudScape::makeHalfCloud(), and NL3D::CCloudScape::render().

double NL3D::CCloud::Time
 

Definition at line 108 of file cloud.h.

Referenced by NL3D::CCloudScape::anim(), dispBill(), NL3D::CCloudScape::init(), and NL3D::CCloudScape::makeHalfCloud().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:45:06 2004 for NeL by doxygen 1.3.6