# 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::CPatchDLMContext Class Reference

A Dynamic LightMap (DLM) context for a patch. More...

#include <patchdlm_context.h>

Inheritance diagram for NL3D::CPatchDLMContext:

NL3D::CTessNodeList List of all members.

Public Types

enum  TCompileType { ModulateTileColor = 0, ModulateTextureFar, ModulateConstant, NoModulate }
 see compileLighting(). More...


Public Methods

 CPatchDLMContext ()
 Constructor. More...

 ~CPatchDLMContext ()
 Destructor: lightmap is released from _DLMTexture. More...

bool generate (CPatch *patch, CTextureDLM *textureDLM, CPatchDLMContextList *ctxList)
 generate: link to patch and allocate texture space, compile vertices etc... More...

void clearLighting ()
 Fill texture space with Black: RAM texture is updated. More...

void addPointLightInfluence (const CPatchDLMPointLight &pl)
 Add a pointLight influence to the lighting: RAM texture is updated. More...

void compileLighting (TCompileType compType, NLMISC::CRGBA modulateCte=NLMISC::CRGBA::White)
 update VRAM texture with RAM texture. More...

CPatchgetPatch () const
uint getMemorySize () const

Public Attributes

uint TextPosX
 DLM info The position and size of the DLM in the texture, in pixels. More...

uint TextPosY
 DLM info The position and size of the DLM in the texture, in pixels. More...

uint Width
 DLM info The position and size of the DLM in the texture, in pixels. More...

uint Height
 DLM info The position and size of the DLM in the texture, in pixels. More...

float DLMUScale
 Mapping to this rectangle from 0-1 basis. More...

float DLMVScale
 Mapping to this rectangle from 0-1 basis. More...

float DLMUBias
 Mapping to this rectangle from 0-1 basis. More...

float DLMVBias
 Mapping to this rectangle from 0-1 basis. More...

uint8 MinU8
 texture coordinate bound in 8 bits. Important for Vegetable special DLM mapping. More...

uint8 MaxU8
 texture coordinate bound in 8 bits. Important for Vegetable special DLM mapping. More...

uint8 MinV8
uint8 MaxV8
uint OldPointLightCount
 Lighting Process: number of light contribution to this patch in last rneder, and in cur Render. More...

uint CurPointLightCount

Private Methods

void computeTextureFar ()

Static Private Methods

const CRGBA * computeTileFarSrcDeltas (sint nRot, bool is256x256, uint8 uvOff, const CRGBA *srcPixel, sint &srcDeltaX, sint &srcDeltaY)
void copyTileToTexture (const CRGBA *srcPixel, sint srcDeltaX, sint srcDeltaY, CRGBA *dstPixel, uint dstStride)
void blendTileToTexture (const CRGBA *srcPixel, sint srcDeltaX, sint srcDeltaY, CRGBA *dstPixel, uint dstStride)

Private Attributes

CPatch_Patch
 The patch which owns us. More...

CTextureDLM_DLMTexture
 The DLM texture (only one per landscape). More...

CPatchDLMContextList_DLMContextList
NLMISC::CObjectVector< CVertex_Vertices
 Bezier Patch Array information: Width*Height. More...

NLMISC::CObjectVector< CRGBA > _LightMap
 The computed lightmap: Width*Height. More...

NLMISC::CObjectVector< CCluster_Clusters
 Bounding Sphere QuadTree (with NSkips paradigm). More...

bool _IsSrcTextureFullBlack
bool _IsDstTextureFullBlack
NLMISC::CObjectVector< uint16,
false > 
_LowResTileColors
NLMISC::CObjectVector< CRGBA > _TextureFar
 The TextureFar (at tile level or less), which is always computed at generate(). More...


Detailed Description

A Dynamic LightMap (DLM) context for a patch.

Author:
Lionel Berenguier , Nevrax France
Date:
2002

Definition at line 100 of file patchdlm_context.h.


Member Enumeration Documentation

enum NL3D::CPatchDLMContext::TCompileType
 

