[jme3] to test what objects are visible


I'm trying out jme3 for a little project of mine.

I would like to load the data of objects from a database, but only for the objects that will be visible in the camera. The objects have a position, x;y;z, and now I would like to select all the objects that will be visible to the camera from the database.

If I have the position of the objects, how can I test if the objects will be visible?

You can use Spatial.checkCulling(Camera) to see if an object is visible by a camera.

Don't I need to create a Spatial first? I would rather just do a select statement in SQL:

select * from myobjects where X <= cam and Y <= cam ....

So I just get the data from the visible objects. I like to have like 10 million objects, I just like to get the really visible from the database.

I need to check if the object's point is in the frustum from the camera; the 6 sites pyramid. Is there a method for that already in Jme3?

Thank you :)

Culling (not displaying objects that are not in the camera frustum) is processed on objects in memory, not only on object's position but also on object boundings.

I guess you would have to store object boundings in your database too.

But …are you trying to fetch data from the database every frame?

Isn't that going to kill your frame rate?

Anyway you would have to implement some sort of database scene graph but you would loose a lot of JME3 features…

Checking if a point is inside a frustum, is not exactly accurate because objects have size, so the point might not be inside the frustum, but some part of the object will be.

There's a method for checking if bounding volumes are inside, Camera.contains(BoundingVolume), make sure however you set the bounding's plane state (setPlaneState) to 0 after each use.