# 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  

NL3D::CTextureDLM Class Reference

This texture is used by landscape to perform Dynamic LightMap (DLM). More...

#include <texture_dlm.h>

Inheritance diagram for NL3D::CTextureDLM:

NL3D::ITexture NLMISC::CBitmap NLMISC::CRefCount NLMISC::IStreamable NLMISC::IClassable List of all members.

Public Methods

 CTextureDLM (uint width, uint height)
 Constructor. More...

void doGenerate ()
 Since texture is always in memory... More...

 CTextureDLM ()
 TextureDLM are system. Do not need to serialize them... More...

virtual void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
 serial ITexture basic infos (clamp ...). More...

 NLMISC_DECLARE_CLASS (CTextureDLM)
Lightmap mgt.
bool canCreateLightMap (uint w, uint h)
 return true if can create a texture of this size. More...

bool createLightMap (uint w, uint h, uint &x, uint &y)
 create a space for a lightmap. More...

void copyRect (uint x, uint y, uint w, uint h, CRGBA *textMap)
 refill the texture with raw data. More...

void fillRect (uint x, uint y, uint w, uint h, uint8 value)
 same as copyRect(), but fill a RGBA(value, value, value, value). More...

void modulateAndfillRect565 (uint x, uint y, uint w, uint h, CRGBA *textMap, uint16 *modColor)
 same as copyRect(), but modulate textMap with an array of 565 color, before copying. More...

void modulateAndfillRect8888 (uint x, uint y, uint w, uint h, CRGBA *textMap, CRGBA *modColor)
 same as copyRect(), but modulate textMap with an array of CRGBA color, before copying. More...

void modulateConstantAndfillRect (uint x, uint y, uint w, uint h, CRGBA *textMap, CRGBA modColor)
 same as copyRect(), but modulate textMap with a cte color, before copying. More...

void releaseLightMap (uint x, uint y)
 Set a lightmap as free for use. It is an error to free a not allocated lightmap. (nlassert!!). More...


Private Methods

uint getTypeForSize (uint width, uint height)
 get the lightmap type id according to lightmap size. More...

void linkFreeBlock (uint lMapType, CBlock *block)
 FreeBlock list mgt. More...

void unlinkFreeBlock (uint lMapType, CBlock *block)

Private Attributes

uint _WBlock
 Number of block per line. More...

std::vector< CBlock_Blocks
 The list of blocks. More...

std::vector< uint_EmptyBlocks
 The list of available Blocks, ie Blocks with FreeSpace==0. More...

CBlock_FreeBlocks [NL_DLM_LIGHTMAP_TYPE_SIZE]
 For each type of lightmaps (2x2, 2x3 etc...), list of blocks which are not full. More...


Detailed Description

This texture is used by landscape to perform Dynamic LightMap (DLM).

Actually a CTextureDLM handle many block of lightmap in one single big texture. If NL_DLM_TILE_RES, then Block can be of size of 2,3,5 or 9 * 2,3,5 or 9 (eg 2x9, or 5x5 texture). else Block can be of size of 3,5,9 or 17 * 3,5,9 or 17 (eg 3x17, or 9x9 texture).

Implementation note (NL_DLM_TILE_RES not defined): To make this possible easily, blocks of 10x10 are created and placed in the texture. Hence a 9x9 texture lies in a single block, 3 textures of 3x9 lies in a block etc... In worst case, lost space is 19% (1 - 9*9 / 10*10).

If NL_DLM_TILE_RES is defined, then, same reasoning, with blocks of 18x18. In worst case, space lost is 70%: (1 - 15*15 / 18*18). But others cases are pretty good (90% to 100%)

NB: TextureDLM ensure that point (MaxX,MaxY) of this texture is black. UseFull for patch who want default black color

Author:
Lionel Berenguier , Nevrax France
Date:
2002

Definition at line 77 of file texture_dlm.h.


Constructor & Destructor Documentation

NL3D::CTextureDLM::CTextureDLM uint    width,
uint    height
 

Constructor.

Definition at line 42 of file texture_dlm.cpp.

References _Blocks, _EmptyBlocks, _FreeBlocks, _WBlock, height, NL_DLM_BLOCK_SIZE, NL_DLM_LIGHTMAP_TYPE_SIZE, nlassert, NL3D::ITexture::setFilterMode, NL3D::ITexture::setReleasable, NL3D::ITexture::setUploadFormat, and width.

NL3D::CTextureDLM::CTextureDLM   [inline]
 

TextureDLM are system. Do not need to serialize them...

Definition at line 92 of file texture_dlm.h.

References nlstop.


Member Function Documentation

bool NL3D::CTextureDLM::canCreateLightMap uint    w,
uint    h
 

return true if can create a texture of this size.

Definition at line 124 of file texture_dlm.cpp.

References _EmptyBlocks, _FreeBlocks, getTypeForSize, and w.

Referenced by createLightMap.

void NL3D::CTextureDLM::copyRect uint    x,
uint    y,
uint    w,
uint    h,
CRGBA *    textMap
 

refill the texture with raw data.

NB: no check is made on x,y,w,h lightmap validity. CRGBA are transformed to texture format (16 bits or better) The texture is invalidate (on this part only...)

Parameters:
map  is the raw array of RGBA colors to fills. must be of w*h size

Definition at line 241 of file texture_dlm.cpp.

References NLMISC::CBitmap::getPixels, NLMISC::CBitmap::getWidth, src, w, x, and y.

bool NL3D::CTextureDLM::createLightMap uint    w,
uint    h,
uint   x,
uint   y
 

