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


#1

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).


#2

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.


#3

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.


#4

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


#5

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");
        }

#6

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


#7

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.)


#8

thank you so much.