From 559219f519580b81da8497d1b62b5b736cffc1b7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 8 Sep 2005 13:10:04 +0000 Subject: [PATCH] Added initial interface for computing intersections between sphere segments and terrain. --- examples/osgsimulation/osgsimulation.cpp | 2 +- examples/osgspheresegment/osgspheresegment.cpp | 12 ++++++++++++ include/osgSim/SphereSegment | 7 +++++++ src/osgSim/SphereSegment.cpp | 7 +++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/examples/osgsimulation/osgsimulation.cpp b/examples/osgsimulation/osgsimulation.cpp index 03eec7117..452e3bb63 100644 --- a/examples/osgsimulation/osgsimulation.cpp +++ b/examples/osgsimulation/osgsimulation.cpp @@ -323,7 +323,7 @@ int main(int argc, char **argv) // tell the overlay node to continously update its overlay texture // as we know we'll be tracking a moving target. - // overlayNode->setContinousUpdate(true); + overlayNode->setContinousUpdate(true); } diff --git a/examples/osgspheresegment/osgspheresegment.cpp b/examples/osgspheresegment/osgspheresegment.cpp index 4d139ed87..6c9312a88 100644 --- a/examples/osgspheresegment/osgspheresegment.cpp +++ b/examples/osgspheresegment/osgspheresegment.cpp @@ -272,6 +272,16 @@ void build_world(osg::Group *root) root->addChild(ss.get()); } + osgSim::SphereSegment::LineList lines = ss->computeIntersection(terrainGeode.get(), osg::Matrixd::identity()); + if (!lines.empty()) + { + osg::notify(osg::NOTICE)<<"We've found intersections!!!!"<addChild(terrainGeode.get()); root->addChild(overlayNode); + + #else root->addChild(terrainGeode); #endif diff --git a/include/osgSim/SphereSegment b/include/osgSim/SphereSegment index 1542c4b45..b759ba841 100644 --- a/include/osgSim/SphereSegment +++ b/include/osgSim/SphereSegment @@ -19,6 +19,7 @@ #include #include #include +#include #include namespace osgSim{ @@ -226,6 +227,12 @@ public: void setAllColors(const osg::Vec4& c); META_Node(osgSim, SphereSegment); + + /** A list of vertex arrays representing a list of lines.*/ + typedef std::vector< osg::ref_ptr > LineList; + + /** Compute the interesection lines between specified geometry and this sphere segment.*/ + LineList computeIntersection(osg::Node* subgraph, const osg::Matrixd& transform); private: diff --git a/src/osgSim/SphereSegment.cpp b/src/osgSim/SphereSegment.cpp index 93c7a18e4..ab596b155 100644 --- a/src/osgSim/SphereSegment.cpp +++ b/src/osgSim/SphereSegment.cpp @@ -960,3 +960,10 @@ void SphereSegment::setAllColors(const osg::Vec4& c) setEdgeLineColor(c); setSideColor(c); } + +SphereSegment::LineList SphereSegment::computeIntersection(osg::Node* subgraph, const osg::Matrixd& transform) +{ + osg::notify(osg::NOTICE)<<"Creating line intersection between sphere segment and subgraph."<