Hello Guy,

I have 2 windows, each with its own camera/viewport. I need to display a different hud on each camera. What's the best solution for this. I looked at the hud example, but there is only one hud and it is added to the scene, and therefore gets displayed on each camera.

You have a few options:

1. you can use a different node mask on each HUD, and then set the traversal mask on each camera to traverse only the appropriate HUD. The drawback here is that you have a limited number of bits in the node mask, so if you're also using it for other things, you could run out. But it's really easy to implement, no change to the hierarchy is needed.

2. you can add the HUD directly as child of the camera, instead of in the scene graph lower down. That way only the appropriate camera will traverse each HUD (since a given HUD is not a child of both cameras, only one). osg::Camera is a Group which renders what's under it.

That's what we do here for elements which need to be seen in only one view. There's one problem with that, it's that if you have callbacks somewhere on the HUD's nodes, they won't be called, because the callbacks are only checked on nodes under the View's SceneData (which your HUD can't be in, because then it would be seen by both cameras). You can solve this by having a different SceneData for both views, where the common scene is somewhere lower in the graph.


SceneData1 (group)
    HUD1 camera
        HUD1 contents
    Main scene
        ....

SceneData2 (group)
    HUD2 camera
        HUD2 contents
    Main scene (same as in SceneData1)
        ....

There may be other options, but those are generally the two most convenient.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to