see compileLighting().

Enumeration values:
ModulateTileColor 
ModulateTextureFar 
ModulateConstant 
NoModulate 

Definition at line 111 of file patchdlm_context.h.


Constructor & Destructor Documentation

NL3D::CPatchDLMContext::CPatchDLMContext  
 

Constructor.

Definition at line 171 of file patchdlm_context.cpp.

References _DLMContextList, _DLMTexture, _IsDstTextureFullBlack, _IsSrcTextureFullBlack, _Patch, CurPointLightCount, and OldPointLightCount.

NL3D::CPatchDLMContext::~CPatchDLMContext  
 

Destructor: lightmap is released from _DLMTexture.

Definition at line 185 of file patchdlm_context.cpp.

References _DLMContextList, _DLMTexture, _Patch, TextPosX, and TextPosY.


Member Function Documentation

void NL3D::CPatchDLMContext::addPointLightInfluence const CPatchDLMPointLight   pl
 

Add a pointLight influence to the lighting: RAM texture is updated.

NB: full src blackness is reseted.

Definition at line 648 of file patchdlm_context.cpp.

References _Clusters, _IsSrcTextureFullBlack, _LightMap, _Vertices, NL3D::fastClamp01, Height, min, NL_DLM_CLIP_FACTOR, nlassert, NL3D::OptFastFloor24, NL3D::OptFastFloorBegin24, NL3D::OptFastFloorEnd24, r, NLMISC::CObjectVector< CCluster >::size, NLMISC::CObjectVector< CRGBA >::size, NLMISC::CObjectVector< CVertex >::size, Width, x, and y.

void NL3D::CPatchDLMContext::blendTileToTexture const CRGBA *    srcPixel,
sint    srcDeltaX,
sint    srcDeltaY,
CRGBA *    dstPixel,
uint    dstStride
[static, private]
 

Definition at line 1237 of file patchdlm_context.cpp.

References src.

Referenced by computeTextureFar.

void NL3D::CPatchDLMContext::clearLighting  
 

Fill texture space with Black: RAM texture is updated.

NB: full src blackness is cached.

Definition at line 592 of file patchdlm_context.cpp.

References _IsSrcTextureFullBlack, _LightMap, and NLMISC::CObjectVector< CRGBA >::size.

Referenced by generate.

void NL3D::CPatchDLMContext::compileLighting TCompileType    compType,
NLMISC::CRGBA    modulateCte = NLMISC::CRGBA::White
 

update VRAM texture with RAM texture.

Uploaded in 16 bits format. NB: full dst blackness is cached.

Parameters:
compType  say if, before writing to the texture, the lightmap is modulated with _Patch TileColor, _Patch textureFar (precomputed in the context), modulate with a constant or not modulated at all
modulateCte  used only if compType==ModulateConstant. this is the cte to be modulate by lightmap before copy to texture

Definition at line 888 of file patchdlm_context.cpp.

References _DLMTexture, _IsDstTextureFullBlack, _IsSrcTextureFullBlack, _LightMap, _LowResTileColors, _Patch, _TextureFar, Height, ModulateConstant, ModulateTextureFar, ModulateTileColor, nlassert, NLMISC::CObjectVector< CRGBA >::size, TextPosX, TextPosY, and Width.

void NL3D::CPatchDLMContext::computeTextureFar   [private]
 

Definition at line 964 of file patchdlm_context.cpp.

References _LowResTileColors, _Patch, _TextureFar, blendTileToTexture, computeTileFarSrcDeltas, copyTileToTexture, Height, NLAISCRIPT::l, NL_TILE_ELM_LAYER_EMPTY, nlassert, NLMISC::CObjectVector< CRGBA >::resize, src, Width, x, and y.

Referenced by generate.

const CRGBA * NL3D::CPatchDLMContext::computeTileFarSrcDeltas sint    nRot,
bool    is256x256,
uint8    uvOff,
const CRGBA *    srcPixel,
sint   srcDeltaX,
sint   srcDeltaY
[static, private]
 

