In this post, we’ll be looking at what’s new and what’s changed in MCG 2017. We’ve made a few changes to the operator list, so make sure you take the time to update your graphs if they contain any deprecated operators. These deprecated operators will continue to work in this version of 3ds Max, but it’s a good idea to keep your graphs up-to-date. Here’s an outline of what we’ll be covering in this guide:
- MCG Splines and Shapes
- MCG Controllers
- New Parameter Types
- Stateless Random Number Generation
- Simulation Graphs
- Bullet Physics SDK
- Autodesk CFD Workflows and Reading CSV Data
But First: Migrate your MCGs!
Before we dive in, if you’ve been authoring MCG graphs and compounds, or if you have a bunch of .mcg packages installed in 3ds Max 2016, you’ll need to migrate these files to use them in 3ds Max 2017. To perform this migration, you have three main options:
Option 1: Manually copy the contents of your Tools and Compounds folders from your 3ds Max 2016 user directory (C:\Users\
Option 2: If you only consume .mcg packages, you can simply re-install them in 3ds Max 2017 by selecting Scripting > Install Max Creation Graph (.mcg) Package. You may encounter some deprecation warnings, and if you do, make sure to contact the original package author to make sure he/she updates the graph.
Option 3: If you’re a hard-core MCG developer who wants to keep all his/her tools and compounds in specific directories, consider adding the paths to these directories in the 3ds Max 2017 .ini file (C:\Users\
[MCG Compound Directories]
[MCG Tools Directories]
Alright, now that we’ve got migration covered, put your bath hat on, strap your goggles on tight, and get ready to dive into MCG 2017!
MCG Splines and Shapes
In MCG 2017, you can use the “Output: shape” terminal node to create procedural splines. When you evaluate or install an MCG shape tool, it’ll appear by default under the Create tab > Shapes > Max Creation Graph.
3ds Max 2017 comes with three MCG shape tools pre-installed: MCG_Donut, MCG_SinWave, and MCG_MeshEdgesToSpline, which you can find under the directory: C:\Program Files\Autodesk\3ds Max 2017\MaxCreationGraph\Tools.
The MCG_Donut graph shows how to use the “CombineSplines” operator to merge your splines together into a terminal shape. You can also extract the sub-splines contained within a shape using the “SplineElements” operator, which returns an array of splines.
To convert a sequence of vectors into a spline, use the “CreateSplineFromKnots” operator. The knots correspond to the vertices through which the spline will pass. In the graph below, which you can download at the bottom of this post, we used the “CreateSplineFromKnots” operator to construct a helix spline consisting of small straight lines.
If you have a taste for adventure, you can also try your hand at customizing the following MCG_CirclesOnVertices graph (which you can also download at the bottom of this post). This tool aligns circular splines to the vertices of a mesh using the TransformSpline operator. In fact, we used this graph to create the splash image at the top of this guide.
To help you create procedural animations, MCG 2017 provides a wide range of controller output types, and comes with a collection of pre-installed MCG controller tools. You can access these tools from the Animation > MCG Controllers menu. If you want to see how they were made, you can find their graph definitions under the 3ds Max installation directory: C:\Program Files\Autodesk\3ds Max 2017\MaxCreationGraph\Tools. Here's the set of controller output types available in MCG 2017.
To whet your appetite for MCG controllers, we’ll take a closer look at the “MCG Ray to Surface” controller. To use it, you’ll need a minimum of three objects in your scene:
- A helper object which will act as the origin of the ray.
- An object to constrain. For a smoother workflow, make sure this object’s forward direction points along its local positive X axis.
- A surface to which the object will be constrained.
Once your scene is ready, select the object you want to constrain, then go to Animation > MCG Controllers > MCG Ray to Surface Transform Constraint. You’ll need to have an object selected to enable this menu item, otherwise it will remain greyed-out.
When you select the “MCG Ray to Surface Transform Constraint” menu item, you’ll enter a picking session. The first object you need to pick is the surface to which you want to constrain the object. The second object you need to pick is the helper from which the ray will be emitted. By default, this ray will be fired along the helper’s negative Z axis.
You can add another helper to your scene to control the orientation of the constrained object. In the image below, we used a Dummy helper as the controller’s “Forward Object”.
Once your constraint is complete, you can animate the Point Helper to control the path of the object as it reacts to changes on the surface.
For those who are looking to use MCG controllers in their material graphs, we’ll take a quick detour to cover the use of the “MCG_ColorFromDistance” Point4 controller, which you can download at the bottom of this post.
This controller works by blending colors based on the distance between two input nodes. The “Point4” output type was chosen here for its compatibility with the new Physical Material’s Base Color input. Use a “Point3” or a “Color” output type to create a controller compatible with the Standard material’s Diffuse Color input.
To create the material graph above, make sure the “MCG_ColorFromDistance” controller has been correctly installed (or if you’re building it yourself, that it has been correctly saved and evaluated), then open the material editor and drag an “MCG_ColorFromDistance” controller from the “Point4 Controller” section.
Next, drag a Physical Material into the editor. Right-click on it, and select Show/Hide Slots > Additional Params > Base Color. Expand the “Additional Params” section on the node, and connect the output of the “MCG_ColorFromDistance” controller into the “Base Color” slot. To modify the inputs of the controller, double-click on the “MCG_ColorFromDistance” node. This opens a floating rollout in which you can modify the controller’s inputs. In the image above, we used the distance between two point helpers to control the Base Color of each sphere.
New Parameter Types
The 2017 edition of MCG comes with an expanded set of Parameter input nodes, including the highly requested node array.
Node Array (Parameter: IArray
Single Array (Parameter: IArray
Vector3 (Parameter: Vector3): Use this to streamline the definition of vectors instead of relying on three separate Parameter: Single inputs.
Color (Parameter: Color): Use this to provide a color-picker in the rollout. The resulting Vector3 represents a color in the decimal range [0.0, 0.0, 0.0] to [1.0, 1.0, 1.0] instead of an integer-based definition between [0,0,0] and [255,255,255].
Asset (Parameter: Asset): Use this to provide the user with a way to browse for a valid file. The result of this parameter is a string representing the path to the selected file. Consider using this parameter to read the contents of a CSV file within your graph.
String (Parameter: String): Allows the user to specify an arbitrary string. Note that you do not need to supply quotation marks to define the string in the default value box.
Signal (Parameter: Signal): Not to be confused with the “Single” parameter, the Signal parameter provides a way to trigger a special portion of the graph on that execution cycle. The signal button was conceived to enable “baking” workflows. For example, you can use it in a geometry tool to “bake” node instances into your scene. Baking workflows can be very helpful when you want to export a procedural layout for consumption in a game engine. To give you a basic idea of how to use it, here’s the MCG_RadialInstancer, which you can download at the bottom of this post.
Stateless Random Number Generation
In the previous version of MCG, the random number generators came with their own set of complications; when they were placed inside a function, they were continuously re-created, causing them to generate the same random number repeatedly. You could get around this by using some “Bind” magic, however this wasn’t the most intuitive option.
To maintain backwards compatibility, we didn’t remove the previous random number generation operators, however we did add the “RandInt” and “RandFloat” operators to make random number generation more consistent and more controllable.
The “RandInt” and “RandFloat” operators are implemented as fast and stateless hashing functions, which means that you need to supply a seed to control the permutation, as well as an index to obtain the “nth” random number in that permutation (the algorithm is nonetheless O(1)). The result of RandInt is a random 32-bit integer, and the result of RandFloat is a random floating point value between 0.0 and 1.0.
In the graph above, we generated three random values per vector with the RandFloat operator - one for each X, Y, and Z component. Since we only had one index to work with (i.e. the function argument), we needed to re-hash it with the RandInt operator to obtain new indices for the Y and Z components. This adds a bit of overhead, but the experience is now more consistent. Consider creating your own compounds based on RandInt and RandFloat to control your random number generation for vectors, matrices, quaternions, etc.
One of the big challenges related to authoring history-dependent procedural effects such as n-body simulations and rigid body animations is to correctly synchronize the time step of the simulation with the host scene’s representation of the current time.
In MCG 2017, you can use the “Is Simulation” checkbox under Edit > Graph Properties to ensure that the data stored inside your Cache operators (which you use to represent the state of your simulation) is cleared when the timeline reverts back to frame 0. Keep in mind that when you switch between two frames, if your next frame is earlier than your previous one, the simulation will re-run itself up to that point (which might appear as a slow-down when you manipulate the timeline backwards in time). Additionally, if you’re working with an MCG simulation, it’s usually best to disable the “Real Time” mode in your timeline to ensure consistency.
That being said, MCG simulations don’t have to be complicated to be useful. To give you an idea of how to create a history-dependent simulation graph, we’ve written the MCG_MeshPlotter which you can download at the bottom of this post. No fancy calculations here - we’re just appending a vector to a growing array of vectors, and displaying that array as a spline.
The result of this tool is a plot of the progress of the center of a mesh, which is displayed as a spline. In the image below, we used it to plot the progression of a cone as it travels around a helix.
The topic of MCG simulations leads down a very deep rabbit hole, and from our initial experiments, it has a very promising outlook. In fact, we wrote an n-body simulation purely in MCG, which we’ll cover in more detail in a later post. Here’s a render of our result to get your own creative juices flowing:
Bullet Physics SDK
The MCG 2017 operator list now exposes a subset of the Bullet Physics SDK. With these operators, you can simulate rigid bodies and joint constraints inside an MCG graph. We leveraged our exposure of the Bullet Physics SDK to create the MCG DOF Rotation Spring Controllers, which you can find under the Animation > MCG Controllers menu.
In the scene below, we used an MCG 3 DOF Rotation Controller to drive the animation of a wrecking ball attached to a crane. The wrecking ball you see below is controlled by an MCG controller, and also acts as a collider inside an mParticle PFlow graph to interact with the stacked boxes.
The "MCG DOF Rotation Controller" is actually a rigid spring connecting the crane and the ball. Given the large mass of the wrecking ball, a thin cylinder was used to represent the high-tension chain between the ball and the root object. In a later tutorial, we’ll show how to use Bullet Physics in MCG to create a more flexible rope-like structure.
To use the "MCG DOF Rotation Controllers", you’ll need three objects in your scene:
- The object you want to animate.
- The convex hull representation of the object you want to animate, placed in the initial pose of your simulation.
- The object to act as the parent of the constraint.
When your scene is ready, select the object you want to animate, then go to Animation > MCG Controllers > MCG 3 DOF Rotation Controller. This begins a picking session. The first object to pick is the parent object of the constraint. The second object to pick is the convex hull representing your animated object. A convex hull is necessary here because the current exposure of Bullet Physics in MCG does not account for concave meshes.
Once your controller is created, toggle the visibility of your convex hull to avoid overlapping faces. You can then animate the position of the parent object to affect the constrained object’s position and rotation. Note that in addition to using Bullet Physics, this tool is implemented as a simulation graph, since it relies on the historical progression of other objects in the scene.
Autodesk CFD Workflows and Reading CSV Data
In 3ds Max 2017, we used MCG to help plot the velocity fields generated by Autodesk CFD. Given the variety of workflows related to CFD data visualization in 3ds Max, I encourage you to consult the documentation presented in the 2017 help guide.
At the core of these CFD importing and visualization tools is the capability to read comma separated values (CSVs) contained in the rows of a given file via the ParseCSVData compound. In fact, if you have a CSV file containing arbitrary data you want to plot, you can use the ParseCSVData compound to extract this data and process it in MCG. For example, we used this approach to generate a map of the world based on the airport coordinates contained within a CSV file.
As a closing thought, I hope this range of examples has convinced you that we’ve only started scratching the surface of what MCG has to offer. As always, I invite you to post your comments and your questions below, and to join the action on our MCG facebook page.
Instructions: Extract the .zip file anywhere on your filesystem. Copy the contained .maxtool files into your Max Creation Graph 2017 user directory (C:\Users\