From 7adb75c5721ce71af0dadeba517e8df24fb05f63 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 14 Jun 2002 14:50:31 +0000 Subject: [PATCH] Added occluder hole test code into the osgoccluder demo. The code works, but I've commented it out right now as the Geode physically representing the occluder doesn't yet have a hole in it - just a cosmetic thing. --- src/Demos/osgoccluder/osgoccluder.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Demos/osgoccluder/osgoccluder.cpp b/src/Demos/osgoccluder/osgoccluder.cpp index ea8a2ba2a..cb78c0854 100644 --- a/src/Demos/osgoccluder/osgoccluder.cpp +++ b/src/Demos/osgoccluder/osgoccluder.cpp @@ -51,6 +51,9 @@ void write_usage(std::ostream& out,const std::string& name) out << std::endl; } + + + osg::Node* createOccludersAroundModel(osg::Node* model) { osg::Group* scene = osgNew osg::Group; @@ -63,14 +66,17 @@ osg::Node* createOccludersAroundModel(osg::Node* model) osg::OccluderNode* occluderNode = osgNew osg::OccluderNode; // get the bounding volume of the model. - const osg::BoundingSphere& bs = model->getBound(); + const osg::BoundingSphere bs = model->getBound(); // create a bounding box around the sphere. osg::BoundingBox bb; bb.expandBy(bs); - + // create the convex planer occluder osg::ConvexPlanerOccluder* cpo = osgNew osg::ConvexPlanerOccluder; + + // attach it to the occluder node. + occluderNode->setOccluder(cpo); // set the occluder up for the front face of the bounding box. osg::ConvexPlanerPolygon& occluder = cpo->getOccluder(); @@ -79,7 +85,19 @@ osg::Node* createOccludersAroundModel(osg::Node* model) occluder.add(osg::Vec3(bb.xMax(),bb.yMin(),bb.zMax())); occluder.add(osg::Vec3(bb.xMin(),bb.yMin(),bb.zMax())); - occluderNode->setOccluder(cpo); +// +// // create a hole in the occluder. +// osg::Vec3 center((bb.xMin()+bb.xMax())*0.5f,bb.yMin(),(bb.zMin()+bb.zMax())*0.5f); +// float dx = (bb.xMax()-bb.xMin())*0.25f; +// float dz = (bb.zMax()-bb.zMin())*0.25f; +// +// +// cpo->getHoleList().push_back(); +// osg::ConvexPlanerPolygon& hole = cpo->getHoleList().back(); +// hole.add(center+osg::Vec3(-dx,0.0,-dz)); +// hole.add(center+osg::Vec3(dx,0.0,-dz)); +// hole.add(center+osg::Vec3(dx,0.0,dz)); +// hole.add(center+osg::Vec3(-dx,0.0,dz)); // create a drawable for occluder.