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

Guy guy at dvp.co.il
Tue Mar 17 00:46:37 PDT 2009


Hi,
 Maybe you should post the relevant lines of code where you set the
camera.

What happens when you attach the camera? Only that object under the
camera are seen and the rest disappear?

Maybe you should play a little with the clear mask of the camera, set it
to 0 mean nothing will be cleared so you have the complete scene that
was drawn before.

Another option which people here would like to avoid is to use
osg::Projection which you can set it's projection and model view
matrices.

Last thing that might help, you would probably want to set the
Camera/Projection reference frame to ABSOLUTE_RF.
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

Hope it helps,
 Guy.


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.or
g



More information about the osg-users mailing list