[Closed] simpleMeshMod – using intersectray on owningNode in ModifyMesh event
When a node with a simpleMeshMod applied is modified i would like to find some positions on the mesh either with intersectRay or raymeshgridIntersect and store them as a parameter. However, running any method with the node as an argument in the modifyMesh event will cause an infinite loop/stack overflow… even print owningNode . Can i achieve what i’m looking for with simpleMeshMod or should i go another route?
plugin simpleMeshMod hitTestMod
name:"hitTestMod"
classID:#(0x68c129d6, 0x32ec6619)
category:"hit test"
(
parameters main
(
thePos type:#point3
nodeMon type:#maxObject subanim:on
)
on modifyMesh do
(
print "Modifying"
print owningNode.pos
print nodeMon.node.pos
-- will crash max
-- print owningNode
-- will crash max
-- print nodeMon.node
-- will crash max
-- local hitRay = intersectRay owningNode (ray [0,0,0] [0,0,-1])
-- thePos = if hitRay != undefined then hitRay.pos else [0,0,0]
)
on attachedtonode node do
(
nodeMon = NodeTransformMonitor node:node
)
)
came across this for simpleMod, assuming it’s the same for simpleMeshMod modifyMesh handler:
You must not try to access the object being modified from within the map handler as this will attempt to evaluate the scripted modifier again. This will result in an infinite loop and hang 3ds Max.
i guess i’ll have to write my own intersectRay function that takes a trimesh as an argument. How hard could that be? A big thanks to swordslayer for his in depth function publishing tutorial. Still wrapping my head around it, but gave me a practical starting point.