Definition at line 1140 of file patchdlm_context.cpp.

Referenced by computeTextureFar.

void NL3D::CPatchDLMContext::copyTileToTexture const CRGBA *    srcPixel,
sint    srcDeltaX,
sint    srcDeltaY,
CRGBA *    dstPixel,
uint    dstStride
[static, private]
 

Definition at line 1224 of file patchdlm_context.cpp.

Referenced by computeTextureFar.

bool NL3D::CPatchDLMContext::generate CPatch   patch,
CTextureDLM   textureDLM,
CPatchDLMContextList   ctxList
 

generate: link to patch and allocate texture space, compile vertices etc...

The context is also linked to the list, and removed automaticllay at dtor Texture space is filled with black (RAM only)

Returns:
false if cannot allocate texture space for this patch

Definition at line 214 of file patchdlm_context.cpp.

References _Clusters, _DLMContextList, _DLMTexture, _LightMap, _LowResTileColors, _Patch, _Vertices, NLMISC::clamp, clearLighting, computeTextureFar, DLMUBias, DLMUScale, DLMVBias, DLMVScale, Height, MaxU8, MaxV8, min, MinU8, MinV8, NL_DLM_CLIP_FACTOR, NL_DLM_CLIP_NUM_LEVEL, nlassert, nlstop, NLMISC::CObjectVector< uint16, false >::resize, NLMISC::CObjectVector< CCluster >::resize, NLMISC::CObjectVector< CVertex >::resize, NLMISC::CObjectVector< CRGBA >::resize, s, NLMISC::CObjectVector< CCluster >::size, t, TextPosX, TextPosY, Width, x, and y.

uint NL3D::CPatchDLMContext::getMemorySize   const
 

Definition at line 948 of file patchdlm_context.cpp.

References _Clusters, _LightMap, _LowResTileColors, _TextureFar, _Vertices, NLMISC::CObjectVector< uint16, false >::size, NLMISC::CObjectVector< CCluster >::size, NLMISC::CObjectVector< CRGBA >::size, and NLMISC::CObjectVector< CVertex >::size.

CPatch* NL3D::CPatchDLMContext::getPatch   const [inline]
 

Definition at line 164 of file patchdlm_context.h.

References _Patch.


Member Data Documentation

NLMISC::CObjectVector<CCluster> NL3D::CPatchDLMContext::_Clusters [private]
 

Bounding Sphere QuadTree (with NSkips paradigm).

Definition at line 197 of file patchdlm_context.h.

Referenced by addPointLightInfluence, generate, and getMemorySize.

CPatchDLMContextList* NL3D::CPatchDLMContext::_DLMContextList [private]
 

Definition at line 177 of file patchdlm_context.h.

Referenced by CPatchDLMContext, generate, and ~CPatchDLMContext.

CTextureDLM* NL3D::CPatchDLMContext::_DLMTexture [private]
 

The DLM texture (only one per landscape).

Definition at line 175 of file patchdlm_context.h.

Referenced by compileLighting, CPatchDLMContext, generate, and ~CPatchDLMContext.

bool NL3D::CPatchDLMContext::_IsDstTextureFullBlack [private]
 

Definition at line 202 of file patchdlm_context.h.

Referenced by compileLighting, and CPatchDLMContext.

bool NL3D::CPatchDLMContext::_IsSrcTextureFullBlack [private]
 

Definition at line 200 of file patchdlm_context.h.

Referenced by addPointLightInfluence, clearLighting, compileLighting, and CPatchDLMContext.

NLMISC::CObjectVector<CRGBA> NL3D::CPatchDLMContext::_LightMap [private]
 

The computed lightmap: Width*Height.

Definition at line 183 of file patchdlm_context.h.

Referenced by addPointLightInfluence, clearLighting, compileLighting, generate, and getMemorySize.

NLMISC::CObjectVector<uint16, false> NL3D::CPatchDLMContext::_LowResTileColors [private]
 

Definition at line 208 of file patchdlm_context.h.

