OpenSceneGraph 3.6.5
LineOfSight
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGSIM_LINEOFSIGHT
15#define OSGSIM_LINEOFSIGHT 1
16
18
19#include <osgSim/Export>
20
21namespace osgSim {
22
24{
25 public:
27
28 void setMaximumNumOfFilesToCache(unsigned int maxNumFilesToCache) { _maxNumFilesToCache = maxNumFilesToCache; }
29 unsigned int getMaximumNumOfFilesToCache() const { return _maxNumFilesToCache; }
30
32
34
35 virtual osg::ref_ptr<osg::Node> readNodeFile(const std::string& filename);
36
37 protected:
38
39 typedef std::map<std::string, osg::ref_ptr<osg::Node> > FileNameSceneMap;
40
41 unsigned int _maxNumFilesToCache;
42 OpenThreads::Mutex _mutex;
44};
45
55{
56 public :
57
59
61 void clear();
62
64 unsigned int addLOS(const osg::Vec3d& start, const osg::Vec3d& end);
65
67 unsigned int getNumLOS() const { return _LOSList.size(); }
68
70 void setStartPoint(unsigned int i, const osg::Vec3d& start) { _LOSList[i]._start = start; }
71
73 const osg::Vec3d& getStartPoint(unsigned int i) const { return _LOSList[i]._start; }
74
76 void setEndPoint(unsigned int i, const osg::Vec3d& end) { _LOSList[i]._end = end; }
77
79 const osg::Vec3d& getEndPoint(unsigned int i) const { return _LOSList[i]._end; }
80
81 typedef std::vector<osg::Vec3d> Intersections;
82
84 const Intersections& getIntersections(unsigned int i) const { return _LOSList[i]._intersections; }
85
88 void computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask=0xffffffff);
89
91 static Intersections computeIntersections(osg::Node* scene, const osg::Vec3d& start, const osg::Vec3d& end, osg::Node::NodeMask traversalMask=0xffffffff);
92
93
95 void clearDatabaseCache() { if (_dcrc.valid()) _dcrc->clearDatabaseCache(); }
96
101
104
105 protected :
106
107 struct LOS
108 {
109 LOS(const osg::Vec3d& start, const osg::Vec3d& end):
110 _start(start),
111 _end(end) {}
112
113
117 };
118
119 typedef std::vector<LOS> LOSList;
121
124
125};
126
127}
128
129#endif
The osgSim library is a NodeKit that extends the core scene graph to support nodes and drawables that...
Definition BlinkSequence:27
Base class for all internal nodes in the scene graph.
Definition Node:72
unsigned int NodeMask
This is a set of bits (flags) that represent the Node.
Definition Node:363
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
Definition LineOfSight:24
unsigned int getMaximumNumOfFilesToCache() const
Definition LineOfSight:29
OpenThreads::Mutex _mutex
Definition LineOfSight:42
FileNameSceneMap _filenameSceneMap
Definition LineOfSight:43
void setMaximumNumOfFilesToCache(unsigned int maxNumFilesToCache)
Definition LineOfSight:28
unsigned int _maxNumFilesToCache
Definition LineOfSight:41
virtual osg::ref_ptr< osg::Node > readNodeFile(const std::string &filename)
std::map< std::string, osg::ref_ptr< osg::Node > > FileNameSceneMap
Definition LineOfSight:39
osgUtil::IntersectionVisitor _intersectionVisitor
Definition LineOfSight:123
std::vector< osg::Vec3d > Intersections
Definition LineOfSight:81
void setDatabaseCacheReadCallback(DatabaseCacheReadCallback *dcrc)
Set the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgrap...
const Intersections & getIntersections(unsigned int i) const
Get the intersection points for a single line of sight test.
Definition LineOfSight:84
const osg::Vec3d & getStartPoint(unsigned int i) const
Get the start point of single line of sight test.
Definition LineOfSight:73
DatabaseCacheReadCallback * getDatabaseCacheReadCallback()
Get the ReadCallback that does the reading of external PagedLOD models, and caching of loaded subgrap...
Definition LineOfSight:103
unsigned int addLOS(const osg::Vec3d &start, const osg::Vec3d &end)
Add a line of sight test, consisting of start and end point.
osg::ref_ptr< DatabaseCacheReadCallback > _dcrc
Definition LineOfSight:122
void setStartPoint(unsigned int i, const osg::Vec3d &start)
Set the start point of single line of sight test.
Definition LineOfSight:70
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,...
std::vector< LOS > LOSList
Definition LineOfSight:119
LOSList _LOSList
Definition LineOfSight:120
const osg::Vec3d & getEndPoint(unsigned int i) const
Get the end point of single line of sight test.
Definition LineOfSight:79
void computeIntersections(osg::Node *scene, osg::Node::NodeMask traversalMask=0xffffffff)
Compute the LOS intersections with the specified scene graph.
void setEndPoint(unsigned int i, const osg::Vec3d &end)
Set the end point of single line of sight test.
Definition LineOfSight:76
void clear()
Clear the internal LOS List so it contains no line of sight tests.
void clearDatabaseCache()
Clear the database cache.
Definition LineOfSight:95
unsigned int getNumLOS() const
Get the number of line of sight tests.
Definition LineOfSight:67
LOS(const osg::Vec3d &start, const osg::Vec3d &end)
Definition LineOfSight:109
osg::Vec3d _end
Definition LineOfSight:115
osg::Vec3d _start
Definition LineOfSight:114
Intersections _intersections
Definition LineOfSight:116
IntersectionVisitor is used to testing for intersections with the scene, traversing the scene using g...
Definition IntersectionVisitor:152
Callback used to implement the reading of external files, allowing support for paged databases to be ...
Definition IntersectionVisitor:161
#define OSGSIM_EXPORT
Definition Export:38

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.