Mark Schlosser
Mark Schlosser

Reputation: 196

Get actual node path of OpenSceneGraph custom osg::Drawable

I am writing a custom osg::Drawable class which needs to calculate its current distance from the camera's eye when its drawImplementation method is called. It needs to do this in order to determine the optimal number of facets for rendering.

The difficulty is that my drawable can have any number of osg:Transform nodes as parents. I need to apply the transformation of the actual parent that is being applied to the drawable. Using osg::Node::getParents() and/or getParentalNodePaths(), I can determine all possible paths to this drawable, but not the path that was taken.

Is there any way to determine this in OpenSceneGraph? I have dug through the examples and documentation and have not found exactly what I require.

Upvotes: 1

Views: 752

Answers (1)

sn710
sn710

Reputation: 601

You can do this at cull stage rather than the render/draw stage. You can get the model view matrix from the cull visitor and later determine the distance from this. Since you want this for your custom drawable class, you can do this by attaching a cullcallback.

Upvotes: 3

Related Questions