[osg-users] Rendering in-scene camera from different cameras
Jannik Heller
scrawl at baseoftrash.de
Fri Aug 5 08:50:18 PDT 2016
Hi,
A Camera does not inherit the render target implementation, it will simply use what is specified (default FRAMEBUFFER).
You bring up a valid use case, perhaps adding an "inherit render target" mode for Cameras would be a nice feature for the osg core to have.
For the time being what I would suggest is that you don't really need a Camera, you just need a way to set the modelView and projection matrices to identity before drawing your GUI (i.e. work in screen relative coordinates). You can do that with a cull callback:
Code:
class ScreenRelativeCallback : public osg::NodeCallback
{
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv)
{
cv->pushModelViewMatrix(new osg::RefMatrix(), osg::Transform::ABSOLUTE_RF);
cv->pushProjectionMatrix(new osg::RefMatrix());
traverse(node, nv);
cv->popModelViewMatrix();
cv->popProjectionMatrix();
}
else
traverse(node, nv);
}
Then instead of decorating your GUI with a Camera, you decorate it with a Group and add the cull callback: group->addCullCallback(new ScreenRelativeCallback);
In addition you may need to set a RenderBin so that the GUI is drawn after the scene.
I haven't tested this out but I believe it will work.
Cheers,
Jannik
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68295#68295
More information about the osg-users
mailing list