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

An entity created by CVisualCollisionManager. More...

#include <visual_collision_entity.h>

List of all members.

Landscape part.

bool triangleIntersect2DGround (CTriangle &tri, const CVector &pos0)
 Fast "2D" test of a triangle against ray P0 P1. More...

bool triangleIntersect2DCeil (CTriangle &tri, const CVector &pos0)
bool triangleIntersect (CTriangle &tri, const CVector &pos0, const CVector &pos1, CVector &hit)
 Fast "2D" test of a triangle against ray P0 P1. More...

void testComputeLandscape (const CVector &pos)
 test if the new position is outside the preceding setuped bbox, and then compute tiles infos around the position. More...

void doComputeLandscape (const CVector &pos)
 compute tiles infos around the position. More...

void snapToLandscapeCurrentTesselation (CVector &pos, const CTrianglePatch &tri)
 snap to current rendered tesselation. More...

CTrianglePatchgetPatchTriangleUnderUs (const CVector &pos, CVector &res)
 return the best trianglePatch under what we are. More...

std::vector< CPatchQuadBlock * > _PatchQuadBlocks
 Array of quadBlock which are around the entity. More...

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

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

bool _LastGPTValid
 Cache for getPatchTriangleUnderUs(). More...

CVector _LastGPTPosInput
CVector _LastGPTPosOutput
CTrianglePatch _LastGPTTrianglePatch
void computeUvForPos (const CTrianglePatch &tri, const CVector &pos, CUV &uv)
 given a CTrianglePatch, compute Patch uv according to position. More...

const uint32 _StartPatchQuadBlockSize = 64
 Default capacity of _PatchQuadBlocks. More...

std::vector< CPatchBlockIdent_TmpBlockIds
 This is the temp array of BlockIds filled by landscape search. More...

std::vector< CPatchQuadBlock * > _TmpPatchQuadBlocks
 This is the temp array of PatchBlocks ptr. More...


Public Methods

 CVisualCollisionEntity (CVisualCollisionManager *owner)
 Constructor. More...

 ~CVisualCollisionEntity ()
bool snapToGround (CVector &pos)
 Snap the entity onto the ground. More...

bool snapToGround (CVector &pos, CVector &normal)
 Snap the entity onto the ground. More...

void setGroundMode (bool groundMode)
 If groundMode is true, the entity is snapped on faces with normal.z > 0. More...

void setCeilMode (bool ceilMode)
 If ceilMode is true, the entity is snapped on faces with normal.z < 0. More...

bool getGroundMode () const
bool getCeilMode () const
void setSnapToRenderedTesselation (bool snapMode)
 By default, the visual collision entity is snapped on rendered/geomorphed tesselation (true). More...

bool getSnapToRenderedTesselation () const
bool getSurfaceInfo (const CVector &pos, CSurfaceInfo &info)
 Get surface informations. More...

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

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


Static Public Attributes

Parameters.
const float BBoxRadius = 10
 This is the radius of the bbox around the entity where we have correct collisions: 10m. More...

const float BBoxRadiusZ = 20
 Same as BBoxRadius, but for z value. More...


Private Attributes

CVisualCollisionManager_Owner
bool _CeilMode
bool _GroundMode
bool _SnapToRenderedTesselation


Detailed Description

An entity created by CVisualCollisionManager.

Author:
Lionel Berenguier , Nevrax France
Date:
2001

Definition at line 50 of file visual_collision_entity.h.


Constructor & Destructor Documentation

NL3D::CVisualCollisionEntity::CVisualCollisionEntity CVisualCollisionManager   owner
 

Constructor.

Definition at line 55 of file visual_collision_entity.cpp.

References _CeilMode, _CurrentBBoxValidity, _GroundMode, _LastGPTValid, _Owner, _PatchQuadBlocks, _SnapToRenderedTesselation, and _StartPatchQuadBlockSize.

NL3D::CVisualCollisionEntity::~CVisualCollisionEntity  
 

Definition at line 71 of file visual_collision_entity.cpp.

