How to know if specific point in world coordinates is visible within current render?
I know vtkSelectVisiblePoints could handle that using z-buffer, however I cannot find source code of that part, and any examples related.
Any suggestions would be appreciated, thanks.
I tried following code to test if point on object’s surface is occluded(rotating camera 360 degrees and check if point is visible), but the returned value is always false.
step = 10
for i in range(36):
renderer.GetActiveCamera().Azimuth(step)
visPts = vtk.vtkSelectVisiblePoints()
visPts.SetRenderer(renderer)
visible = visPts.IsPointOccluded(pos, 0.0)
print(f"visible {visible}")
vtkSelectVisiblePoints’s IsPointOccluded() expects, as its second parameter, an array of foats that is the Z-Buffer data. You passed a 0.0 scalar instead. Hence the unexpected result.
While the detailed solution provided by @Paulo_Carvalho will work, accessing the Z buffer is an expensive operation. Maybe you can achieve better performances by creating an implicit function from the camera frustum. Something similar is done here: https://examples.vtk.org/site/Cxx/Meshes/ClipFrustum/