NL3D::SCloudTextureClamp Struct Reference

#include <cloud_scape.h>


Public Member Functions

void init (uint32 nWidth, uint32 nHeight, uint32 nDepth, const std::string &filename)
 SCloudTextureClamp ()

Data Fields

uint32 Depth
uint32 Height
uint8Mem
uint32 NbH
uint32 NbW
NLMISC::CSmartPtr< NL3D::CTextureMemTex
NL3D::CMaterial ToClamp
uint32 Width


Constructor & Destructor Documentation

NL3D::SCloudTextureClamp::SCloudTextureClamp  ) 
 

Definition at line 126 of file cloud_scape.cpp.

References NL3D::CMaterial::initUnlit(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), NL3D::CMaterial::setColor(), NL3D::CMaterial::setShader(), NL3D::CMaterial::setZFunc(), NL3D::CMaterial::setZWrite(), NL3D::CMaterial::texEnvArg0Alpha(), NL3D::CMaterial::texEnvArg1Alpha(), NL3D::CMaterial::texEnvOpAlpha(), and ToClamp.

00127 {
00128         Mem = NULL;
00129         ToClamp.initUnlit();
00130         ToClamp.setShader (CMaterial::Normal);
00131         ToClamp.texEnvOpAlpha (0, CMaterial::Add);
00132         ToClamp.texEnvArg0Alpha (0, CMaterial::Texture, CMaterial::SrcAlpha);
00133         ToClamp.texEnvArg1Alpha (0, CMaterial::Diffuse, CMaterial::SrcAlpha);
00134         ToClamp.setColor (CRGBA(255,255,255,255));
00135         ToClamp.setBlend (true);
00136         ToClamp.setBlendFunc (CMaterial::one, CMaterial::one);
00137         ToClamp.setZFunc (CMaterial::always);
00138         ToClamp.setZWrite (false);
00139 
00140 }


Member Function Documentation

void NL3D::SCloudTextureClamp::init uint32  nWidth,
uint32  nHeight,
uint32  nDepth,
const std::string &  filename
 

Definition at line 143 of file cloud_scape.cpp.

References NLMISC::getPowerOf2(), r, NLMISC::raiseToNextPowerOf2(), NL3D::CMaterial::setTexture(), ToClamp, uint32, uint8, x, y, and z.

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

00144 {
00145         if (Mem != NULL)
00146                 return;
00147         
00148         Width = raiseToNextPowerOf2 (nWidth);
00149         Height = raiseToNextPowerOf2 (nHeight);
00150         Depth = raiseToNextPowerOf2 (nDepth);
00151         uint32 vdpo2 = getPowerOf2(Depth);
00152         NbW = 1 << (vdpo2 / 2);
00153         if ((vdpo2 & 1) != 0)
00154                 NbH = 2 << (vdpo2 / 2);
00155         else
00156                 NbH = 1 << (vdpo2 / 2);
00157 
00158         Mem = new uint8[NbW*Width*NbH*Height];
00159         uint32 i, j;
00160 
00161         if (filename == "")
00162         {
00163                 // No filename so init with default
00164                 for (i = 0; i < NbW; ++i)
00165                 {
00166                         for (j = 0; j < NbH; ++j)
00167                         {
00168                                 uint32 d = i+j*NbW;
00169                                 uint32 k, l;
00170                                 for (k = 0; k < Width; ++k)
00171                                 for (l = 0; l < Height; ++l)
00172                                 {
00173                                         float x = k+0.5f;
00174                                         float y = l+0.5f;
00175                                         float z = d+0.5f;
00176                                         float xc = Width/2.0f;
00177                                         float yc = Height/2.0f;
00178                                         float zc = Depth/2.0f;
00179 
00180                                         float r = (x-xc)*(x-xc)/(Width*Width/4.0f) + (y-yc)*(y-yc)/(Height*Height/4.0f) 
00181                                                         + (z-zc)*(z-zc)/(Depth*Depth/4.0f);
00182 
00183                                         uint8 col = 255;
00184                                         if (r < 1.0f)
00185                                         {
00186                                                 col = (uint8)((r)*223+32);
00187                                         }
00188                                         Mem[i*Width+k + (j*Height+l)*NbW*Width] = col;
00189                                 }
00190                         }
00191                 }
00192         }
00193         else
00194         {
00195                 // Load file TODO !
00196         }
00197 
00198         Tex = new CTextureMem (Mem, NbW*Width*NbH*Height, true, false, NbW*Width, NbH*Height, CBitmap::Alpha);
00199         Tex->setWrapS (ITexture::Repeat);
00200         Tex->setWrapT (ITexture::Repeat);
00201         Tex->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff);
00202 
00203         Tex->touch();
00204         Tex->setReleasable (false);
00205         Tex->generate();
00206 
00207         ToClamp.setTexture(0, Tex);
00208 
00209 }


Field Documentation

uint32 NL3D::SCloudTextureClamp::Depth
 

Definition at line 62 of file cloud_scape.h.

uint32 NL3D::SCloudTextureClamp::Height
 

Definition at line 62 of file cloud_scape.h.

uint8* NL3D::SCloudTextureClamp::Mem
 

Definition at line 64 of file cloud_scape.h.

uint32 NL3D::SCloudTextureClamp::NbH
 

Definition at line 63 of file cloud_scape.h.

uint32 NL3D::SCloudTextureClamp::NbW
 

Definition at line 63 of file cloud_scape.h.

NLMISC::CSmartPtr<NL3D::CTextureMem> NL3D::SCloudTextureClamp::Tex
 

Definition at line 65 of file cloud_scape.h.

NL3D::CMaterial NL3D::SCloudTextureClamp::ToClamp
 

Definition at line 66 of file cloud_scape.h.

Referenced by NL3D::CCloud::generate(), init(), and SCloudTextureClamp().

uint32 NL3D::SCloudTextureClamp::Width
 

Definition at line 62 of file cloud_scape.h.


The documentation for this struct was generated from the following files:
Generated on Tue Mar 16 08:42:11 2004 for NeL by doxygen 1.3.6