Mouse hover on object question

Hello guys, Id like to affect the players who are hovered color, in order to do that i Am using an input control, on MouseInput.AXIS_X and MouseInput.AXIS_Y I use raytracing to determine the hovered spatial, and then I set its UserData “STATE” at hovered,
then a Control handles the color and sets the selected spatial color.

is this efficient? Am I overdoing it for something as simple as hover change color on spatial. I’m using the ray collide with on all the players :confused: since I am doing it on mouse move maybe this is too much?

thx for the feedback!

It’s probably fine. The Lemur toolkit has some classes that do similar in a more general way… pretty much the same… and it works fine for me. (Incidentally, those particular classes can be used by themselves even if you aren’t making a Lemur UI.)

ow also i’ve encountered aweird issue where the Geometry closest = results.getClosestCollision().getGeometry() , return the inner mesh of my node that is selected :confused:

I’m not getting the spatial with this, but the inner mesh of the spatial, is there a way to get the closes Spatial Node parent?
Ive already added a bounding box around my node, but the submesh boudn s keep triggering :confused:

That’s because the intersection collides with geometries not nodes.

Just traverse up the parents of the hit geometry if that is what you are interested in.

but when do I know when to stop?
won’t it continue going up until the rootnode?
or is there a way to disable the bounding box of the mesh?

my solution : add a userdata telling if its a model Node. and go up untill model node is found.

not sure if its the usual thing todo but it works.

That’s essentially what I do.

For example I could have any clickable items in the screen. Whenever you click it finds the first geometry. It then traverses up the scene graph for the first “clickable” user data and then calls the clicked method in that user data.

Note: the Lemur code would have taken care of that for you, too… since it traverses up until it finds the MouseEventControl.