Hi Chris,
Have a look a the osg::ClusterCullingCallback.
Robert.
On 10/25/07, Chris Denham <[EMAIL PROTECTED]> wrote:
> I'm looking for the best way to make a collection of linestrips (which
> lie on plane) disappear when the plane is facing away from the screen.
> i.e. exactly like the way back face culling works for polygonal faces.
> My first attempt was to create a special kind of group that has a
> normal, then when the CullVistor visits the node, determine whether to
> accept the node based on the modelviewmatrix transformation of the
> normal vector.
> Here's my implementation (which doesn't seem to work properly). Can
> anyone help me fix it, or suggest a better method?
>
> class NormalGroup : public osg::Group
> {
> public:
> virtual void accept(osg::NodeVisitor& nv);
> void setNormal(const osg::Vec3 & position, const osg::Vec3 & direction)
> {
> _position = position;
> _direction = direction;
> }
>
> private:
> osg::Vec3 _position;
> osg::Vec3 _direction;
> };
>
> void NormalGroup::accept(osg::NodeVisitor& nv)
> {
> if (nv.validNodeMask(*this))
> {
> if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
> {
> osgUtil::CullVisitor * cv =
> dynamic_cast<osgUtil::CullVisitor*>(&nv);
> if (cv)
> {
> osg::Matrix * matrix = cv->getModelViewMatrix();
> osg::Vec3 p1 = *matrix * _position;
> osg::Vec3 p2 = *matrix * (_position + _direction);
> osg::Vec3 d = p2 - p1;
> if (d.y() > 0) Group::accept(nv);
> }
> } else {
> Group::accept(nv);
> }
> }
> }
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org