[solved] How can I find and select characters that are in camview?

1-how can I find and select characters that are in cam view? (double click and select all in camView)
2-and a selection like multi-select in C&C game? (click and drag and draw a square and select what are in the square area).

If an object isn’t in view it will be culled, so you can start from there.

Objects should be grouped in one way or another (tanks, footmen, workers, etc) so just iterate the group and check the cull hint.

Without knowing your setup, that’s the quickest way.

A better way would be a radial area check. If you know how to draw a circle then you know how to check if a coordinate is in the circle.

The second way avoids using the scene - which is the way i would be more inclined to use.

1 Like

For your second point see here.

Point A is the point where the mouse is pressed, point B is where the mouse is released. You will have both the 2D and 3D coords to draw a rectangle on both scenes.

https://gist.github.com/jayfella/2683d763b8aa19b4206048bc4d67f51a

1 Like

Has your question been adequately answered? If so, please let us know!

1 Like

no, it is not working…
if a node gets out of the camera view and was not on screen its CullHint doesn’t change.

if (node.getCullHint() == Spatial.CullHint.Always) {
            System.out.println("it`s not in camview");
        }

The method I linked to tells you everything on how a spatial is determined whether or not to be culled.

1 Like

That’s because cull hint is not a status. It’s a HINT to how culling should be done on this spatial.

https://javadoc.jmonkeyengine.org/com/jme3/scene/Spatial.CullHint.html

It helps to be careful of what the input to a process is versus the output to a process. Sometimes the javadoc can be helpful in that regard. (Sometimes not.)

1 Like

thank you so much.