[vtkusers] How can I hide vtkCaptionActor2D?

David Lonie david.lonie at kitware.com
Wed Oct 14 08:30:34 EDT 2015


On Tue, Oct 13, 2015 at 1:12 PM, -Daniel- <ich_daniel at habmalnefrage.de>
wrote:

> Hi there,
>
> I have a cube with text on every corner. For this I use vtkCaptionActor2D,
> so that the text is always visible in the foreground. Now I want to hide
> the
> text (or vtkCaptionActor2D) when the corresponding corner can't be seen in
> the renderer.
>
> How can I hide a vtkCaptionActor2D?
>

As far as I'm aware, there is not a built-in way to do this, and it will
take some work from the application side.

The vtkCaptionActor2D (or any actor for that matter) can be hidden by
calling SetVisibility(0) on the actor. The trick is going to be detecting
when the point is not visible.

The vtkSelectVisiblePoints class does something similar to what you want.
In that class's IsPointOccluded method, a point is transformed using the
active camera's modelview/projection matrices. The transformed point is
tested to see if it falls within a rectangular region (they use some
selection bounds, but it could just be the viewport extents in your case),
and then it also compares the point to the renderer's depth buffer to see
if there's anything in front of it.

See
https://github.com/Kitware/VTK/blob/master/Rendering/Core/vtkSelectVisiblePoints.cxx#L241
for the implementation.

You'll need to do something similar for your usecase, and update the
actor's visibility based on whether the point is occluded.

Hope this helps,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151014/872c07e9/attachment.html>


More information about the vtkusers mailing list