create a space for a lightmap.

NB: texture space is not filled with black. return false if cannot, else return true, and return in x/y the position in the texture.

Definition at line 164 of file texture_dlm.cpp.

References _Blocks, _EmptyBlocks, _FreeBlocks, canCreateLightMap, getTypeForSize, linkFreeBlock, NL_DLM_BLOCK_SIZE, nlassert, unlinkFreeBlock, w, x, and y.

void NL3D::CTextureDLM::doGenerate   [inline, virtual]
 

Since texture is always in memory...

Implements NL3D::ITexture.

Definition at line 85 of file texture_dlm.h.

void NL3D::CTextureDLM::fillRect uint    x,
uint    y,
uint    w,
uint    h,
uint8    value
 

same as copyRect(), but fill a RGBA(value, value, value, value).

Definition at line 257 of file texture_dlm.cpp.

References NLMISC::CBitmap::getPixels, NLMISC::CBitmap::getWidth, value, w, x, and y.

uint NL3D::CTextureDLM::getTypeForSize uint    width,
uint    height
[private]
 

get the lightmap type id according to lightmap size.

Definition at line 98 of file texture_dlm.cpp.

References NLMISC::getPowerOf2, height, id, NL_DLM_LIGHTMAP_TYPE_SIZE, nlassert, and width.

Referenced by canCreateLightMap, createLightMap, and releaseLightMap.

void NL3D::CTextureDLM::linkFreeBlock uint    lMapType,
CBlock   block
[private]
 

FreeBlock list mgt.

Definition at line 136 of file texture_dlm.cpp.

References _FreeBlocks, and NL3D::CTextureDLM::CBlock::FreePrec.

Referenced by createLightMap, and releaseLightMap.

void NL3D::CTextureDLM::modulateAndfillRect565 uint    x,
uint    y,
uint    w,
uint    h,
CRGBA *    textMap,
uint16   modColor
 

same as copyRect(), but modulate textMap with an array of 565 color, before copying.

Definition at line 273 of file texture_dlm.cpp.

References NLMISC::CBitmap::getPixels, NLMISC::CBitmap::getWidth, w, x, and y.

void NL3D::CTextureDLM::modulateAndfillRect8888 uint    x,
uint    y,
uint    w,
uint    h,
CRGBA *    textMap,
CRGBA *    modColor
 

same as copyRect(), but modulate textMap with an array of CRGBA color, before copying.

Definition at line 305 of file texture_dlm.cpp.

References NLMISC::CBitmap::getPixels, NLMISC::CBitmap::getWidth, w, x, and y.

void NL3D::CTextureDLM::modulateConstantAndfillRect uint    x,
uint    y,
uint    w,
uint    h,
CRGBA *    textMap,
CRGBA    modColor
 

same as copyRect(), but modulate textMap with a cte color, before copying.

Definition at line 335 of file texture_dlm.cpp.

References NLMISC::CBitmap::getPixels, NLMISC::CBitmap::getWidth, w, x, and y.

NL3D::CTextureDLM::NLMISC_DECLARE_CLASS CTextureDLM   
 

void NL3D::CTextureDLM::releaseLightMap uint    x,
uint    y
 

Set a lightmap as free for use. It is an error to free a not allocated lightmap. (nlassert!!).

Definition at line 363 of file texture_dlm.cpp.

References _Blocks, _EmptyBlocks, _WBlock, getTypeForSize, linkFreeBlock, NL_DLM_BLOCK_SIZE, nlassert, unlinkFreeBlock, x, and y.

virtual void NL3D::CTextureDLM::serial NLMISC::IStream   f throw (NLMISC::EStream) [inline, virtual]
 

serial ITexture basic infos (clamp ...).

Reimplemented from NL3D::ITexture.

Definition at line 93 of file texture_dlm.h.

References nlstop.

void NL3D::CTextureDLM::unlinkFreeBlock uint    lMapType,
CBlock   block
[private]
 

Definition at line 148 of file texture_dlm.cpp.

References _FreeBlocks, NL3D::CTextureDLM::CBlock::FreeNext, and NL3D::CTextureDLM::CBlock::FreePrec.

Referenced by createLightMap, and releaseLightMap.


Member Data Documentation

std::vector<CBlock> NL3D::CTextureDLM::_Blocks [private]
 

The list of blocks.

There is TextureWidth/NL_DLM_BLOCK_SIZE * TextureHeight/NL_DLM_BLOCK_SIZE blocks, ranged from left to right then top to bottom.

Definition at line 178 of file texture_dlm.h.

Referenced by createLightMap, CTextureDLM, and releaseLightMap.

std::vector<uint> NL3D::CTextureDLM::_EmptyBlocks [private]
 

The list of available Blocks, ie Blocks with FreeSpace==0.

Definition at line 182 of file texture_dlm.h.

Referenced by canCreateLightMap, createLightMap, CTextureDLM, and releaseLightMap.

CBlock* NL3D::CTextureDLM::_FreeBlocks[NL_DLM_LIGHTMAP_TYPE_SIZE] [private]
 

For each type of lightmaps (2x2, 2x3 etc...), list of blocks which are not full.

Definition at line 186 of file texture_dlm.h.

Referenced by canCreateLightMap, createLightMap, CTextureDLM, linkFreeBlock, and unlinkFreeBlock.

uint NL3D::CTextureDLM::_WBlock [private]
 

Number of block per line.

Definition at line 173 of file texture_dlm.h.

Referenced by CTextureDLM, and releaseLightMap.


The documentation for this class was generated from the following files: