[osg-users] How to access the view parameters from which the Cull Visitor came?

Miguel cvx at yandex.ru
Fri Sep 22 10:31:32 PDT 2017


Hi!

I have a multi-view app (using CompositeViewer) in which some nodes should look differently in different views. For example, some label positions should be recalculated depending on the view's camera parameters and some annotations (rectangular area with a border some text) should be visible or hidden depending on the view scale.

I am trying to override 

void GraticuleNode::traverse(osg::NodeVisitor& nv)

and check if the visitor is osg::NodeVisitor::CULL_VISITOR

if it is, I change child required parameters of child nodes, and make them visible or not with 

setNodeMask(visible ? 0x2 : 0);

I am new to OSG and I am not sure I am doing everything correctly and its not clear for me, how to access View parameters here ( in traverse(...) ). In particular, I need: 

1) to access view width and height in pixels (Viewport in pixels) and pass them to a specific node shader as uniforms, 

2) Check some View attributes depending on which I show or hide the child nodes. I set the View attributes when I create the osgViewer::View, for example, there is an attribute determining if the View is Primary (Main) or Secondary (Zoom).

Vasiliy.


More information about the osg-users mailing list