[Closed] Executing a function on mouse over node?
Hi, is it possible to register a callback or another way to fire a function on a mouse over a node?
Thanks,
OZRay
there is no a simple callback to get it. but there are some ways to do it. what do you need to know when the mouse is over a node? do you want to track only geometry or any node?
Hehehehe well not really a performance wise solution… hehehehe
There is really no way in Maxscript with all the callback and mouse tools functions
to trigger a function on mouse over of a node…
May be worth to test it with intersectRay().
It’s not that slow. I’d try it with a timer and some interval.
The question is if you really need it.
There is a script that switches viewports on hover, I don’t know where it is, but you will find it on scriptspot, for inspiration.
Sure I want it if you think that’s not to slow I may give IntersectRay a try
If it’s something that is part of a tool, or runs for a small amount of time, it would probably be feasible. I don’t think I would add it as something that runs throughout the max session.
Hi, is it possible to register a callback or another way to fire a function on a mouse over a node?
without raycasting:
Collect all the nodes you want to check for into an array.
On a timer or callback, compare the mouse.pos to each node.pos in the array.
If the mouse.pos is within a tolerance (episilon) of a node in the array, the mouse is over the node, so put your function here.
with raycasting:
Collect all the nodes you want to check for into an array.
On a timer or callback, shoot a ray from the mouse.pos along the negative zaxis or screen zaxis.
if the ray intersects any element in the array, the mouse is over that node, so put your function here.
hope this helps
how would that work? mouse.pos is a 2d viewport coord and node.pos is a 3d world coord.
Node.pos is the position of the pivot. If the pivot is “outside” of the node then the tolerance will not work. The better solution is to use Node.center.
you could also set the tolerance per node, depending on the size of its bounding box.