SEARCH AND PRESS ENTER
Maya API / 24 May 2016
Maya API: Cross section tool

Dynamic section tool in Autodesk Alias is an awfully practical tool for automotive modellers, unfortunately it didn’t exist in Maya… Until now!


Section tool is actually my very first C++ plugin. It displays cross sections of input geometry along given axis. Section plane orientation and distance can be easily set by changing node’s transformations, through custom manipulator or attribute editor. Just like the one in Autodesk Alias. It works in legacy viewport as well as Viewport 2.0.

Update 2016-10-10: Turned out I haven’t tested the Viewport 2.0 thoroughly and  it’s not working correctly. Also the manip does funny things when part of another transform.
Update 2017-01-30: Check the new version of this plugin.

How does the section tool work?

Since Maya API doesn’t provide any direct method for intersecting meshes I came up with the following workflow.

  1. Smooth all input meshes according to their smooth display options.
  2. Join meshes in a single work mesh
  3. Remove faces whose bounding box doesn’t intersect with the section plane(s)
  4. Calculate intersection of each face edge with section plane:

Section tool algorythm

The work mesh

First step is pretty straightforward. We load all the data and generate smooth meshes.

That was easy. Joining meshes however isn’t nearly as simple as you’d expect. There’s surprisingly no merge or join method in the function set. Luckily we can get data structure of each mesh, merge them all together and use the new data structure to generate a new mesh as described in this thread. To create the merged work mesh we first have to define the following variables.

Now we add info about each mesh. Pay attention especially to the last bit.

Finally the work mesh can be created.

The intersection

We have the work mesh, great! We still need to create a set of planes to intersect it. We’re going to set the base plane by defining its normal vector. By applying node’s world mesh to the plane normal, we can change orientation by simply transforming the locator node.

Now that we have all that we need for calculation, we can loop through mesh faces, calculate the intersection and create curve segments. But first, let’s check if bounding boxes of the polygon/plane intersect at all. This won’t give us the curve we want, but it will give us more speed.

The actual intersection algorithm is based on a simple 3D Line Segment and Plane Intersection method.

No Comments

There are not comments on this post yet. Be the first one!

Post your Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.