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

A landscape zone. More...

#include <zone.h>

List of all members.

Public Methods

 CZone ()
 Constructor. More...

 ~CZone ()
 Destructor. More...

void build (const CZoneInfo &zoneInfo, uint32 numVertices=0)
 Build a zone. More...

void build (uint16 zoneId, const std::vector< CPatchInfo > &patchs, const std::vector< CBorderVertex > &borderVertices, uint32 numVertices=0)
 Build a zone. More...

void build (const CZone &zone)
 Build a copy of a zone. More...

void retrieve (CZoneInfo &zoneInfo)
 Retrieve zone patchinfo. More...

void retrieve (std::vector< CPatchInfo > &patchs, std::vector< CBorderVertex > &borderVertices)
 Retrieve zone patchinfo. More...

void debugBinds (FILE *f=stdout)
 Debug a zone, print binds in display. More...

void compile (CLandscape *landscape, TZoneMap &loadedZones)
 Compile a zone. More...

void release (TZoneMap &loadedZones)
 Release a zone. More...

void serial (NLMISC::IStream &f)
 Load/save a zone. More...

void changePatchTextureAndColor (sint numPatch, const std::vector< CTileElement > *tiles, const std::vector< CTileColor > *colors)
 Update and refresh a patch texture. More...

void refreshTesselationGeometry (sint numPatch)
 refresh the geometry (re-compute vertices). More...

const std::vector< CTileElement > & getPatchTexture (sint numPatch) const
 Get a patch texture. More...

const std::vector< CTileColor > & getPatchColor (sint numPatch) const
 Get a patch colors Return the color array. More...

CLandscapegetLandscape () const
 Get the landscape in which is placed this zone. More...

void clip (const std::vector< CPlane > &pyramid)
 Clip a zone. To know if must be rendered etc... A zone is IN if in BACK of at least one plane of the pyramid. More...

void preRender ()
 PreRender a zone (if needed). More...

void resetRenderFarAndDeleteVBFV ()
void forceMergeAtTileLevel ()
 For changing TileMaxSubdivision. force tesselation to be under tile. More...

void refineAll ()
 force Refine a zone. More...

void excludePatchFromRefineAll (uint patch, bool exclude)
 This is especially for Pacs. exlude a patch to be refineAll()ed. More...

void averageTesselationVertices ()
 This is especially for Pacs. More...

const CVector & getPatchBias () const
float getPatchScale () const
bool compiled () const
uint16 getZoneId () const
sint getNumPatchs () const
const CAABBoxExt & getZoneBB () const
const CPatchgetPatch (sint patch) const
 Get a read only patch pointer. More...

const CPatchConnectgetPatchConnect (sint patch) const
 Get a read only patch connect pointer. More...

void applyHeightField (const CLandscape &landScape)
 apply a landscape heightfield on a zone (modification of Z control points values). More...

void setupColorsFromTileFlags (const NLMISC::CRGBA colors[4])
 Debug purpose only : setup the colors of the patch of this zone so that it shows which tiles have vegetable disabled, or are above, below water. More...

void copyTilesFlags (sint destPatchId, const CPatch *srcPatch)
 Copy the tiles flags from a src patch to a patch of this zone. More...


Private Types

typedef NLMISC::CSmartPtr<
CTessBaseVertex
PBaseVertex
typedef std::vector< PBaseVertexTBaseVerticesVec
enum  TClipResult { ClipIn = 0, ClipOut = 1, ClipSide = 2 }

Private Methods

