/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer * * This library is based on OpenSceneGraph, 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. * * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. * You have to aquire licenses for all used proprietary modules. * * 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. */ #include #include #include #include using namespace osgVisual; using namespace osgSim; terrainQuery::terrainQuery() { _lowestHeight = -1000.0; setDatabaseCacheReadCallback(new DatabaseCacheReadCallback); } void terrainQuery::clear() { _HATList.clear(); } unsigned int terrainQuery::addPoint(const osg::Vec3d& point) { unsigned int index = _HATList.size(); _HATList.push_back(HAT(point)); return index; } void terrainQuery::computeIntersections(osg::Node* scene, osg::Node::NodeMask traversalMask) { osg::CoordinateSystemNode* csn = dynamic_cast(scene); osg::EllipsoidModel* em = csn ? csn->getEllipsoidModel() : 0; osg::ref_ptr intersectorGroup = new osgUtil::IntersectorGroup(); for(HATList::iterator itr = _HATList.begin(); itr != _HATList.end(); ++itr) { if (em) { osg::Vec3d start = itr->_point; osg::Vec3d upVector = em->computeLocalUpVector(start.x(), start.y(), start.z()); double latitude, longitude, height; em->convertXYZToLatLongHeight(start.x(), start.y(), start.z(), latitude, longitude, height); osg::Vec3d end = start - upVector * (height - _lowestHeight); itr->_hat = height; OSG_NOTICE<<"lat = "<