OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HeightAboveTerrain.h
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_HEIGHTABOVETERRAIN
15 #define OSGSIM_HEIGHTABOVETERRAIN 1
16 
17 #include <osgUtil/IntersectionVisitor>
18 
19 // include so we can get access to the DatabaseCacheReadCallback
20 #include <osgSim/LineOfSight>
21 
22 namespace osgSim {
23 
33 {
34  public :
35 
36 
38 
39 
41  void clear();
42 
44  unsigned int addPoint(const osg::Vec3d& point);
45 
47  unsigned int getNumPoints() const { return _HATList.size(); }
48 
50  void setPoint(unsigned int i, const osg::Vec3d& point) { _HATList[i]._point = point; }
51 
53  const osg::Vec3d& getPoint(unsigned int i) const { return _HATList[i]._point; }
54 
58  double getHeightAboveTerrain(unsigned int i) const { return _HATList[i]._hat; }
59 
62  void setLowestHeight(double lowestHeight) { _lowestHeight = lowestHeight; }
63 
65  double getLowestHeight() const { return _lowestHeight; }
66 
72  void computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask=0xffffffff);
73 
75  static double computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, osg::Node::NodeMask traversalMask=0xffffffff);
76 
77 
79  void clearDatabaseCache() { if (_dcrc.valid()) _dcrc->clearDatabaseCache(); }
80 
84  void setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc);
85 
88 
89  protected :
90 
91  struct HAT
92  {
93  HAT(const osg::Vec3d& point):
94  _point(point),
95  _hat(0.0) {}
96 
98  double _hat;
99  };
100 
101  typedef std::vector<HAT> HATList;
102 
103 
105  HATList _HATList;
106 
107 
110 
111 
112 };
113 
114 }
115 
116 #endif
#define OSGSIM_EXPORT
Definition: Export.h:38
void setPoint(unsigned int i, const osg::Vec3d &point)
HAT(const osg::Vec3d &point)
unsigned int getNumPoints() const
Definition: Node.h:71
osgUtil::IntersectionVisitor _intersectionVisitor
const osg::Vec3d & getPoint(unsigned int i) const
unsigned int NodeMask
Definition: Node.h:352
double getHeightAboveTerrain(unsigned int i) const
DatabaseCacheReadCallback * getDatabaseCacheReadCallback()
osg::ref_ptr< DatabaseCacheReadCallback > _dcrc
void setLowestHeight(double lowestHeight)