OpenSceneGraph 3.6.5
osgSim::LineOfSight Class Reference

Helper class for setting up and acquiring line of sight intersections with terrain. More...

#include <LineOfSight>

Classes

struct  LOS

Public Types

typedef std::vector< osg::Vec3dIntersections

Public Member Functions

 LineOfSight ()
void clear ()
 Clear the internal LOS List so it contains no line of sight tests.
unsigned int addLOS (const osg::Vec3d &start, const osg::Vec3d &end)
 Add a line of sight test, consisting of start and end point.
unsigned int getNumLOS () const
 Get the number of line of sight tests.
void setStartPoint (unsigned int i, const osg::Vec3d &start)
 Set the start point of single line of sight test.
const osg::Vec3dgetStartPoint (unsigned int i) const
 Get the start point of single line of sight test.
void setEndPoint (unsigned int i, const osg::Vec3d &end)
 Set the end point of single line of sight test.
const osg::Vec3dgetEndPoint (unsigned int i) const
 Get the end point of single line of sight test.
const IntersectionsgetIntersections (unsigned int i) const
 Get the intersection points for a single line of sight test.
void computeIntersections (osg::Node *scene, osg::Node::NodeMask traversalMask=0xffffffff)
 Compute the LOS intersections with the specified scene graph.
void clearDatabaseCache ()
 Clear the database cache.
void setDatabaseCacheReadCallback (DatabaseCacheReadCallback *dcrc)
 Set the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.
DatabaseCacheReadCallbackgetDatabaseCacheReadCallback ()
 Get the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.

Static Public Member Functions

static Intersections computeIntersections (osg::Node *scene, const osg::Vec3d &start, const osg::Vec3d &end, osg::Node::NodeMask traversalMask=0xffffffff)
 Compute the intersection between the specified scene graph and a single LOS start,end pair.

Protected Types

typedef std::vector< LOSLOSList

Protected Attributes

LOSList _LOSList
osg::ref_ptr< DatabaseCacheReadCallback_dcrc
osgUtil::IntersectionVisitor _intersectionVisitor

Detailed Description

Helper class for setting up and acquiring line of sight intersections with terrain.

By default assigns a osgSim::DatabaseCacheReadCallback that enables automatic loading of external PagedLOD tiles to ensure that the highest level of detail is used in intersections. This automatic loading of tiles is done by the intersection traversal that is done within the computeIntersections(..) method, so can result in long intersection times when external tiles have to be loaded. The external loading of tiles can be disabled by removing the read callback, this is done by calling the setDatabaseCacheReadCallback(DatabaseCacheReadCallback*) method with a value of 0.

Member Typedef Documentation

◆ Intersections

◆ LOSList

typedef std::vector<LOS> osgSim::LineOfSight::LOSList
protected

Constructor & Destructor Documentation

◆ LineOfSight()

osgSim::LineOfSight::LineOfSight ( )

Member Function Documentation

◆ addLOS()

unsigned int osgSim::LineOfSight::addLOS ( const osg::Vec3d & start,
const osg::Vec3d & end )

Add a line of sight test, consisting of start and end point.

Returns the index number of the newly adding LOS test.

◆ clear()

void osgSim::LineOfSight::clear ( )

Clear the internal LOS List so it contains no line of sight tests.

◆ clearDatabaseCache()

void osgSim::LineOfSight::clearDatabaseCache ( )
inline

Clear the database cache.

References _dcrc.

◆ computeIntersections() [1/2]

Intersections osgSim::LineOfSight::computeIntersections ( osg::Node * scene,
const osg::Vec3d & start,
const osg::Vec3d & end,
osg::Node::NodeMask traversalMask = 0xffffffff )
static

Compute the intersection between the specified scene graph and a single LOS start,end pair.

Returns an IntersectionList, of all the points intersected.

◆ computeIntersections() [2/2]

void osgSim::LineOfSight::computeIntersections ( osg::Node * scene,
osg::Node::NodeMask traversalMask = 0xffffffff )

Compute the LOS intersections with the specified scene graph.

The results are all stored in the form of Intersections list, one per LOS test.

◆ getDatabaseCacheReadCallback()

DatabaseCacheReadCallback * osgSim::LineOfSight::getDatabaseCacheReadCallback ( )
inline

Get the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.

References _dcrc.

◆ getEndPoint()

const osg::Vec3d & osgSim::LineOfSight::getEndPoint ( unsigned int i) const
inline

Get the end point of single line of sight test.

References _LOSList.

◆ getIntersections()

const Intersections & osgSim::LineOfSight::getIntersections ( unsigned int i) const
inline

Get the intersection points for a single line of sight test.

References _LOSList.

◆ getNumLOS()

unsigned int osgSim::LineOfSight::getNumLOS ( ) const
inline

Get the number of line of sight tests.

References _LOSList.

◆ getStartPoint()

const osg::Vec3d & osgSim::LineOfSight::getStartPoint ( unsigned int i) const
inline

Get the start point of single line of sight test.

References _LOSList.

◆ setDatabaseCacheReadCallback()

void osgSim::LineOfSight::setDatabaseCacheReadCallback ( DatabaseCacheReadCallback * dcrc)

Set the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgraphs.

Note, if you have multiple LineOfSight or HeightAboveTerrain objects in use at one time then you should share a single DatabaseCacheReadCallback between all of them.

◆ setEndPoint()

void osgSim::LineOfSight::setEndPoint ( unsigned int i,
const osg::Vec3d & end )
inline

Set the end point of single line of sight test.

References _LOSList.

◆ setStartPoint()

void osgSim::LineOfSight::setStartPoint ( unsigned int i,
const osg::Vec3d & start )
inline

Set the start point of single line of sight test.

References _LOSList.

Member Data Documentation

◆ _dcrc

osg::ref_ptr<DatabaseCacheReadCallback> osgSim::LineOfSight::_dcrc
protected

◆ _intersectionVisitor

osgUtil::IntersectionVisitor osgSim::LineOfSight::_intersectionVisitor
protected

◆ _LOSList

LOSList osgSim::LineOfSight::_LOSList
protected

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

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.