Check if node visible to camera in OSG

1k views Asked by At

How can I check if a node in my scene graph is actually seen by my main camera?

In my particular use-case, I want to know if a node is (in the area) behind the camera.

Thanks.

1

There are 1 answers

3
ratchet freak On BEST ANSWER

You only need to know 3 things to do this: the view direction, the position of the camera and the position of the node (all in the same coordinate system).

Then the test is easy: dot(view, nodePos-cameraPos)<0 where dot(v1, v2) is the dot product of 2 vectors in other words v1.x*v2.x + v1.y*v2.y + v1.z*v2.z.