Added osgSim::LineOfSight and osgSim::HeightAboveTerrain classes
This commit is contained in:
@@ -167,6 +167,10 @@ SOURCE=..\..\src\osgSim\DOFTransform.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgSim\HeightAboveTerrain.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgSim\Impostor.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -195,6 +199,10 @@ SOURCE=..\..\src\osgSim\LightPointNode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgSim\LineOfSight.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgSim\MultiSwitch.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -251,6 +259,10 @@ SOURCE=..\..\include\osgSim\Export
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgSim\HeightAboveTerrain
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\osgSim\Impostor
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -283,6 +295,10 @@ SOURCE=..\..\include\osgSim\LightPointSystem
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgSim\LineOfSight
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgSim\MultiSwitch
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
|
||||
CXXFILES =\
|
||||
osgintersection.cpp\
|
||||
|
||||
LIBS += -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
LIBS += -losgText -losgSim -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
|
||||
|
||||
INSTFILES = \
|
||||
$(CXXFILES)\
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <osgUtil/IntersectionVisitor>
|
||||
|
||||
#include <osgSim/LineOfSight>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
struct MyReadCallback : public osgUtil::IntersectionVisitor::ReadCallback
|
||||
@@ -45,8 +47,62 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
bool useIntersectorGroup = true;
|
||||
bool useLineOfSight = true;
|
||||
|
||||
if (useIntersectorGroup)
|
||||
if (useLineOfSight)
|
||||
{
|
||||
osg::Timer_t startTick = osg::Timer::instance()->tick();
|
||||
|
||||
osg::Vec3d start = bs.center() + osg::Vec3d(0.0,bs.radius(),0.0);
|
||||
osg::Vec3d end = bs.center();// - osg::Vec3d(0.0, bs.radius(),0.0);
|
||||
osg::Vec3d deltaRow( 0.0, 0.0, bs.radius()*0.01);
|
||||
osg::Vec3d deltaColumn( bs.radius()*0.01, 0.0, 0.0);
|
||||
unsigned int numRows = 50;
|
||||
unsigned int numColumns = 50;
|
||||
|
||||
osgSim::LineOfSight los;
|
||||
|
||||
for(unsigned int r=0; r<numRows; ++r)
|
||||
{
|
||||
for(unsigned int c=0; c<numColumns; ++c)
|
||||
{
|
||||
osg::Vec3d s = start + deltaColumn * double(c) + deltaRow * double(r);
|
||||
osg::Vec3d e = end + deltaColumn * double(c) + deltaRow * double(r);
|
||||
los.addLOS(s,e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
los.computeIntersections(root.get());
|
||||
|
||||
osg::Timer_t endTick = osg::Timer::instance()->tick();
|
||||
|
||||
std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl;
|
||||
|
||||
#if 0
|
||||
for(unsigned int i=0; i<los.getNumLOS(); i++)
|
||||
{
|
||||
const osgSim::LineOfSight::Intersections& intersections = los.getIntersections(i);
|
||||
for(osgSim::LineOfSight::Intersections::const_iterator itr = intersections.begin();
|
||||
itr != intersections.end();
|
||||
++itr)
|
||||
{
|
||||
std::cout<<" point "<<*itr<<std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// now do a second traversal to test performance of cache.
|
||||
startTick = osg::Timer::instance()->tick();
|
||||
|
||||
los.computeIntersections(root.get());
|
||||
|
||||
endTick = osg::Timer::instance()->tick();
|
||||
|
||||
std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl;
|
||||
|
||||
}
|
||||
else if (useIntersectorGroup)
|
||||
{
|
||||
osg::Timer_t startTick = osg::Timer::instance()->tick();
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define OSGUTIL_INTERSECTIONVISITOR 1
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Drawable>
|
||||
#include <osgUtil/Export>
|
||||
|
||||
#include <list>
|
||||
|
||||
@@ -13,6 +13,8 @@ CXXFILES = \
|
||||
LightPointDrawable.cpp\
|
||||
LightPointSpriteDrawable.cpp\
|
||||
LightPointNode.cpp\
|
||||
LineOfSight.cpp\
|
||||
HeightAboveTerrain.cpp\
|
||||
MultiSwitch.cpp\
|
||||
OverlayNode.cpp\
|
||||
OpenFlightOptimizer.cpp\
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/* -*-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.
|
||||
*/
|
||||
|
||||
|
||||
#include <osgUtil/IntersectionVisitor>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user