NL3D::CTextureFar Class Reference

A CTextureFar is a set of texture used to map a whole patch when it is in far Mode. More...

#include <texture_far.h>

Inherits NL3D::ITexture.

List of all members.

Classes

struct  CPatchIdent
struct  CVector2s

Public Member Functions

 CTextureFar ()
 Constructor.
virtual ~CTextureFar ()
sint tryAllocatePatch (CPatch *pPatch, uint farIndex)
 Try to allocate a patch.
void allocatePatch (CPatch *pPatch, uint farIndex, float &farUScale, float &farVScale, float &farUBias, float &farVBias, bool &bRot)
 Allocate a patch in the CTextureFar, according to its size.
void removePatch (CPatch *pPatch, uint farIndex)
 Remove a patch in the CTexture Far.
virtual void doGenerate (bool async=false)
 Generate the texture.
uint touchPatchULAndNext ()
 Touch a patch (call touchRect()) and iterate to next .
void startPatchULTouch ()
bool endPatchULTouch () const
void linkBeforeUL (CTextureFar *textNext)
 For lighting update, insert this before textNext (CiruclarList). textNext must be !NULL.
void unlinkUL ()
 For lighting update, unlink (CiruclarList).
CTextureFargetNextUL () const
 For lighting update, get Next (CiruclarList). If ==this, then list is empty.

Public Attributes

CTileFarBank_Bank
 A pointer on the far bank.

Private Types

typedef std::map< CPatchIdent,
CVector2s
TPatchToPosMap
 Map of Patchs stored in this texture Far.
typedef std::map< CVector2s,
CPatchIdent
TPosToPatchMap

Private Member Functions

bool getUpperSize (uint &width, uint &height)
uint getFreeListId (uint width, uint height)
void recursSplitNext (uint width, uint height)
void rebuildPatch (const CVector2s texturePos, const CPatchIdent &pid)
 Rebuild the patch passed in parameter.
virtual void serial (NLMISC::IStream &) throw (NLMISC::EStream)
 From IStreamable.
 NLMISC_DECLARE_CLASS (CTextureFar)

Private Attributes

TPatchToPosMap _PatchToPosMap
TPosToPatchMap _PosToPatchMap
std::list< CVector2s_FreeSpaces [NL_NUM_FAR_PATCH_EDGE_LEVEL *NL_NUM_FAR_RECTANGLE_RATIO]
 Lists of empty Space.
CTextureFar_ULPrec
 UpdateLighting. CiruclarList.
CTextureFar_ULNext
TPatchToPosMap::iterator _ItULPatch

Static Private Attributes

static NLMISC::CRGBA _LightmapExpanded []
static uint8 _LumelExpanded []
static NLMISC::CRGBA _TileTLIColors []

Detailed Description

A CTextureFar is a set of texture used to map a whole patch when it is in far Mode.

(ie not in tile mode). A CTextureFar handle several patch texture.\

TODO: keeping the far texture level1 alive when the tile pass in level0 (tile mode), don't erase it. TODO: add an hysteresis to avoid swap of far texture on boundaries of levels TODO: set the upload format in rgba565

Author:
Cyril Corvazier - Lionel Berenguier
Nevrax France
Date:
2000

Definition at line 83 of file texture_far.h.


Member Typedef Documentation

Map of Patchs stored in this texture Far.

Should be == to _WidthPatches*_HeightPatches

Definition at line 174 of file texture_far.h.

Definition at line 175 of file texture_far.h.


Constructor & Destructor Documentation

NL3D::CTextureFar::CTextureFar (  ) 
NL3D::CTextureFar::~CTextureFar (  )  [virtual]

Definition at line 90 of file texture_far.cpp.

References _ULNext, _ULPrec, and nlassert.


Member Function Documentation

void NL3D::CTextureFar::allocatePatch ( CPatch pPatch,
uint  farIndex,
float farUScale,
float farVScale,
float farUBias,
float farVBias,
bool bRot 
)

Allocate a patch in the CTextureFar, according to its size.

nlstop if fails. Must call before tryAllocate()

Parameters:
pPatch is the pointer to the patch to add in the landscape
farUVScale will receive the scale to use to compute the UV coordinates
farUBias will receive the U Bias to use to compute the UV coordinates
farVBias will receive the V Bias to use to compute the UV coordinates
bRot will receive true if the texture is rotated of 90deg to the left or false. You should take care of this value to compute UV coordinates.

Definition at line 274 of file texture_far.cpp.

