NL3D::CVisualCollisionEntity Class Reference

An entity created by CVisualCollisionManager. More...

#include <visual_collision_entity.h>

List of all members.

Public Member Functions

 CVisualCollisionEntity (CVisualCollisionManager *owner)
 Constructor.
 ~CVisualCollisionEntity ()
bool snapToGround (CVector &pos)
 Snap the entity onto the ground.
bool snapToGround (CVector &pos, CVector &normal)
 Snap the entity onto the ground.
void setGroundMode (bool groundMode)
 If groundMode is true, the entity is snapped on faces with normal.z > 0.
void setCeilMode (bool ceilMode)
 If ceilMode is true, the entity is snapped on faces with normal.z < 0.
bool getGroundMode () const
bool getCeilMode () const
void setSnapToRenderedTesselation (bool snapMode)
 By default, the visual collision entity is snapped on rendered/geomorphed tesselation (true).
bool getSnapToRenderedTesselation () const
bool getSurfaceInfo (const CVector &pos, CSurfaceInfo &info)
 Get surface informations.
Static Lighting



bool getStaticLightSetup (NLMISC::CRGBA sunAmbient, const CVector &pos, std::vector< CPointLightInfluence > &pointLightList, uint8 &sunContribution, NLMISC::CRGBA &localAmbient)
 Get the static Light Setup, using landscape under us.
Debug display



void displayDebugGrid (IDriver &drv) const
 Draw lines for the landscape quadgrid collision faces under us.

Static Public Attributes

Parameters.



static const float BBoxRadius = 10
 This is the radius of the bbox around the entity where we have correct collisions: 10m.
static const float BBoxRadiusZ = 20
 Same as BBoxRadius, but for z value.

Private Attributes

CVisualCollisionManager_Owner
bool _CeilMode
bool _GroundMode
bool _SnapToRenderedTesselation

Landscape part.



std::vector< CPatchQuadBlock * > _PatchQuadBlocks
 Array of quadBlock which are around the entity.
CLandscapeCollisionGrid _LandscapeQuadGrid
 A quadgrid of chainlist of tileId (CVisualTileDescNode), which are around the entity.
CAABBox _CurrentBBoxValidity
 The current BBox where we don't need to recompute the patchQuadBlocks if the entity is in.
bool _LastGPTValid
 Cache for getPatchTriangleUnderUs().
CVector _LastGPTPosInput
CVector _LastGPTPosOutput
CTrianglePatch _LastGPTTrianglePatch
static const uint32 _StartPatchQuadBlockSize = 64
 Default capacity of _PatchQuadBlocks.
static std::vector
< CPatchBlockIdent
_TmpBlockIds
 This is the temp array of BlockIds filled by landscape search.
static std::vector
< CPatchQuadBlock * > 
_TmpPatchQuadBlocks
 This is the temp array of PatchBlocks ptr.
static bool triangleIntersect2DGround (CTriangle &tri, const CVector &pos0)
 Fast "2D" test of a triangle against ray P0 P1.
static bool triangleIntersect2DCeil (CTriangle &tri, const CVector &pos0)
static void computeUvForPos (const CTrianglePatch &tri, const CVector &pos, CUV &uv)
 given a CTrianglePatch, compute Patch uv according to position.
bool triangleIntersect (CTriangle &tri, const CVector &pos0, const CVector &pos1, CVector &hit)
 Fast "2D" test of a triangle against ray P0 P1.
void testComputeLandscape (const CVector &pos)
 test if the new position is outside the preceding setuped bbox, and then compute tiles infos around the position.
void doComputeLandscape (const CVector &pos)
 compute tiles infos around the position.
void snapToLandscapeCurrentTesselation (CVector &pos, const CTrianglePatch &tri)
 snap to current rendered tesselation.
CTrianglePatchgetPatchTriangleUnderUs (const CVector &pos, CVector &res)
 return the best trianglePatch under what we are.

Detailed Description

An entity created by CVisualCollisionManager.

Author:
Lionel Berenguier
Nevrax France
Date:
2001

Definition at line 48 of file visual_collision_entity.h.


Constructor & Destructor Documentation

NL3D::CVisualCollisionEntity::CVisualCollisionEntity ( CVisualCollisionManager owner  ) 
NL3D::CVisualCollisionEntity::~CVisualCollisionEntity (  ) 

Member Function Documentation

void NL3D::CVisualCollisionEntity::computeUvForPos ( const CTrianglePatch tri,
const CVector pos,
CUV uv 
) [static, private]
void NL3D::CVisualCollisionEntity::displayDebugGrid ( IDriver drv  )  const
void NL3D::CVisualCollisionEntity::doComputeLandscape ( const CVector pos  )  [private]
bool NL3D::CVisualCollisionEntity::getCeilMode (  )  const [inline]

