top of page

Raycasting In Maya (curveInteresect node)

Raycasting is a very important concept to understand in computer graphics. Basically raycasting is like aiming a laser pointer along a vector and seeing if the beam hits something. Disney Studios made a great video that explains raycasting in the context of rendering

In the past I have used cMuscleKeepOut nodes to cast rays to see if they collide with a nurbs surface or mesh. This is a decent technique and is the only technique that works with meshes without requiring you to use the Maya API, but there is an easier technique that works in most cases.

Here's an example. I have a joint segment and a curve (the yellow one). I want to figure out what point on the curve the joint segment needs to aim at. We can't just use a nearestPointOnCurve node to find the point on the curve that is closest to the tip of the joint segment. The result from this method is the red locator (clearly not the right result). Instead we are going to create a curve along the joint segment, extend it, and then see where it intersects the yellow curve.

Here is the node network that gets us the right result (the green locator). We plug both curves into the curveIntersect node, the output is the parameter of the point where they intersect, then we use a pointOnCurveInfo node to convert the parameter value to a world space position value.

But what if the curves don't intersect? Well the default parameter output is 12456.0 (who knows why), so you could use a condition node to check for that output.

Well what if they look like the intersect from one angle but they actually don't? Well, Maya has got you covered. We can set the curveIntersect node to use a specific normal to look for an intersection, basically if you were to take your camera align it with that normal and look at the curves it will tell you where it looks like they intersect.

This technique was shown to me by Hector Barea (another rigger at Boulder Media), hopeful you'll get some use out of it.

Featured Posts
Recent Posts
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page