References _FreeSpaces, _PatchToPosMap, _PosToPatchMap, NL3D::CTextureFar::CPatchIdent::FarIndex, getFreeListId(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NL_FAR_TEXTURE_EDGE_SIZE, NL_NUM_PIXELS_ON_FAR_TILE_EDGE, nlassert, NL3D::CTextureFar::CPatchIdent::Patch, recursSplitNext(), NLMISC::CBitmap::swap(), NL3D::ITexture::touchRect(), NL3D::CTextureFar::CVector2s::x, and NL3D::CTextureFar::CVector2s::y.

Referenced by NL3D::CLandscape::getFarRenderPass().

void NL3D::CTextureFar::doGenerate ( bool  async = false  )  [virtual]
bool NL3D::CTextureFar::endPatchULTouch (  )  const

Definition at line 409 of file texture_far.cpp.

References _ItULPatch, and _PatchToPosMap.

Referenced by NL3D::CLandscape::updateLightingTextureFar().

uint NL3D::CTextureFar::getFreeListId ( uint  width,
uint  height 
) [private]
CTextureFar* NL3D::CTextureFar::getNextUL (  )  const [inline]

For lighting update, get Next (CiruclarList). If ==this, then list is empty.

Definition at line 137 of file texture_far.h.

References _ULNext.

Referenced by NL3D::CLandscape::clearFarRenderPass(), and NL3D::CLandscape::updateLightingTextureFar().

bool NL3D::CTextureFar::getUpperSize ( uint width,
uint height 
) [private]

Definition at line 146 of file texture_far.cpp.

References NLMISC::isPowerOf2(), NL_MAX_FAR_PATCH_EDGE, and nlassert.

Referenced by recursSplitNext(), and tryAllocatePatch().

void NL3D::CTextureFar::linkBeforeUL ( CTextureFar textNext  ) 

For lighting update, insert this before textNext (CiruclarList). textNext must be !NULL.

Definition at line 98 of file texture_far.cpp.

References _ULNext, _ULPrec, and nlassert.

Referenced by NL3D::CLandscape::getFarRenderPass().

NL3D::CTextureFar::NLMISC_DECLARE_CLASS ( CTextureFar   )  [private]
void NL3D::CTextureFar::rebuildPatch ( const CVector2s  texturePos,
const CPatchIdent pid 
) [private]

Rebuild the patch passed in parameter.

Definition at line 463 of file texture_far.cpp.

References _Bank, _LightmapExpanded, _LumelExpanded, _TileTLIColors, NLMISC::CBitmap::_Width, NL3D::CTileFarBank::additive, NL3D_CComputeTileFar::AsmMMX, NL3D_CExpandLightmap::ColorTile, NL3D::CPatch::computeCurrentTLILightmapDiv2(), NL3D::CTileFarBank::diffuse, NL3D_CComputeTileFar::DstDeltaX, NL3D_CComputeTileFar::DstDeltaY, NL3D_CComputeTileFar::DstPixels, NL3D_CExpandLightmap::DstPixels, NL3D::CTextureFar::CPatchIdent::FarIndex, NL3D::CZone::getLandscape(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NLMISC::CBitmap::getPixelFormat(), NL3D::CTileFarBank::CTileFar::getPixels(), NLMISC::CBitmap::getPixels(), NL3D::CLandscape::getStaticLight(), NL3D::CTileFarBank::getTile(), NL3D::CTileElement::getTile256Info(), NL3D::CTileElement::getTileOrient(), NL3D::CPatch::getZone(), NLMISC::CSystemInfo::hasMMX(), NL3D_CExpandLightmap::Height, NL3D::CTileFarBank::CTileFar::isFill(), NL3D_CExpandLightmap::LumelTile, NL3D_CExpandLightmap::MulFactor, NL3D_drawFarTileInFarTexture(), NL3D_drawFarTileInFarTextureAdditive(), NL3D_drawFarTileInFarTextureAdditiveAlpha(), NL3D_drawFarTileInFarTextureAlpha(), NL3D_expandLightmap(), NL_NUM_PIXELS_ON_FAR_TILE_EDGE, NL_TILE_ELM_LAYER_EMPTY, nlassert, nlwarning, NL3D::CTileFarBank::order0, NL3D::CTileFarBank::order1, NL3D::CTileFarBank::order2, NL3D::CTextureFar::CPatchIdent::Patch, NLMISC::CBitmap::RGBA, NL3D_CComputeTileFar::Size, NL3D_CComputeTileFar::SrcAdditivePixels, NL3D_CComputeTileFar::SrcDeltaX, NL3D_CComputeTileFar::SrcDeltaY, NL3D_CComputeTileFar::SrcDiffusePixels, NL3D_CComputeTileFar::SrcLightingDeltaY, NL3D_CComputeTileFar::SrcLightingPixels, NL3D_CExpandLightmap::StaticLightColor, NL3D::CTileElement::Tile, NL3D::CPatch::TileColors, NL3D::CPatch::Tiles, NL3D_CExpandLightmap::TLIColor, NL3D::CPatch::unpackShadowMap(), NL3D_CExpandLightmap::Width, NL3D::CTextureFar::CVector2s::x, and NL3D::CTextureFar::CVector2s::y.

Referenced by doGenerate().

void NL3D::CTextureFar::recursSplitNext ( uint  width,
uint  height 
) [private]
void NL3D::CTextureFar::removePatch ( CPatch pPatch,
uint  farIndex 
)
virtual void NL3D::CTextureFar::serial ( NLMISC::IStream  )  throw (NLMISC::EStream) [inline, private, virtual]

From IStreamable.

Reimplemented from NL3D::ITexture.

Definition at line 195 of file texture_far.h.

void NL3D::CTextureFar::startPatchULTouch (  ) 

Definition at line 402 of file texture_far.cpp.

References _ItULPatch, and _PatchToPosMap.

Referenced by NL3D::CLandscape::updateLightingTextureFar().

uint NL3D::CTextureFar::touchPatchULAndNext (  ) 

Touch a patch (call touchRect()) and iterate to next .

Returns:
number of pixels touched. 0 if end() (empty).

Definition at line 366 of file texture_far.cpp.

References _ItULPatch, _PatchToPosMap, NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NL_NUM_PIXELS_ON_FAR_TILE_EDGE, NLMISC::CBitmap::swap(), and NL3D::ITexture::touchRect().

Referenced by NL3D::CLandscape::updateLightingTextureFar().

sint NL3D::CTextureFar::tryAllocatePatch ( CPatch pPatch,
uint  farIndex 
)

Try to allocate a patch.

return -1 if error (not enough space) return 0 if OK, and success to allocate a place without splitting any square else return the size of the max space to split (eg if must a split a 32x32 to allocate a 16x8)

Definition at line 174 of file texture_far.cpp.

References _FreeSpaces, getFreeListId(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), getUpperSize(), NL_NUM_PIXELS_ON_FAR_TILE_EDGE, and NLMISC::CBitmap::swap().

Referenced by NL3D::CLandscape::getFarRenderPass().

void NL3D::CTextureFar::unlinkUL (  ) 

For lighting update, unlink (CiruclarList).

Definition at line 114 of file texture_far.cpp.

References _ULNext, and _ULPrec.

Referenced by NL3D::CLandscape::clearFarRenderPass().


Member Data Documentation

A pointer on the far bank.

Definition at line 141 of file texture_far.h.

Referenced by NL3D::CLandscape::getFarRenderPass(), and rebuildPatch().

std::list<CVector2s> NL3D::CTextureFar::_FreeSpaces[NL_NUM_FAR_PATCH_EDGE_LEVEL *NL_NUM_FAR_RECTANGLE_RATIO] [private]

Lists of empty Space.

One for each possible size (64x64, 64x8 etc, but not 64x4 since not possible...)

Definition at line 181 of file texture_far.h.

Referenced by allocatePatch(), CTextureFar(), recursSplitNext(), removePatch(), and tryAllocatePatch().

TPatchToPosMap::iterator NL3D::CTextureFar::_ItULPatch [private]

Definition at line 198 of file texture_far.h.

Referenced by rebuildPatch().

Definition at line 199 of file texture_far.h.

Referenced by rebuildPatch().

Definition at line 177 of file texture_far.h.

Referenced by allocatePatch(), doGenerate(), and removePatch().

Definition at line 200 of file texture_far.h.

Referenced by rebuildPatch().

Definition at line 206 of file texture_far.h.

Referenced by CTextureFar(), getNextUL(), linkBeforeUL(), unlinkUL(), and ~CTextureFar().

UpdateLighting. CiruclarList.

Definition at line 205 of file texture_far.h.

Referenced by CTextureFar(), linkBeforeUL(), unlinkUL(), and ~CTextureFar().


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

Generated on Thu Jan 7 08:30:12 2010 for NeL by  doxygen 1.6.1