void rebindBorder (TZoneMap &loadedZones)
 Force border patchs (those who don't bind to current zone) to re bind() them, using new neighborood. More...

PBaseVertex getBaseVertex (sint vert) const
CPatchgetPatch (sint patch)
bool patchOnBorder (const CPatchConnect &pc) const
void computeBBScaleBias (const CAABBox &bb)
void buildBindInfo (uint patchId, uint edge, CZone *neighborZone, CPatch::CBindInfo &paBind)

Static Private Methods

CPatchgetZonePatch (TZoneMap &loadedZones, sint zoneId, sint patch)
void unbindPatch (CPatch &pa)
void bindPatch (TZoneMap &loadedZones, CPatch &pa, CPatchConnect &pc, bool rebind)

Private Attributes

CLandscapeLandscape
uint16 ZoneId
bool Compiled
CAABBoxExt ZoneBB
CVector PatchBias
float PatchScale
sint32 NumVertices
TBaseVerticesVec BaseVertices
std::vector< CBorderVertexBorderVertices
std::vector< CPatchPatchs
std::vector< CPatchConnectPatchConnects
CPointLightNamedArray _PointLightArray
 List of PointLights that may influences Patchs and objects walking on them. More...

sint ClipResult

Friends

class CLandscape
class CTessFace
class CPatch


Detailed Description

A landscape zone.

There is 2 ways for building a zone:

  • use build(). (then you can use serial to save the zone, don't need to compile() the zone).
  • use serial() for loading this zone.
Before a zone may be rendered, it must be compile()-ed, to compile and bind patch, to make vertices etc...

NB: you must call release() before deleting a compiled zone. (else assert in destruction).

Author:
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 296 of file src/3d/zone.h.


Member Typedef Documentation

typedef NLMISC::CSmartPtr<CTessBaseVertex> NL3D::CZone::PBaseVertex [private]
 

Definition at line 533 of file src/3d/zone.h.

typedef std::vector<PBaseVertex> NL3D::CZone::TBaseVerticesVec [private]
 

Definition at line 534 of file src/3d/zone.h.


Member Enumeration Documentation

enum NL3D::CZone::TClipResult [private]
 

Enumeration values:
ClipIn 
ClipOut 
ClipSide 

Definition at line 573 of file src/3d/zone.h.


Constructor & Destructor Documentation

NL3D::CZone::CZone  
 

Constructor.

Definition at line 82 of file 3d/zone.cpp.

References ClipOut, ClipResult, Compiled, Landscape, and ZoneId.

Referenced by compile, and release.

NL3D::CZone::~CZone  
 

Destructor.

Definition at line 90 of file 3d/zone.cpp.

References Compiled, and nlassert.


Member Function Documentation

void NL3D::CZone::applyHeightField const CLandscape   landScape
 

apply a landscape heightfield on a zone (modification of Z control points values).

NB: this is done in Landscape addZone(), before compile().

Parameters:
landScape  the landscape which gives Z delta values, for a x,y point.

Definition at line 1302 of file 3d/zone.cpp.

References computeBBScaleBias, CPatch, PatchBias, Patchs, and PatchScale.

void NL3D::CZone::averageTesselationVertices  
 

This is especially for Pacs.

see CLandscape desc.

Definition at line 1067 of file 3d/zone.cpp.

References Compiled, CPatch, nlassert, and Patchs.

void NL3D::CZone::bindPatch TZoneMap   loadedZones,
CPatch   pa,
CPatchConnect   pc,
bool    rebind
[static, private]
 

Definition at line 740 of file 3d/zone.cpp.

References nlassert, and NL3D::TZoneMap.

Referenced by compile, and rebindBorder.

void NL3D::CZone::build const CZone &    zone
 

Build a copy of a zone.

This method do a copy of zone (should be builded but maybe not compiled).

NB: cannot build on a compiled zone. must release the zone before....

Definition at line 359 of file 3d/zone.cpp.

References _PointLightArray, BorderVertices, Compiled, nlassert, NumVertices, PatchBias, PatchConnects, Patchs, PatchScale, ZoneBB, and ZoneId.

void NL3D::CZone::build uint16    zoneId,
const std::vector< CPatchInfo > &    patchs,
const std::vector< CBorderVertex > &    borderVertices,
uint32    numVertices = 0
 

Build a zone.

Deprecated. Should use build(CZoneInfo &) instead. see this method

Definition at line 111 of file 3d/zone.cpp.

References build.

void NL3D::CZone::build const CZoneInfo   zoneInfo,
uint32    numVertices = 0
 

Build a zone.

This method do:

  • compress the patchs coordinates.
  • build the patchs of the zone, but doesn't compile() them.
  • compress Lumels.
  • sort PointLights by name, and hence remap TileLightInfluences coordinates.
NB: cannot build on a compiled zone. must release the zone before....
Parameters:
numVertices  maximize the numgber of vertices used by this zone with this value.

Definition at line 121 of file 3d/zone.cpp.

References _PointLightArray, BorderVertices, Compiled, computeBBScaleBias, CPatch, NLAISCRIPT::l, NL_LUMEL_BY_TILE, NL_PATCH_SMOOTH_FLAG_MASK, NL_PATCH_SMOOTH_FLAG_SHIFT, nlassert, NumVertices, PatchBias, PatchConnects, Patchs, PatchScale, and ZoneId.

Referenced by build.

void NL3D::CZone::buildBindInfo uint    patchId,
uint    edge,
CZone *    neighborZone,
CPatch::CBindInfo   paBind
[private]
 

Definition at line 682 of file 3d/zone.cpp.

References nlassert, PatchConnects, and Patchs.

void NL3D::CZone::changePatchTextureAndColor sint    numPatch,
const std::vector< CTileElement > *    tiles,
const std::vector< CTileColor > *    colors
 

Update and refresh a patch texture.

Usefull for Tile edition. Even if patch is in tile mode, it is refreshed...

Parameters:
numPatch  the index of patch in this zone which will receive his new texture. assert if bad id.
tiles  the patch texture. assert if not of good size (OrderS*OrderT). Can be NULL if you don't want to change the patch texture.
colors  the patch texture. assert if not of good size ((OrderS+1)*(OrderT+1)). Can be NULL if you don't want to change the patch colors.

Definition at line 1191 of file 3d/zone.cpp.

References getNumPatchs, Landscape, nlassert, and Patchs.

void NL3D::CZone::clip const std::vector< CPlane > &    pyramid
 

Clip a zone. To know if must be rendered etc... A zone is IN if in BACK of at least one plane of the pyramid.

Definition at line 875 of file 3d/zone.cpp.

References ClipIn, ClipOut, ClipResult, ClipSide, Compiled, CPatch, nlassert, Patchs, and ZoneBB.

void NL3D::CZone::compile CLandscape   landscape,
TZoneMap   loadedZones
 

Compile a zone.

Make it usable for clip()/refine()/render(). This method do:

  • attach this to loadedZones.
  • create/link the base vertices (internal..), according to present neigbor zones.
  • compile() the patchs.
  • bind() the patchs.
  • rebindBorder() on neighbor zones.
A zone must keep a pointer on a landscape, for texture management. NB: assert if already compiled. assert if zone already exist in loadedZones.

Definition at line 476 of file 3d/zone.cpp.

References BaseVertices, bindPatch, BorderVertices, Compiled, CPatch, CZone, NL3D::ItZoneMap, Landscape, nlassert, NumVertices, PatchConnects, Patchs, NL3D::TZoneMap, and ZoneId.

bool NL3D::CZone::compiled   const [inline]
 

Definition at line 478 of file src/3d/zone.h.

References Compiled.

void NL3D::CZone::computeBBScaleBias const CAABBox &    bb [private]
 

Definition at line 98 of file 3d/zone.cpp.

References NL3D_NOISE_MAX, PatchBias, PatchScale, and ZoneBB.

Referenced by applyHeightField, and build.

void NL3D::CZone::copyTilesFlags sint    destPatchId,
const CPatch   srcPatch
 

Copy the tiles flags from a src patch to a patch of this zone.

the patch must match of course...

Definition at line 1392 of file 3d/zone.cpp.

References CPatch, and getPatch.

void NL3D::CZone::debugBinds FILE *    f = stdout
 

Debug a zone, print binds in display.

Definition at line 1270 of file 3d/zone.cpp.

References BorderVertices, PatchConnects, and ZoneId.

void NL3D::CZone::excludePatchFromRefineAll uint    patch,
bool    exclude
 

This is especially for Pacs. exlude a patch to be refineAll()ed.

Definition at line 1022 of file 3d/zone.cpp.

References Compiled, nlassert, and Patchs.

void NL3D::CZone::forceMergeAtTileLevel  
 

For changing TileMaxSubdivision. force tesselation to be under tile.

Definition at line 1171 of file 3d/zone.cpp.

References CPatch, and Patchs.

PBaseVertex NL3D::CZone::getBaseVertex sint    vert const [inline, private]
 

Definition at line 583 of file src/3d/zone.h.

References BaseVertices.

CLandscape* NL3D::CZone::getLandscape   const [inline]
 

Get the landscape in which is placed this zone.

If no landscape, return NULL.

Returns:
the pointer of the landscape of the zone or NULL if the zone hasn't be compiled.

Definition at line 452 of file src/3d/zone.h.

References CLandscape, and Landscape.

sint NL3D::CZone::getNumPatchs   const [inline]
 

Definition at line 480 of file src/3d/zone.h.

References Patchs.

Referenced by changePatchTextureAndColor, getPatchColor, getPatchTexture, and refreshTesselationGeometry.

CPatch* NL3D::CZone::getPatch sint    patch [inline, private]
 

Definition at line 584 of file src/3d/zone.h.

References CPatch, nlassert, and Patchs.

const CPatch* NL3D::CZone::getPatch sint    patch const [inline]
 

Get a read only patch pointer.

Parameters:
patch  the index of patch to get.
Returns:
A patch pointer in read only.

Definition at line 490 of file src/3d/zone.h.

References CPatch, nlassert, and Patchs.

Referenced by copyTilesFlags.

const CVector& NL3D::CZone::getPatchBias   const [inline]
 

Definition at line 476 of file src/3d/zone.h.

References PatchBias.

const std::vector< CTileColor > & NL3D::CZone::getPatchColor sint    numPatch const
 

Get a patch colors Return the color array.

Parameters:
numPatch  the index of patch in this zone which will get his colors. assert if bad id.
return  The tiles the patch colors. The size should be (OrderS+1)*(OrderT+1).
See also:
getPatch()

Definition at line 1259 of file 3d/zone.cpp.

References getNumPatchs, nlassert, and Patchs.

const CPatchConnect* NL3D::CZone::getPatchConnect sint    patch const [inline]
 

Get a read only patch connect pointer.

Parameters:
patch  the index of patch to get.
Returns:
A patch pointer in read only.

Definition at line 498 of file src/3d/zone.h.

References nlassert, PatchConnects, and Patchs.

float NL3D::CZone::getPatchScale   const [inline]
 

Definition at line 477 of file src/3d/zone.h.

References PatchScale.

const std::vector< CTileElement > & NL3D::CZone::getPatchTexture sint    numPatch const
 

Get a patch texture.

Return the tile array.

Parameters:
numPatch  the index of patch in this zone which will get his texture. assert if bad id.
return  The tiles the patch texture. The size should be OrderS*OrderT.
See also:
getPatch()

Definition at line 1248 of file 3d/zone.cpp.

References getNumPatchs, nlassert, and Patchs.

const CAABBoxExt& NL3D::CZone::getZoneBB   const [inline]
 

Definition at line 482 of file src/3d/zone.h.

References ZoneBB.

uint16 NL3D::CZone::getZoneId   const [inline]
 

Definition at line 479 of file src/3d/zone.h.

References ZoneId.

Referenced by retrieve.

CPatch * NL3D::CZone::getZonePatch TZoneMap   loadedZones,
sint    zoneId,
sint    patch
[static, private]
 

Definition at line 669 of file 3d/zone.cpp.

References NL3D::TZoneMap.

bool NL3D::CZone::patchOnBorder const CPatchConnect   pc const [private]
 

Definition at line 846 of file 3d/zone.cpp.

References nlassert, and ZoneId.

Referenced by rebindBorder.

void NL3D::CZone::preRender  
 

PreRender a zone (if needed).

Definition at line 1085 of file 3d/zone.cpp.

References ClipOut, ClipResult, ClipSide, Compiled, CPatch, nlassert, Patchs, and ZoneId.

void NL3D::CZone::rebindBorder TZoneMap   loadedZones [private]
 

Force border patchs (those who don't bind to current zone) to re bind() them, using new neighborood.

no-op if zone is not compiled.

Definition at line 650 of file 3d/zone.cpp.

References bindPatch, CPatch, PatchConnects, patchOnBorder, Patchs, and NL3D::TZoneMap.

void NL3D::CZone::refineAll  
 

force Refine a zone.

Definition at line 1035 of file 3d/zone.cpp.

References Compiled, CPatch, nlassert, and Patchs.

void NL3D::CZone::refreshTesselationGeometry sint    numPatch
 

refresh the geometry (re-compute vertices).

Usefull for Tile Noise edition. Do it after calling changePatchTextureAndColor(). NB: a refreshTesselationGeometry() should be done on All patchs, and all direct neighbors of this patch (including patchs on corners). WARNING: specially coded for Tile edition. Result is not perfect:

  • only EndPos of tesselation is modified. because Tile edition always subdivide at max.
  • Pos=EndPos. because TileEdition always subdivide at max, and don't refine...
  • TessBlocks BSphere may be too big. Clip is worse (too big), but doesn't matter.
Parameters:
numPatch  the index of patch in this zone. assert if bad id.

Definition at line 1234 of file 3d/zone.cpp.

References Compiled, getNumPatchs, Landscape, nlassert, and Patchs.

void NL3D::CZone::release TZoneMap   loadedZones
 

Release a zone.

This method do:

  • detach this zone to loadedZones.
  • destroy/unlink the base vertices (internal..), according to present neigbor zones.
  • unbind() the patchs.
  • release() the patchs.
  • rebindBorder() on neighbor zones.
NB: no-op if not compiled.

Definition at line 567 of file 3d/zone.cpp.

References BaseVertices, BorderVertices, ClipOut, ClipResult, Compiled, CPatch, CZone, NL3D::ItZoneMap, Landscape, nlassert, NumVertices, Patchs, NL3D::TZoneMap, unbindPatch, and ZoneId.

void NL3D::CZone::resetRenderFarAndDeleteVBFV  
 

Definition at line 1149 of file 3d/zone.cpp.

References CPatch, and Patchs.

void NL3D::CZone::retrieve std::vector< CPatchInfo > &    patchs,
std::vector< CBorderVertex > &    borderVertices
 

Retrieve zone patchinfo.

Deprecated. Should use retrieve(CZoneInfo &) instead. see this method.

Definition at line 272 of file 3d/zone.cpp.

References retrieve.

void NL3D::CZone::retrieve CZoneInfo   zoneInfo
 

Retrieve zone patchinfo.

This method uncompress the patchs coordinates and all info into the patch info/borderVertices. Warning!!! Due to compression, data won't be the same as those given in build(). Same remark for TileLightInfluences, due to light sorting.

Definition at line 283 of file 3d/zone.cpp.

References _PointLightArray, BorderVertices, CPatch, getZoneId, NL_PATCH_SMOOTH_FLAG_MASK, NL_PATCH_SMOOTH_FLAG_SHIFT, PatchBias, PatchConnects, Patchs, and PatchScale.

Referenced by retrieve.

void NL3D::CZone::serial NLMISC::IStream   f
 

Load/save a zone.

Save work even if zone is not compiled, but load must be done on a not compiled zone...

Definition at line 419 of file 3d/zone.cpp.

References _PointLightArray, BorderVertices, NumVertices, PatchBias, PatchConnects, Patchs, PatchScale, NLMISC::IStream::serial, NLMISC::IStream::serialCheck, NLMISC::IStream::serialCont, NLMISC::IStream::serialVersion, NLMISC::IStream::xmlPop, NLMISC::IStream::xmlPush, NLMISC::IStream::xmlSerial, ZoneBB, and ZoneId.

void NL3D::CZone::setupColorsFromTileFlags const NLMISC::CRGBA    colors[4]
 

Debug purpose only : setup the colors of the patch of this zone so that it shows which tiles have vegetable disabled, or are above, below water.

User provides a table with 4 colors for each state : color 0 = above water color 1 = underwater color 2 = intersect water color 3 = vegetable disabled

Definition at line 1382 of file 3d/zone.cpp.

References Patchs.

void NL3D::CZone::unbindPatch CPatch   pa [static, private]
 

Definition at line 832 of file 3d/zone.cpp.

Referenced by release.


Friends And Related Function Documentation

friend class CLandscape [friend]
 

Definition at line 567 of file src/3d/zone.h.

Referenced by getLandscape.

friend class CPatch [friend]
 

Definition at line 570 of file src/3d/zone.h.

Referenced by applyHeightField, averageTesselationVertices, build, clip, compile, copyTilesFlags, forceMergeAtTileLevel, getPatch, preRender, rebindBorder, refineAll, release, resetRenderFarAndDeleteVBFV, and retrieve.

friend class CTessFace [friend]
 

Definition at line 568 of file src/3d/zone.h.


Member Data Documentation

CPointLightNamedArray NL3D::CZone::_PointLightArray [private]
 

List of PointLights that may influences Patchs and objects walking on them.

Definition at line 563 of file src/3d/zone.h.

Referenced by build, retrieve, and serial.

TBaseVerticesVec NL3D::CZone::BaseVertices [private]
 

Definition at line 552 of file src/3d/zone.h.

Referenced by compile, getBaseVertex, and release.

std::vector<CBorderVertex> NL3D::CZone::BorderVertices [private]
 

Definition at line 554 of file src/3d/zone.h.

Referenced by build, compile, debugBinds, release, retrieve, and serial.

sint NL3D::CZone::ClipResult [private]
 

Definition at line 572 of file src/3d/zone.h.

Referenced by clip, CZone, preRender, and release.

bool NL3D::CZone::Compiled [private]
 

Definition at line 544 of file src/3d/zone.h.

Referenced by averageTesselationVertices, build, clip, compile, compiled, CZone, excludePatchFromRefineAll, preRender, refineAll, refreshTesselationGeometry, release, and ~CZone.

CLandscape* NL3D::CZone::Landscape [private]
 

Definition at line 540 of file src/3d/zone.h.

Referenced by changePatchTextureAndColor, compile, CZone, getLandscape, refreshTesselationGeometry, and release.

sint32 NL3D::CZone::NumVertices [private]
 

Definition at line 550 of file src/3d/zone.h.

Referenced by build, compile, release, and serial.

CVector NL3D::CZone::PatchBias [private]
 

Definition at line 546 of file src/3d/zone.h.

Referenced by applyHeightField, build, computeBBScaleBias, getPatchBias, retrieve, and serial.

std::vector<CPatchConnect> NL3D::CZone::PatchConnects [private]
 

Definition at line 559 of file src/3d/zone.h.

Referenced by build, buildBindInfo, compile, debugBinds, getPatchConnect, rebindBorder, retrieve, and serial.

std::vector<CPatch> NL3D::CZone::Patchs [private]
 

Definition at line 558 of file src/3d/zone.h.

Referenced by applyHeightField, averageTesselationVertices, build, buildBindInfo, changePatchTextureAndColor, clip, compile, excludePatchFromRefineAll, forceMergeAtTileLevel, getNumPatchs, getPatch, getPatchColor, getPatchConnect, getPatchTexture, preRender, rebindBorder, refineAll, refreshTesselationGeometry, release, resetRenderFarAndDeleteVBFV, retrieve, serial, and setupColorsFromTileFlags.

float NL3D::CZone::PatchScale [private]
 

Definition at line 547 of file src/3d/zone.h.

Referenced by applyHeightField, build, computeBBScaleBias, getPatchScale, retrieve, and serial.

CAABBoxExt NL3D::CZone::ZoneBB [private]
 

Definition at line 545 of file src/3d/zone.h.

Referenced by build, clip, computeBBScaleBias, getZoneBB, and serial.

uint16 NL3D::CZone::ZoneId [private]
 

Definition at line 543 of file src/3d/zone.h.

Referenced by build, compile, CZone, debugBinds, getZoneId, patchOnBorder, preRender, release, and serial.


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