2008-06-04 00:13:49 +08:00
|
|
|
/* OpenSceneGraph example, osgintersection.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2015-10-22 21:42:19 +08:00
|
|
|
|
2008-06-06 01:28:06 +08:00
|
|
|
#include <osgDB/ReadFile>
|
|
|
|
|
2008-06-04 00:13:49 +08:00
|
|
|
#include <osg/ArgumentParser>
|
|
|
|
#include <osg/ApplicationUsage>
|
|
|
|
#include <osg/Timer>
|
|
|
|
#include <osg/CoordinateSystemNode>
|
|
|
|
#include <osg/Notify>
|
|
|
|
#include <osg/io_utils>
|
2008-06-05 01:59:39 +08:00
|
|
|
#include <osg/Geometry>
|
2008-07-03 18:24:20 +08:00
|
|
|
#include <osg/TriangleIndexFunctor>
|
2008-06-04 00:13:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include <osgUtil/IntersectionVisitor>
|
|
|
|
#include <osgUtil/LineSegmentIntersector>
|
2008-06-06 18:51:23 +08:00
|
|
|
#include <osgUtil/UpdateVisitor>
|
2008-06-04 00:13:49 +08:00
|
|
|
|
|
|
|
#include <osgSim/LineOfSight>
|
|
|
|
#include <osgSim/HeightAboveTerrain>
|
|
|
|
#include <osgSim/ElevationSlice>
|
|
|
|
|
2008-07-04 23:57:48 +08:00
|
|
|
#include <osgViewer/Viewer>
|
|
|
|
|
|
|
|
#include <osg/KdTree>
|
2008-06-06 01:28:06 +08:00
|
|
|
|
2008-07-12 19:19:25 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
2008-06-04 00:13:49 +08:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
// use an ArgumentParser object to manage the program arguments.
|
|
|
|
osg::ArgumentParser arguments(&argc,argv);
|
2015-10-22 21:42:19 +08:00
|
|
|
|
2008-07-03 19:22:23 +08:00
|
|
|
int maxNumLevels = 16;
|
|
|
|
int targetNumIndicesPerLeaf = 16;
|
2008-07-03 18:24:20 +08:00
|
|
|
|
2008-07-03 19:22:23 +08:00
|
|
|
while (arguments.read("--max", maxNumLevels)) {}
|
|
|
|
while (arguments.read("--leaf", targetNumIndicesPerLeaf)) {}
|
2015-10-22 21:42:19 +08:00
|
|
|
|
2008-07-04 23:57:48 +08:00
|
|
|
osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
|
2015-10-22 21:42:19 +08:00
|
|
|
|
|
|
|
osg::ref_ptr<osg::Node> scene = osgDB::readRefNodeFiles(arguments);
|
|
|
|
|
|
|
|
if (!scene)
|
2008-06-04 00:13:49 +08:00
|
|
|
{
|
|
|
|
std::cout<<"No model loaded, please specify a valid model on the command line."<<std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|
2008-06-06 02:52:29 +08:00
|
|
|
|
2008-07-12 19:19:25 +08:00
|
|
|
osgViewer::Viewer viewer;
|
2015-10-22 21:42:19 +08:00
|
|
|
viewer.setSceneData(scene);
|
2008-07-12 19:19:25 +08:00
|
|
|
return viewer.run();
|
2008-06-04 00:13:49 +08:00
|
|
|
}
|