References _LandscapeQuadGrid, _Owner, and _PatchQuadBlocks.


Member Function Documentation

void NL3D::CVisualCollisionEntity::computeUvForPos const CTrianglePatch   tri,
const CVector &    pos,
CUV &    uv
[static, private]
 

given a CTrianglePatch, compute Patch uv according to position.

Definition at line 239 of file visual_collision_entity.cpp.

Referenced by getStaticLightSetup, getSurfaceInfo, and snapToLandscapeCurrentTesselation.

void NL3D::CVisualCollisionEntity::displayDebugGrid IDriver   drv const
 

Draw lines for the landscape quadgrid collision faces under us.

Definition at line 600 of file visual_collision_entity.cpp.

References _PatchQuadBlocks, NL_PATCH_BLOCK_MAX_VERTEX, s, and t.

void NL3D::CVisualCollisionEntity::doComputeLandscape const CVector &    pos [private]
 

compute tiles infos around the position.

Definition at line 403 of file visual_collision_entity.cpp.

References _CurrentBBoxValidity, _LandscapeQuadGrid, _Owner, _PatchQuadBlocks, _TmpBlockIds, _TmpPatchQuadBlocks, BBoxRadius, and BBoxRadiusZ.

Referenced by testComputeLandscape.

bool NL3D::CVisualCollisionEntity::getCeilMode   const [inline]
 

Definition at line 90 of file visual_collision_entity.h.

References _CeilMode.

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

Definition at line 89 of file visual_collision_entity.h.

References _GroundMode.

CTrianglePatch * NL3D::CVisualCollisionEntity::getPatchTriangleUnderUs const CVector &    pos,
CVector &    res
[private]
 

return the best trianglePatch under what we are.

NULL if not found. Ptr is valid until next call to getPatchTriangleUnderUs() Actually return NULL or &_LastTrianglePatch;

Definition at line 95 of file visual_collision_entity.cpp.

References _LandscapeQuadGrid, _LastGPTPosInput, _LastGPTPosOutput, _LastGPTTrianglePatch, _LastGPTValid, _Owner, _PatchQuadBlocks, nlassert, res, NLMISC::sqr, testComputeLandscape, and triangleIntersect.

Referenced by getStaticLightSetup, getSurfaceInfo, and snapToGround.

bool NL3D::CVisualCollisionEntity::getSnapToRenderedTesselation   const [inline]
 

Definition at line 98 of file visual_collision_entity.h.

References _SnapToRenderedTesselation.

bool NL3D::CVisualCollisionEntity::getStaticLightSetup 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 516 of file visual_collision_entity.cpp.

References _Owner, computeUvForPos, getPatchTriangleUnderUs, res, and NLMISC::CRGBA::set.

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 554 of file visual_collision_entity.cpp.

References _Owner, computeUvForPos, getPatchTriangleUnderUs, NL_TILE_ELM_LAYER_EMPTY, res, and type.

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 86 of file visual_collision_entity.h.

References _CeilMode.

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 80 of file visual_collision_entity.h.

References _GroundMode.

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 97 of file visual_collision_entity.h.

References _SnapToRenderedTesselation.

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 204 of file visual_collision_entity.cpp.

References getPatchTriangleUnderUs, res, and snapToLandscapeCurrentTesselation.

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 86 of file visual_collision_entity.cpp.

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

snap to current rendered tesselation.

Definition at line 253 of file visual_collision_entity.cpp.

References _Owner, and computeUvForPos.

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 392 of file visual_collision_entity.cpp.

References _CurrentBBoxValidity, and doComputeLandscape.

Referenced by getPatchTriangleUnderUs.

bool NL3D::CVisualCollisionEntity::triangleIntersect CTriangle &    tri,
const CVector &    pos0,
const CVector &    pos1,
CVector &    hit
[private]
 

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

Definition at line 358 of file visual_collision_entity.cpp.

References _CeilMode, _GroundMode, triangleIntersect2DCeil, and triangleIntersect2DGround.

Referenced by getPatchTriangleUnderUs.

