XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : How to move a locator along a vector until it intersects a surface?

09-17-2010, 09:59 AM
I'm trying to figure out how to write a script to move a locator in camera Z until it intersects the nearest surface. I've seen it done at a studio I was working at years ago but I'm a bit baffled. I can work out the vector to move it in but not how to work out when it 'hits' something...
Can anyone help? [I'm using MEL]

09-17-2010, 10:18 AM
I guess it's not possible only using mel, how ever you can use python to import openMaya module and use MFnMesh::intersect fuction to achieve that, there's lot python script do that on creativecrash.

09-17-2010, 10:23 AM
Thanks for that - I think it must be possible with MEL because I've seen it done. I'll have a look at the python you mention but I've never used it before so I may be a bit stumped. Thanks anyway...

09-17-2010, 07:20 PM
It's probably possible with base MEL using some crazy-ass hack like particle collisions or booleans, insanely slow maths or something equally unfeasible in practice, but there is a pretty popular plug-in called rayIntersect which gives you a new MEL command called rayIntersect that does exactly what you want (it's basically a wrapper for the API classes already mentioned). If you've seen this done using just MEL before, chances are it was using this plug-in command.

Do a CGTalk search for rayIntersect and you'll find it... in fact I'm sure I even posted the source code here at one point...


09-17-2010, 10:18 PM
Great! - thanks very much for the tip Nathan, I will look that up

CGTalk Moderation
09-17-2010, 10:18 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.