Paul Martz wrote:
> The HUD issue shouldn't require modifying the scene graph at all. Create one
> HUD scene graph with the entire HUD in it. Parent it to two HUD cameras with
> two different views. One Camera has its view matrix set to view the left
> half of the HUD, and the other is similarly configured to view the right
> half.
> 


Ok, that's a possible solution, but this creates a specific scenegraph for a 
specific number of  slave cameras.

A more flexible and dirty solution I came up with a couple of minutes ago was 
this:
-Add an empty group node above the HUD camera
-Add a CullCallback with a reference to the HUD camera
In the CullCallback do this


Code:

class CullCallback : public osg::NodeCallback
{
       osg::ref_ptr<osg::Camera> _camera;
public:
        CullCallback(osg::Camera* camera) :
                _camera(camera)
        {
        }

    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
    { 
                osgUtil::CullVisitor* cv = 
dynamic_cast<osgUtil::CullVisitor*>(nv);
                if (cv)
                {
                        osg::Camera* cam = cv->getCurrentCamera();
                        osg::View::Slave* slave = 
cam->getView()->findSlaveForCamera(cam);
                        mat.makeOrtho2D(-1,1,-1,1);
                        if (slave)
                        {
                                mat *= slave->_projectionOffset;
                        }
                        _camera->setProjectionMatrix(mat);
                }
        traverse(node,nv);
    }
};




--
Roland

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=10763#10763





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to