diff --git a/src/osgSim/OverlayNode.cpp b/src/osgSim/OverlayNode.cpp index 811a63278..cc8892286 100644 --- a/src/osgSim/OverlayNode.cpp +++ b/src/osgSim/OverlayNode.cpp @@ -43,6 +43,7 @@ public: Face& createFace() { _faces.push_back(Face()); return _faces.back(); } + /** Create a Polytope which is a cube, centered at 0,0,0, with sides of 2 units.*/ void setToUnitFrustum(bool withNear=true, bool withFar=true) { @@ -199,9 +200,87 @@ public: } } + + void insertVertex(const osg::Vec3d& vertex) + { + // osg::notify(osg::NOTICE)<<"Inserting vertex "< Edge; + typedef std::map Edges; + Edges edges; + + double numVerticesAdded=0.0; + osg::Vec3d center; + for(itr = removedFaces.begin(); + itr != removedFaces.end(); + ++itr) + { + Face& face = *itr; + Vertices& vertices = face.vertices; + for(unsigned int i=0; isecond==1) + { + // osg::notify(osg::NOTICE)<<" edge Ok"<first; + Face face; + face.plane.set(vertex, edge.first, edge.second); + face.vertices.push_back(vertex); + face.vertices.push_back(edge.first); + face.vertices.push_back(edge.second); + if (face.plane.distance(center)<0.0) face.plane.flip(); + + _faces.push_back(face); + } + } + + + // osg::notify(osg::NOTICE)<<" Removed faces "<accept(cbbv); overlayPolytope.setToBoundingBox(cbbv.getBoundingBox()); + + if (csn) + { + overlayPolytope.insertVertex(osg::Vec3d(0.0,0.0,0.0)); + } frustum.cut(overlayPolytope);