Checking if actor is visible to a user

(Marvin) #1

Hello,
I try to check if an Actor can be seen by a user or if it is hidden behind another object. Currently I try doing this with a picker, since I thought it would only select the topmost Actor. But it selects all actors in its path, and I’ve run out of ideas.
Also adding only the desired Actors to the pick list does not work, because they will be picked any time

What I do currently (pseudocode)

point = [actor.x, actor.y, 0]
picker = vtkPointPicker.newInstance()
picker.pick(point, renderer)

Now picker.getActors() will return all actors in the pickers ray cast, and they always have the same order to, so I can not decide if the actor can be seen by the user or is hidden behind one of the other actors.

Can anyone please help me?

(Peter) #3

Have you trief Worldpointpicker instead of Pointpicker? According to documentation:
vtkWorldPointPicker is the fastest picker, returning an x-y-z coordinate value using the hardware z-buffer.

Havent tried it myself, just an idea

(Sebastien Jourdain) #4

The code in that test should give you a good starting point.

Rendering/OpenGL/HardwareSelector/test/testHardwareSelector.js

Unfortunately my previous posts fail due to the direct link I was putting trying to provide.

(Marvin) #5

Thank you so much, the HardwareSelector does exactly what I needed :upside_down_face:

(Marvin) #7

Ok the efficiency issue was mostly on my part. For a group of actors I did one selection for each everytime the view was moved. Now I optimised it by doing on large selection where all actors could be included (if they are visible) and I only do this, once moving the view has ended.

The selection still takes 50 - 150ms, but its definitely smooth enough for my interaction.