PDA

View Full Version : Need IntersectRayEx Help...


PiXeL_MoNKeY
01-09-2009, 12:49 AM
I need to place screws inside holes on some sheet metal objects. So I need to figure out the best way to automate it since it is going to be a few hundred/thousand screws and holes. So I was thinking of extracting shapes of the hole openings, converting to mesh to get faces, exploding the new faces to individual objects, and finally using IntersectRayEx to align the screws to the filled in hole objects. The problem I have is the hole "caps" could be facing any direction so how would I generate a ray that is garanteed to intersect a face on it?

-Eric

ZeBoxx2
01-09-2009, 01:12 AM
Use rayMeshGridIntersect() instead? it has a doubleSided option for its intersectRay().

However... if you presumably already have cap faces - then why not separate the caps into elements and for each element take 1 face, and take that face's face normal as the direction? Can probably use one of the polyops or so methods to determine the 'center' of the cap as well?

PiXeL_MoNKeY
01-09-2009, 01:18 AM
Oh sure be smart, I was over complicating it. I can use the face normal with portions of the Maxscript sample that Bobo did for aligning UVW map to a face. Thanks for pointing that out.

-Eric

PiXeL_MoNKeY
01-10-2009, 12:56 AM
Ok got it pretty much all worked out. Used various approaches to get the center of the element inside the mesh, average the face normals of the element, align the object to that, and then used RayGridMeshIntersect to move it into its final resting place.

I could probably handle most of it with just RayGridMeshIntersect, but what I have now helps to ensure that there isn't an issue of multiple hits returned. Plus I get the average of all the element faces rather than just the hit one.

-Eric

CGTalk Moderation
01-10-2009, 12:56 AM
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.