Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
The DDConvexHull dependency node is intended to be as easy to use a possible, making few assumptions about pipelines. For example, the two scripts, AEDDConvexHullTemplate.mel and DDConvexHullUtils.py, are completely optional. If a TD wants to write their own utilities for the node, they are free to do so.
Once the plug-in is built, simply copy it to a location found in your MAYA_PLUG_IN_PATH. On Windows, the default location is:
If the scripts are desirable, then copy the scripts into a location found in your script path. On Windows, a default location is here:
On OSX, that location is here:
NOTE: For the MEL script to be found, it must live somewhere in the MAYA_SCRIPT_PATH. For the python scripts to be found, the must live somewhere in the PYTHONPATH. The example paths above typically satisfy both requirements, as they are factory default paths.
Because DDConvexHull is a simple dependency node, it needs to have its output plugged into something capable of rendering an MFnMesh object (such as mesh node). Typically, the dependency graph looks like this:
Below is an example of a script that would create a valid convex hull:
import maya.cmds as cmds # Create the nodes inputMesh = 'polySurface1Shape' convexHullNode = cmds.createNode('DDConvexHull') outputMeshNode = cmds.createNode('mesh', n='outputHullShape') # Connect the input to the hull node cmds.connectAttr('%s.outMesh' % inputMesh, '%s.input.inputPolymesh' % convexHullNode) # Optional - Only act on the first 100 vertices of the input mesh cmds.setAttr('%s.input.ics' % convexHullNode, 1, type='componentList', *['vtx[0:100]']) # Connect the output of the hull to the input of the outputMeshNode cmds.connectAttr('%s.output' % convexHullNode, '%s.inMesh' % outputMeshNode)
DDConvexHull comes with two scripts: a custom attribute editor template, and a utilities script. Both are intended to make working with the convex hull a little easier for both artists, and TDs. While usage of the scripts is not necessary for the hull to function correctly, the Attribute Editor script (AEDDConvexHullTemplate.mel) does depend on the utilities script.
Adding Objects via DDConvexHull Custom Attribute Editor
The custom attribute editor for DDConvexHull provides a button that allows users to add their selected objects and components to the inputs of the convex hull. To add objects:
- Create the hull node if one doesn't exist
- Select the hull node and bring up the attribute editor
- Make a selection of objects or components in the scene. Notice that the attribute editor will typically switch focus to the current selection
- Under the Focus menu in the attribute editor, select your hull node from the menu. This will change the attribute editor's focus, but the viewport selection will still be retained.
- Under the "Convex Hull Inputs" frame, click on the "Add Selected" button.
Adding the selected objects first add any new meshes as inputs to the hull that are not already connected. Then, it will add any of the selected components to the appropriately matched input slot. This makes it super easy for the artist to add additional points for multiple render meshes into the collision hull
Adding Objects via DDConvexHullUtils.py
The "Add Selected" functionality doesn't live in the Attribute Editor code, instead it lives in the utilities script (DDConvexHullUtils.py). This allows a TD or Technical Artist to add the functionality to menus or shelves elsewhere in Maya.
import DDConvexHullUtils # Get the selection (should include the hull node) selection = cmds.ls(sl=True,l=True) # From the selection grab any hull nodes hullSet = set(cmds.ls(selection, type='DDConvexHull')) # Remove the hull nodes from the original selection selectionSet = set(selectionSet) - hullSet # Add the selected objects to the selected hulls for hull in hullSet: DDConvexHullUtils.addObjects(hull, objects=selectionSet)