[osg-users] Adding a child to a node at runtime.
Thrall, Bryan
bryan.thrall at flightsafety.com
Thu Jun 19 10:26:49 PDT 2008
James Reid wrote on Thursday, June 19, 2008 12:13 PM:
> Howdy!
>
> When I try to add a child to a node at runtime I get an exception.
> Unfortunately, the exception dies quietly so I'm not sure what the
actual
> exception is. I know I've done this before (a long time ago) and
things have
> changed since then, so I'm not sure what I'm doing wrong. Here's the
setup
> of our app.
>
> We're rendering on a managed window using managed c++
> We have a button that enables/disable certain graphics to be drawn.
> To do the hiding of a graphic, I remove the geode from it's parent
node.
> To do the showing of a graphic, I add the geode to the parent. <- this
causes
> the exception
>
> We're building a simulation and our users can toggle certain graphics
on/off.
> For example, they can view graphic, physics, center of mass,
constraints,
> etc... They can view any number of these at any time.
>
> My current set up is I have a Geode for each representation. I then
> add/remove that geode depending on the display settings.
>
> Is this the wrong setup? I've searched for similar solutions and
haven't
> really found anything. Maybe I'm looking in the wrong places?
It isn't safe to modify the scenegraph during the cull and draw passes;
it's best to use a UpdateCallback, or to replace your call to frame()
with your own that modifies the scenegraph before doing the cull and
draw.
There are other ways to show/hide geometry, such as the node mask or a
CullCallback; not that what you're doing is wrong, but perhaps they
might do what you want better.
--
Bryan Thrall
FlightSafety International
bryan.thrall at flightsafety.com
More information about the osg-users
mailing list