HeightAboveTerrain
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGSIM_HEIGHTABOVETERRAIN
#define OSGSIM_HEIGHTABOVETERRAIN 1
#include <osgUtil/IntersectionVisitor>
// include so we can get access to the DatabaseCacheReadCallback
#include <osgSim/LineOfSight>
namespace osgSim {
class OSGSIM_EXPORT HeightAboveTerrain
{
public :
HeightAboveTerrain();
void clear();
unsigned int addPoint(const osg::Vec3d& point);
unsigned int getNumPoints() const { return _HATList.size(); }
void setPoint(unsigned int i, const osg::Vec3d& point) { _HATList[i]._point = point; }
const osg::Vec3d& getPoint(unsigned int i) const { return _HATList[i]._point; }
double getHeightAboveTerrain(unsigned int i) const { return _HATList[i]._hat; }
void setLowestHeight(double lowestHeight) { _lowestHeight = lowestHeight; }
double getLowestHeight() const { return _lowestHeight; }
void computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask=0xffffffff);
static double computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, osg::Node::NodeMask traversalMask=0xffffffff);
void clearDatabaseCache() { if (_dcrc.valid()) _dcrc->clearDatabaseCache(); }
void setDatabaseCacheReadCallback(DatabaseCacheReadCallback* dcrc);
DatabaseCacheReadCallback* getDatabaseCacheReadCallback() { return _dcrc.get(); }
protected :
struct HAT
{
HAT(const osg::Vec3d& point):
_point(point),
_hat(0.0) {}
osg::Vec3d _point;
double _hat;
};
typedef std::vector<HAT> HATList;
double _lowestHeight;
HATList _HATList;
osg::ref_ptr<DatabaseCacheReadCallback> _dcrc;
osgUtil::IntersectionVisitor _intersectionVisitor;
};
}
#endif
IntersectionVisitor
LineOfSight
osgSim::DatabaseCacheReadCallback
Definition LineOfSight:24
osgSim::HeightAboveTerrain::_intersectionVisitor
osgUtil::IntersectionVisitor _intersectionVisitor
Definition HeightAboveTerrain:109
osgSim::HeightAboveTerrain::getHeightAboveTerrain
double getHeightAboveTerrain(unsigned int i) const
Definition HeightAboveTerrain:58
osgSim::HeightAboveTerrain::getDatabaseCacheReadCallback
DatabaseCacheReadCallback * getDatabaseCacheReadCallback()
Definition HeightAboveTerrain:87
osgSim::HeightAboveTerrain::setLowestHeight
void setLowestHeight(double lowestHeight)
Definition HeightAboveTerrain:62
osgSim::HeightAboveTerrain::_lowestHeight
double _lowestHeight
Definition HeightAboveTerrain:104
osgSim::HeightAboveTerrain::setDatabaseCacheReadCallback
void setDatabaseCacheReadCallback(DatabaseCacheReadCallback *dcrc)
osgSim::HeightAboveTerrain::clear
void clear()
osgSim::HeightAboveTerrain::clearDatabaseCache
void clearDatabaseCache()
Definition HeightAboveTerrain:79
osgSim::HeightAboveTerrain::getPoint
const osg::Vec3d & getPoint(unsigned int i) const
Definition HeightAboveTerrain:53
osgSim::HeightAboveTerrain::HATList
std::vector< HAT > HATList
Definition HeightAboveTerrain:101
osgSim::HeightAboveTerrain::addPoint
unsigned int addPoint(const osg::Vec3d &point)
osgSim::HeightAboveTerrain::computeIntersections
void computeIntersections(osg::Node *scene, osg::Node::NodeMask traversalMask=0xffffffff)
osgSim::HeightAboveTerrain::HeightAboveTerrain
HeightAboveTerrain()
osgSim::HeightAboveTerrain::_dcrc
osg::ref_ptr< DatabaseCacheReadCallback > _dcrc
Definition HeightAboveTerrain:108
osgSim::HeightAboveTerrain::_HATList
HATList _HATList
Definition HeightAboveTerrain:105
osgSim::HeightAboveTerrain::computeHeightAboveTerrain
static double computeHeightAboveTerrain(osg::Node *scene, const osg::Vec3d &point, osg::Node::NodeMask traversalMask=0xffffffff)
osgSim::HeightAboveTerrain::setPoint
void setPoint(unsigned int i, const osg::Vec3d &point)
Definition HeightAboveTerrain:50
osgSim::HeightAboveTerrain::getNumPoints
unsigned int getNumPoints() const
Definition HeightAboveTerrain:47
osgSim::HeightAboveTerrain::getLowestHeight
double getLowestHeight() const
Definition HeightAboveTerrain:65
osgUtil::IntersectionVisitor
Definition IntersectionVisitor:152
osg::Node
Definition Node:72
osg::Node::NodeMask
unsigned int NodeMask
Definition Node:363
osg::Vec3d
Definition Vec3d:30
osg::ref_ptr
Definition ref_ptr:32
osgSim
Definition BlinkSequence:27
OSGSIM_EXPORT
#define OSGSIM_EXPORT
Definition osgSim/Export:38
osgSim::HeightAboveTerrain::HAT::HAT
HAT(const osg::Vec3d &point)
Definition HeightAboveTerrain:93
osgSim::HeightAboveTerrain::HAT::_point
osg::Vec3d _point
Definition HeightAboveTerrain:97
osgSim::HeightAboveTerrain::HAT::_hat
double _hat
Definition HeightAboveTerrain:98