#include <visual_collision_manager.h>
Nevrax France
Definition at line 70 of file visual_collision_manager.h.
|
Definition at line 201 of file visual_collision_manager.h. |
|
Constructor.
Definition at line 53 of file visual_collision_manager.cpp. References _MeshIdPool, _MeshQuadGrid, NL3D::CQuadGrid< CMeshCol * >::create(), NL3D::MeshColQuadGridEltSize, NL3D::MeshColQuadGridSize, NL3D::PatchQuadBlockAllocatorBlockSize, setSunContributionPower(), and NL3D::TileDescNodeAllocatorBlockSize.
00053 : 00054 _TileDescNodeAllocator(TileDescNodeAllocatorBlockSize), 00055 _PatchQuadBlockAllocator(PatchQuadBlockAllocatorBlockSize) 00056 { 00057 _Landscape= NULL; 00058 00059 // Default. 00060 setSunContributionPower(0.5f, 0.5f); 00061 00062 // init the mesh quadGrid 00063 _MeshQuadGrid.create(MeshColQuadGridSize, MeshColQuadGridEltSize); 00064 // valid id start at 1 00065 _MeshIdPool= 1; 00066 } |
|
Definition at line 68 of file visual_collision_manager.cpp.
00069 { 00070 _Landscape= NULL; 00071 } |
|
Add a Mesh to the collision manager. For now it is used only for Camera Collision number of vertices and number of triangles must not exceed 65535
Definition at line 401 of file visual_collision_manager.cpp. References _MeshIdPool, _MeshQuadGrid, _Meshs, NL3D::CVisualCollisionManager::CMeshCol::BBox, NL3D::CVisualCollisionManager::CMeshCol::build(), NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), NL3D::CQuadGrid< CMeshCol * >::insert(), NL3D::CVisualCollisionManager::CMeshCol::QuadGridIt, uint, and uint32. Referenced by NL3D::CVisualCollisionManagerUser::addMeshCollision().
00402 { 00403 if(vertices.empty() || triangles.empty()) 00404 return 0; 00405 // triangles id are stored in uint16 form. so their should not be more than 65535*3 indices 00406 if(vertices.size()>65535 || triangles.size()>65535*3) 00407 return 0; 00408 00409 // allocate a new id 00410 uint32 id= _MeshIdPool++; 00411 00412 // insert in map 00413 CMeshCol &mesh= _Meshs[id]; 00414 00415 // Build the col mesh 00416 mesh.build(vertices, triangles); 00417 00418 // insert in quadGrid 00419 mesh.QuadGridIt= _MeshQuadGrid.insert(mesh.BBox.getMin(), mesh.BBox.getMax(), &mesh); 00420 00421 return id; 00422 } |
|
create an entity. NB: CVisualCollisionManager do not owns this ptr for now, and you must delete it with deleteEntity(). NB: CVisualCollisionEntity are no more valid when this manager is deleted. Definition at line 82 of file visual_collision_manager.cpp. References CVisualCollisionEntity. Referenced by NL3D::CInstanceLighter::computeSunContribution().
00083 { 00084 return new CVisualCollisionEntity(this); 00085 } |
|
delete an entity. Definition at line 89 of file visual_collision_manager.cpp. Referenced by NL3D::CInstanceLighter::computeSunContribution(), and NL3D::CVisualCollisionEntityUser::~CVisualCollisionEntityUser().
00090 {
00091 delete entity;
00092 }
|
|
Definition at line 114 of file visual_collision_manager.cpp. References _PatchQuadBlockAllocator, and NLMISC::CBlockMemory< CPatchQuadBlock >::free(). Referenced by NL3D::CVisualCollisionEntity::doComputeLandscape(), and NL3D::CVisualCollisionEntity::~CVisualCollisionEntity().
00115 { 00116 _PatchQuadBlockAllocator.free(ptr); 00117 } |
|
Definition at line 102 of file visual_collision_manager.cpp. References _TileDescNodeAllocator, and NLMISC::CBlockMemory< CVisualTileDescNode >::free(). Referenced by NL3D::CLandscapeCollisionGrid::clear().
00103 { 00104 _TileDescNodeAllocator.free(ptr); 00105 } |
|
Get Typical Camera 3rd person collision. For landscape, it is done only against TileFaces (ie only under approx 50 m) return a [0,1] value. 0 => collision at start. 1 => no collision.
Definition at line 144 of file visual_collision_manager.cpp. References _MeshQuadGrid, NL3D::CCameraCol::BBox, NL3D::CQuadGrid< CMeshCol * >::begin(), NL3D::CCameraCol::build(), NL3D::CQuadGrid< CMeshCol * >::end(), NLMISC::CAABBox::getMax(), NLMISC::CAABBox::getMin(), min, and NL3D::CQuadGrid< CMeshCol * >::select(). Referenced by NL3D::CVisualCollisionManagerUser::getCameraCollision().
00145 { 00146 float minCol= 1; 00147 00148 // try col with landscape 00149 if(_Landscape) 00150 { 00151 minCol= _Landscape->getCameraCollision(start, end, radius, cone); 00152 } 00153 00154 // try col with meshes 00155 CCameraCol camCol; 00156 camCol.build(start, end, radius, cone); 00157 _MeshQuadGrid.select(camCol.BBox.getMin(), camCol.BBox.getMax()); 00158 // try to intersect with any meshs 00159 CQuadGrid<CMeshCol*>::CIterator it; 00160 for(it= _MeshQuadGrid.begin();it!=_MeshQuadGrid.end();it++) 00161 { 00162 float meshCol= (*it)->getCameraCollision(camCol); 00163 // Keep only yhe smallest value 00164 minCol= min(minCol, meshCol); 00165 } 00166 00167 return minCol; 00168 } |
|
Definition at line 108 of file visual_collision_manager.cpp. References _PatchQuadBlockAllocator, and NLMISC::CBlockMemory< CPatchQuadBlock >::allocate(). Referenced by NL3D::CVisualCollisionEntity::doComputeLandscape().
00109 { 00110 return _PatchQuadBlockAllocator.allocate(); 00111 } |
|
Definition at line 96 of file visual_collision_manager.cpp. References _TileDescNodeAllocator, and NLMISC::CBlockMemory< CVisualTileDescNode >::allocate(). Referenced by NL3D::CLandscapeCollisionGrid::addQuadToGrid().
00097 { 00098 return _TileDescNodeAllocator.allocate(); 00099 } |
|
Remove a Mesh from the collision manager. Definition at line 425 of file visual_collision_manager.cpp. References _MeshQuadGrid, _Meshs, NL3D::CQuadGrid< CMeshCol * >::erase(), and uint. Referenced by NL3D::CVisualCollisionManagerUser::removeMeshCollision().
00426 { 00427 // find in map 00428 TMeshColMap::iterator it= _Meshs.find(id); 00429 if(it!=_Meshs.end()) 00430 { 00431 // remove from the quadgrid 00432 _MeshQuadGrid.erase(it->second.QuadGridIt); 00433 // remove from the map 00434 _Meshs.erase(it); 00435 } 00436 } |
|
setup the landscape used for this collision manager. ptr is kept, and manager and all entities must be cleared when the landscape is deleted. Definition at line 75 of file visual_collision_manager.cpp. Referenced by NL3D::CInstanceLighter::computeSunContribution(), and NL3D::CVisualCollisionManagerUser::setLandscape().
00076 { 00077 _Landscape= landscape; 00078 } |
|
for CVisualCollisionEntity::getStaticLightSetup(). Build a lighting table to remap sun contribution from landscape to sun contribution for objects. The value remap the landscape sun contribution (0 ~ 1) to an object sun contribution (0 ~1) using the following formula:objectSunContribution = min ( powf ( landscapeSunContribution / maxThreshold, power ), 1 ); Default is 0.5 (=> sqrt) for power and 0.5 for maxThreshold. Definition at line 121 of file visual_collision_manager.cpp. References _SunContributionLUT, NLMISC::clamp(), sint, and uint. Referenced by CVisualCollisionManager(), and NL3D::CVisualCollisionManagerUser::setSunContributionPower().
00122 { 00123 NLMISC::clamp(power, 0.f, 1.f); 00124 00125 for(uint i=0; i<256; i++) 00126 { 00127 float f= i/255.f; 00128 f = powf(f/maxThreshold, power); 00129 sint uf= (sint)floor(255*f); 00130 NLMISC::clamp(uf, 0, 255); 00131 _SunContributionLUT[i]= uf; 00132 } 00133 00134 } |
|
Definition at line 211 of file visual_collision_manager.h. |
|
Definition at line 210 of file visual_collision_manager.h. Referenced by createEntity(). |
|
The landscape used to generate tiles, and to snap position to tesselated ground.
Definition at line 130 of file visual_collision_manager.h. Referenced by NL3D::CVisualCollisionEntity::doComputeLandscape(), NL3D::CVisualCollisionEntity::getPatchTriangleUnderUs(), NL3D::CVisualCollisionEntity::getStaticLightSetup(), NL3D::CVisualCollisionEntity::getSurfaceInfo(), and NL3D::CVisualCollisionEntity::snapToLandscapeCurrentTesselation(). |
|
Definition at line 206 of file visual_collision_manager.h. Referenced by addMeshCollision(), and CVisualCollisionManager(). |
|
Definition at line 204 of file visual_collision_manager.h. Referenced by addMeshCollision(), CVisualCollisionManager(), getCameraCollision(), and removeMeshCollision(). |
|
Definition at line 202 of file visual_collision_manager.h. Referenced by addMeshCollision(), and removeMeshCollision(). |
|
Definition at line 134 of file visual_collision_manager.h. Referenced by deletePatchQuadBlock(), and newPatchQuadBlock(). |
|
Definition at line 222 of file visual_collision_manager.h. Referenced by NL3D::CVisualCollisionEntity::getStaticLightSetup(), and setSunContributionPower(). |
|
Allocators.
Definition at line 133 of file visual_collision_manager.h. Referenced by deleteVisualTileDescNode(), and newVisualTileDescNode(). |