bool NL3D::CVisualCollisionEntity::triangleIntersect2DCeil CTriangle &    tri,
const CVector &    pos0
[private]
 

Definition at line 328 of file visual_collision_entity.cpp.

Referenced by triangleIntersect.

bool NL3D::CVisualCollisionEntity::triangleIntersect2DGround CTriangle &    tri,
const CVector &    pos0
[private]
 

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

Definition at line 291 of file visual_collision_entity.cpp.

Referenced by triangleIntersect.


Member Data Documentation

bool NL3D::CVisualCollisionEntity::_CeilMode [private]
 

Definition at line 149 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity, getCeilMode, setCeilMode, and triangleIntersect.

CAABBox NL3D::CVisualCollisionEntity::_CurrentBBoxValidity [private]
 

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

Definition at line 171 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity, doComputeLandscape, and testComputeLandscape.

bool NL3D::CVisualCollisionEntity::_GroundMode [private]
 

Definition at line 150 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity, getGroundMode, setGroundMode, and triangleIntersect.

CLandscapeCollisionGrid NL3D::CVisualCollisionEntity::_LandscapeQuadGrid [private]
 

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

Definition at line 169 of file visual_collision_entity.h.

Referenced by doComputeLandscape, getPatchTriangleUnderUs, and ~CVisualCollisionEntity.

CVector NL3D::CVisualCollisionEntity::_LastGPTPosInput [private]
 

Definition at line 174 of file visual_collision_entity.h.

Referenced by getPatchTriangleUnderUs.

CVector NL3D::CVisualCollisionEntity::_LastGPTPosOutput [private]
 

Definition at line 175 of file visual_collision_entity.h.

Referenced by getPatchTriangleUnderUs.

CTrianglePatch NL3D::CVisualCollisionEntity::_LastGPTTrianglePatch [private]
 

Definition at line 176 of file visual_collision_entity.h.

Referenced by getPatchTriangleUnderUs.

bool NL3D::CVisualCollisionEntity::_LastGPTValid [private]
 

Cache for getPatchTriangleUnderUs().

Definition at line 173 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity, and getPatchTriangleUnderUs.

CVisualCollisionManager* NL3D::CVisualCollisionEntity::_Owner [private]
 

Definition at line 147 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity, doComputeLandscape, getPatchTriangleUnderUs, getStaticLightSetup, getSurfaceInfo, snapToLandscapeCurrentTesselation, and ~CVisualCollisionEntity.

std::vector<CPatchQuadBlock*> NL3D::CVisualCollisionEntity::_PatchQuadBlocks [private]
 

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 167 of file visual_collision_entity.h.

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

bool NL3D::CVisualCollisionEntity::_SnapToRenderedTesselation [private]
 

Definition at line 151 of file visual_collision_entity.h.

Referenced by CVisualCollisionEntity, getSnapToRenderedTesselation, and setSnapToRenderedTesselation.

const uint32 NL3D::CVisualCollisionEntity::_StartPatchQuadBlockSize = 64 [static, private]
 

Default capacity of _PatchQuadBlocks.

Definition at line 49 of file visual_collision_entity.cpp.

Referenced by CVisualCollisionEntity.

vector< CPatchBlockIdent > NL3D::CVisualCollisionEntity::_TmpBlockIds [static, private]
 

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

Definition at line 50 of file visual_collision_entity.cpp.

Referenced by doComputeLandscape.

vector< CPatchQuadBlock * > NL3D::CVisualCollisionEntity::_TmpPatchQuadBlocks [static, private]
 

This is the temp array of PatchBlocks ptr.

Definition at line 51 of file visual_collision_entity.cpp.

Referenced by doComputeLandscape.

const float NL3D::CVisualCollisionEntity::BBoxRadius = 10 [static]
 

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

Definition at line 47 of file visual_collision_entity.cpp.

Referenced by doComputeLandscape.

const float NL3D::CVisualCollisionEntity::BBoxRadiusZ = 20 [static]
 

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 48 of file visual_collision_entity.cpp.

Referenced by doComputeLandscape.


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