Definition at line 88 of file visual_collision_entity.h.

References _CeilMode.

Referenced by NL3D::CVisualCollisionEntityUser::getCeilMode().

bool NL3D::CVisualCollisionEntity::getGroundMode (  )  const [inline]

Definition at line 87 of file visual_collision_entity.h.

References _GroundMode.

Referenced by NL3D::CVisualCollisionEntityUser::getGroundMode().

CTrianglePatch * NL3D::CVisualCollisionEntity::getPatchTriangleUnderUs ( const CVector pos,
CVector res 
) [private]
bool NL3D::CVisualCollisionEntity::getSnapToRenderedTesselation (  )  const [inline]
bool NL3D::CVisualCollisionEntity::getStaticLightSetup ( NLMISC::CRGBA  sunAmbient,
const CVector pos,
std::vector< CPointLightInfluence > &  pointLightList,
uint8 sunContribution,
NLMISC::CRGBA localAmbient 
)

Get the static Light Setup, using landscape under us.

append lights to pointLightList. NB: if find no landscape faces, don't modify pointLightList, set sunContribution=255, and return false Else, use CPatch::TileLightInfluences to get lights, and use CPatch::Lumels to get sunContribution. NB: because CPatch::Lumels encode the gouraud shading on the surface, returning lumelValue will darken the object too much. To avoid this, the sunContribution is raised to a power (0..1). See CVisualCollisionManager::setSunContributionPower(). Default is 0.5

Definition at line 525 of file visual_collision_entity.cpp.

References NL3D::CVisualCollisionManager::_Landscape, _Owner, NL3D::CVisualCollisionManager::_SunContributionLUT, computeUvForPos(), getPatchTriangleUnderUs(), and NL3D::CTrianglePatch::PatchId.

Referenced by NL3D::CInstanceLighter::computeSunContribution(), and NL3D::CVisualCollisionEntityUser::getStaticLightSetup().

bool NL3D::CVisualCollisionEntity::getSurfaceInfo ( const CVector pos,
CSurfaceInfo info 
)

Get surface informations.

pos is checked with polygons that are at least (cache dependent) at +- 10m in altitude.

Parameters:
info will be filled with surface informations if the method returns true.
Returns:
true if the surface has been found and informations has been filled.

Definition at line 563 of file visual_collision_entity.cpp.

References NL3D::CVisualCollisionManager::_Landscape, _Owner, computeUvForPos(), getPatchTriangleUnderUs(), NL3D::CTileBank::getTileSet(), NL3D::CTileBank::getTileXRef(), H_AUTO, NL_TILE_ELM_LAYER_EMPTY, NL3D::CTrianglePatch::PatchId, NL3D::CTileSet::SurfaceData, NL3D::CTileElement::Tile, and NL3D::CSurfaceInfo::UserSurfaceData.

Referenced by NL3D::CVisualCollisionEntityUser::getSurfaceInfo().

void NL3D::CVisualCollisionEntity::setCeilMode ( bool  ceilMode  )  [inline]

If ceilMode is true, the entity is snapped on faces with normal.z < 0.

Default is false. NB: if both groundMode and ceilMode are false, snapToGround is a no-op.

Definition at line 84 of file visual_collision_entity.h.

References _CeilMode.

Referenced by NL3D::CVisualCollisionEntityUser::setCeilMode().

void NL3D::CVisualCollisionEntity::setGroundMode ( bool  groundMode  )  [inline]

If groundMode is true, the entity is snapped on faces with normal.z > 0.

Default is true. NB: if both groundMode and ceilMode are false, snapToGround is a no-op.

Definition at line 78 of file visual_collision_entity.h.

References _GroundMode.

Referenced by NL3D::CVisualCollisionEntityUser::setGroundMode().

void NL3D::CVisualCollisionEntity::setSnapToRenderedTesselation ( bool  snapMode  )  [inline]

By default, the visual collision entity is snapped on rendered/geomorphed tesselation (true).

Use this method to change this behavior. if false, the entity is snapped to the tile level tesselation according to noise etc...

Definition at line 95 of file visual_collision_entity.h.

References _SnapToRenderedTesselation.

Referenced by NL3D::CVisualCollisionEntityUser::setSnapToRenderedTesselation().

bool NL3D::CVisualCollisionEntity::snapToGround ( CVector pos,
CVector normal 
)

Snap the entity onto the ground.

pos.z is modified so that it lies on the ground, according to rendered landscapes and meshes. pos is checked with polygons that are at least (cache dependent) at +- 10m in altitude.

