Find out which objects are on the screen?


So my question is: Is there an easy way to find out which objects are currently drawn on the screen? Like: You have people walking around and you turn the camera and look at them: How can you count how many people are on the screen and which are?

it would be nice if there was a cone class, that has an intersect method.

you could easily make one, but the only way i could think of would be massively resource intensive (i’d make a screen-sized cone or trapezoid array of raycasts that puts each unique hit string in an array and then parse that through a filter of what you want to see, but that would be insanely resource-intensive to do all the time. at beast do it in a thread. )

or you could use a cube shaped zone of coordinate search if theres such a thing as a callable object list, filter/iterate through that

@xenofobig : it wont be resource intensive, simple because there are infitive rays between 2 positions, since a ray has 0 width, so it will take Math.Inf years to complete, its like doing :

1 = 0.000000000001 + 0.000000000001 + 0.000000000001 + 0.000000000001 + …

with unlimited number of zeroes. There are easier ways to calculate how much number “1” is

The only way to do this is to traverse the scene graph yourself and see if the objects are on camera. You can either clip them against the camera frustum or just find their x,y position in screen space and checking against the screen size.

Neither is particularly difficult, really. There is no built in way to find this information as JME doesn’t really need that information for anything.

You can use Camera.contains() but there are some nuances to using that method. Use the forum search