[osg-users] [forum] add/remove nodes when rendering

Jan Ciger jan.ciger at gmail.com
Tue Apr 14 02:00:00 PDT 2015


Hello,

On Tue, Apr 14, 2015 at 9:57 AM, Sophie Audonneau <
sophie.audonneau1 at etu.univ-lorraine.fr> wrote:

> In my draw function I have to do the following :
> viewer_->setUpViewerAsEmbeddedInWindow(viewParams[0],viewParams[1],viewParams[2]
> ,viewParams[3]);
> viewer_->getCamera()->setProjectionMatrix( osg::Matrix(glMat_projection) );
> viewer_->getCamera()->setViewMatrix( osg::Matrix(glMat_modelview) );
> viewer_->frame();
>

You are not supposed to do this on every frame, unless you are changing
them all time. Are you doing some sort of augmented reality where they are
provided by the tracking system? In a typical OSG application the matrices
are typically set only once (or not at all - use the default!), the view
matrix is often driven using a camera manipulator. The only thing you
should do periodically is viewer_->frame().

I think your problem is that you are calling
setUpViewerAsEmbeddedInWindow() on every frame - this sets the viewer up
from scratch each time. There is no need to do that - you do it only once
when you are creating the window.

Please, have a look at the examples that ship with OSG. They show how to
use OSG and how to integrate it with other libraries (which is what I
assume you are doing, since you are calling setUpViewerAsEmbeddedInWindow()
yourself).

Re adding/removing nodes - that is perfectly fine, just do it before or
after running the viewer_->frame() call, not in some sort of callback or
separate thread.

J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150414/c7c45d7f/attachment-0003.htm>


More information about the osg-users mailing list