Parameters:
normal the ret normal of where it is snapped. NB: if return false, not modified.
Returns:
true if pos.z has been modified (sometimes it may not find a solution).

Definition at line 209 of file visual_collision_entity.cpp.

References _SnapToRenderedTesselation, getPatchTriangleUnderUs(), NLMISC::CVector::normalize(), snapToLandscapeCurrentTesselation(), NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, and NLMISC::CTriangle::V2.

bool NL3D::CVisualCollisionEntity::snapToGround ( CVector pos  ) 

Snap the entity onto the ground.

pos.z is modified so that it lies on the ground, according to rendered landscapes and meshes. see setSnapToRenderedTesselation() option. pos is checked with polygons that are at least (cache dependent) at +- 10m in altitude.

Returns:
true if pos.z has been modified (sometimes it may not find a solution).

Definition at line 85 of file visual_collision_entity.cpp.

Referenced by NL3D::CVisualCollisionEntityUser::snapToGround().

void NL3D::CVisualCollisionEntity::snapToLandscapeCurrentTesselation ( CVector pos,
const CTrianglePatch tri 
) [private]

snap to current rendered tesselation.

Definition at line 259 of file visual_collision_entity.cpp.

References NL3D::CVisualCollisionManager::_Landscape, _Owner, computeUvForPos(), NL3D::CTrianglePatch::PatchId, and NLMISC::CVector::z.

Referenced by snapToGround().

void NL3D::CVisualCollisionEntity::testComputeLandscape ( const CVector pos  )  [private]

test if the new position is outside the preceding setuped bbox, and then compute tiles infos around the position.

Definition at line 401 of file visual_collision_entity.cpp.

References _CurrentBBoxValidity, doComputeLandscape(), NLMISC::CAABBox::getHalfSize(), NLMISC::CAABBox::include(), and NLMISC::CVector::Null.

Referenced by getPatchTriangleUnderUs().

bool NL3D::CVisualCollisionEntity::triangleIntersect ( CTriangle tri,
const CVector pos0,
const CVector pos1,
CVector hit 
) [private]
bool NL3D::CVisualCollisionEntity::triangleIntersect2DCeil ( CTriangle tri,
const CVector pos0 
) [static, private]
bool NL3D::CVisualCollisionEntity::triangleIntersect2DGround ( CTriangle tri,
const CVector pos0 
) [static, private]

Fast "2D" test of a triangle against ray P0 P1.

Definition at line 297 of file visual_collision_entity.cpp.

References NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, NLMISC::CTriangle::V2, NLMISC::CVector::x, and NLMISC::CVector::y.

Referenced by triangleIntersect().


Member Data Documentation

The current BBox where we don't need to recompute the patchQuadBlocks if the entity is in.

Definition at line 169 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity(), doComputeLandscape(), and testComputeLandscape().

A quadgrid of chainlist of tileId (CVisualTileDescNode), which are around the entity.

Definition at line 167 of file visual_collision_entity.h.

Referenced by doComputeLandscape(), getPatchTriangleUnderUs(), and ~CVisualCollisionEntity().

Definition at line 172 of file visual_collision_entity.h.

Referenced by getPatchTriangleUnderUs().

Definition at line 173 of file visual_collision_entity.h.

Referenced by getPatchTriangleUnderUs().

Definition at line 174 of file visual_collision_entity.h.

Referenced by getPatchTriangleUnderUs().

Array of quadBlock which are around the entity.

NB: plain vector, because not so big (ptrs). NB: reserve to a big size (64), so reallocation rarely occurs. NB: this array is sorted in ascending order (comparison of CPatchBlockIdent).

Definition at line 165 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity(), displayDebugGrid(), doComputeLandscape(), getPatchTriangleUnderUs(), and ~CVisualCollisionEntity().

Default capacity of _PatchQuadBlocks.

Definition at line 155 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity().

This is the temp array of BlockIds filled by landscape search.

Definition at line 157 of file visual_collision_entity.h.

Referenced by doComputeLandscape().

This is the temp array of PatchBlocks ptr.

Definition at line 159 of file visual_collision_entity.h.

Referenced by doComputeLandscape().

This is the radius of the bbox around the entity where we have correct collisions: 10m.

Definition at line 110 of file visual_collision_entity.h.

Referenced by doComputeLandscape().

Same as BBoxRadius, but for z value.

This later should be greater because of NLPACS surface quadtree imprecision. 20m NB: Because of caching, if the pos.z passed to snapToGround() is outside of the currentBBox with BBoxRadiuZ/2 (=> 10m), then the bbox is recomputed. Hence, this actually means that a pos is checked with patchs that are at least at +- 10m in altitude.

Definition at line 117 of file visual_collision_entity.h.

Referenced by doComputeLandscape().


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

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