[osg-users] Projection matrix and inline or nested cameras

Robert Osfield robert.osfield at gmail.com
Tue Mar 17 02:11:05 PDT 2009


Hi John,

An in scene graph osg::Camera is certainly the route you'd want to take, the
osghud example is probably a good place to start.  You can assign your own
Viewport to an scene graph osg::Camera, but if you don't it'll just inherit
it's parent Camera's Viewport.  osg::Camera also allows you to control which
of the frame buffer components to clear, if you don't want to clear anything
just use camera->setClearMask(0);

Robert.

On Tue, Mar 17, 2009 at 7:31 AM, John Cummings <jcummings2 at users.sf.net>wrote:

> First, I'm using OSG 2.8.0
>
> I'm have been porting an old application from a homegrown OpenGL
> scene-graph to osg and I've come across an issue that I'm sure there is
> a way to handle, but I seem to be unable to locate just the right
> combination of Camera, Drawables, etc.
>
> While most of the old nodes are simply geometry nodes, some of them do
> their own Projection before issuing geometry-type calls. I may want to
> do this for a variety of reasons, including allowing finer grained
> control of the depth buffer or simply covering over something that has
> already been drawn. In my old OpenGL code, the render method for one of
> these problem  nodes may look something like:
>
> void MyNode::Render()
> {
> glMatrixMode(GL_PROJECTION);
> glPushMatrix();
> glLoadIdentity();
>
> // Then either:
> glOrtho (...);
> // or
> gluPerspective(...);
> // or
> glFrustrum();
>
> glMatrixMode(GL_MODELVIEW);
>
> // begin, end, etc.
>
> glMatrixMode(GL_PROJECTION);
> glPopMatrix();
> glMatrixMode(GL_MODELVIEW);
>
> RenderChildren();
> }
>
> I've played with the Camera node and "NESTED_RENDER" seemed from its
> name to be what I wanted. That is, I though I could simply attach an
> osg::Camera node anywhere in my scene graph and it would act much like
> my nodes above. I either didn't set the correct options or this is not a
> valid use of the Camera class.
>
> I've also tried attaching a camera to the root node (more properly I am
> attaching it to the Scene data for my view). That works great for things
> like a HUD, but that doesn't quite seem right in this particular case.
> For what it's worth "this particular case" is where I would like to put
> a viewport size quad over the viewport, which would cover effectively
> cover up my ancestors but allow my children to be seen (I also thought
> an osg::Billboard is what I might want, but that didn't seem to be right
> either). However, I've also wanted to do this same thing for sky
> effects, etc. but have found clunky workarounds for most of the other
> cases.
>
> I then got to looking at the Drawable class and thought that overloading
> drawImplementation would be the best thing to do. However, that doesn't
> seem quite right. Perhaps it is after all.
>
> So, I'm sure that I can do this in osg, I'm just not sure how. I'm still
> adjust my mind to the osg paradigm, so I've probably overlooked
> something obvious, although I didn't see it when I search the mailing
> list. In essence, I want to be able to do the same type of inline
> projection I did before. What am I missing?
>
> Thank you
> John Cummings
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090317/5322a43a/attachment-0003.htm>


More information about the osg-users mailing list