Notifications
Clear all

[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

15 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

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?

 lo1

probably not what you want to hear, but… use intersectRay on a timer?

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

 lo1

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

 lo1

how would that work? mouse.pos is a 2d viewport coord and node.pos is a 3d world coord.

2 Replies
(@lanimal)
Joined: 11 months ago

Posts: 0

i guess something like (gw.transPoint node.pos)

 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

oh, right. thanks.

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.

 lo1

you could also set the tolerance per node, depending on the size of its bounding box.

Page 1 / 2