cassava
cassava

Reputation: 608

Check if node visible to camera in OSG

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.

Upvotes: 1

Views: 1050

Answers (1)

ratchet freak
ratchet freak

Reputation: 48216

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.

Upvotes: 2

Related Questions