Referenced by compileLighting, computeTextureFar, generate, and getMemorySize.

CPatch* NL3D::CPatchDLMContext::_Patch [private]
 

The patch which owns us.

Definition at line 173 of file patchdlm_context.h.

Referenced by compileLighting, computeTextureFar, CPatchDLMContext, generate, getPatch, and ~CPatchDLMContext.

NLMISC::CObjectVector<CRGBA> NL3D::CPatchDLMContext::_TextureFar [private]
 

The TextureFar (at tile level or less), which is always computed at generate().

NB: Real compute is TextureFar*UserColor, so it need only to be modulated by lightmap each frame.

Definition at line 215 of file patchdlm_context.h.

Referenced by compileLighting, computeTextureFar, and getMemorySize.

NLMISC::CObjectVector<CVertex> NL3D::CPatchDLMContext::_Vertices [private]
 

Bezier Patch Array information: Width*Height.

Definition at line 180 of file patchdlm_context.h.

Referenced by addPointLightInfluence, generate, and getMemorySize.

uint NL3D::CPatchDLMContext::CurPointLightCount
 

Definition at line 128 of file patchdlm_context.h.

Referenced by CPatchDLMContext.

float NL3D::CPatchDLMContext::DLMUBias
 

Mapping to this rectangle from 0-1 basis.

Definition at line 119 of file patchdlm_context.h.

Referenced by generate.

float NL3D::CPatchDLMContext::DLMUScale
 

Mapping to this rectangle from 0-1 basis.

Definition at line 119 of file patchdlm_context.h.

Referenced by generate.

float NL3D::CPatchDLMContext::DLMVBias
 

Mapping to this rectangle from 0-1 basis.

Definition at line 119 of file patchdlm_context.h.

Referenced by generate.

float NL3D::CPatchDLMContext::DLMVScale
 

Mapping to this rectangle from 0-1 basis.

Definition at line 119 of file patchdlm_context.h.

Referenced by generate.

uint NL3D::CPatchDLMContext::Height
 

DLM info The position and size of the DLM in the texture, in pixels.

Definition at line 117 of file patchdlm_context.h.

Referenced by addPointLightInfluence, compileLighting, computeTextureFar, and generate.

uint8 NL3D::CPatchDLMContext::MaxU8
 

texture coordinate bound in 8 bits. Important for Vegetable special DLM mapping.

Definition at line 121 of file patchdlm_context.h.

Referenced by generate.

uint8 NL3D::CPatchDLMContext::MaxV8
 

Definition at line 122 of file patchdlm_context.h.

Referenced by generate.

uint8 NL3D::CPatchDLMContext::MinU8
 

texture coordinate bound in 8 bits. Important for Vegetable special DLM mapping.

Definition at line 121 of file patchdlm_context.h.

Referenced by generate.

uint8 NL3D::CPatchDLMContext::MinV8
 

Definition at line 122 of file patchdlm_context.h.

Referenced by generate.

uint NL3D::CPatchDLMContext::OldPointLightCount
 

Lighting Process: number of light contribution to this patch in last rneder, and in cur Render.

Modified by CPatch and CLandscape

Definition at line 127 of file patchdlm_context.h.

Referenced by CPatchDLMContext.

uint NL3D::CPatchDLMContext::TextPosX
 

DLM info The position and size of the DLM in the texture, in pixels.

Definition at line 117 of file patchdlm_context.h.

Referenced by compileLighting, generate, and ~CPatchDLMContext.

uint NL3D::CPatchDLMContext::TextPosY
 

DLM info The position and size of the DLM in the texture, in pixels.

Definition at line 117 of file patchdlm_context.h.

Referenced by compileLighting, generate, and ~CPatchDLMContext.

uint NL3D::CPatchDLMContext::Width
 

DLM info The position and size of the DLM in the texture, in pixels.

Definition at line 117 of file patchdlm_context.h.

Referenced by addPointLightInfluence, compileLighting, computeTextureFar, and generate.


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