3ds Max - Using Compounds in MCG

By
-
Login to Follow
-
Industry
  • Games
  • Design Visualization
Subject
  • Modeling
  • 2016
  • Lighting and Rendering
  • MCG
Products
  • 3ds Max
Skill Level
  • Intermediate
Duration
12 min

3ds Max - Using Compounds in MCG

In this tutorial, you learn how to create compounds in MCG. Compounds are essentially sub-graphs, designed to reduce the complexity of a tree structure by combining elements together.


Notes

  • Recorded in: 3ds Max 2016
  • The interface in this tutorial applies to MCG 2017. The interface in MCG 2018 has been revised to a new node naming scheme.

Transcript

00:00:06 --> 00:00:16
In this movie, you learn about compounds, which are essentially sub-graphs designed to simplify redundancy in your MCG tree layouts.

00:00:16 --> 00:00:23
To learn about compounds, you will be creating a new modifier that constrains an object between two others.

00:00:23 --> 00:00:31
It's a bit like using the Position Constraint tool that works at an animation controller level, but here, you use it as a modifier.

00:00:32 --> 00:00:39
You will need a few objects to work with, open the scene named Compounds.max you downloaded for this tutorial.

00:00:40 --> 00:00:46
It shows a bolt and a nut, and a simple washer that you need to constrain between the two.

00:00:47 --> 00:00:54
The pivot points are set in the center of the nut, washer and the bolt head.

00:00:56 --> 00:00:59
Go to the Max Creation Graph Editor.

00:01:00 --> 00:01:04
You start building your graph using the base operators you know you need.

00:01:04 --> 00:01:10
You know you need two input nodes for the master objects, in this case the nut and bolt.

00:01:11 --> 00:01:16
From the Parameters section, drag in two INode operators.

00:01:18 --> 00:01:24
Name them Object 1 and Object 2, or maybe Master 1 and Master 2 if you prefer.

00:01:25 --> 00:01:28
Here, you may want to add a validity check.

00:01:28 --> 00:01:35
It would serve as a check test that the two master objects are properly selected, and prevents any errors in the script.

00:01:36 --> 00:01:45
Press X and search for operators beginning with "check". You'll find one named CheckNodeValidity, go ahead and select it.

00:01:46 --> 00:01:51
Use Shift+Move to duplicate it, as you need one for each master object.

00:01:52 --> 00:01:54
Go ahead and make the connections.

00:01:57 --> 00:02:03
Drag out the "value" output socket, and look for operators based on the word "node".

00:02:04 --> 00:02:10
Since you're mainly interested in the master object's position, choose the NodePosition operator.

00:02:11 --> 00:02:19
Repeat for the other master object. As this point in the design of the graph, you're basically duplicating the branch for both master objects.

00:02:19 --> 00:02:25
Ultimately, the washer is dependent on the position of both master objects in space.

00:02:26 --> 00:02:33
In order to constrain the washer between them, you need to add these positions together and then divide them by 2.

00:02:34 --> 00:02:42
You'll need an "Add" operator, andyou'll need to wire the two vector positions of the master objects to it.

00:02:46 --> 00:02:55
To divide these position vectors by 2, search for the word "divide" and choose the "DivideByScalar" operator.

00:02:57 --> 00:03:07
Feed the added vectors into the v (Vector 3) socket and temporarily set the amount to a constant value of 2.0. You'll change that later.

00:03:08 --> 00:03:18
The graph so far caters for the two master objects, but you still need input from the bottom of the stack, input about the actual object you want to constrain.

00:03:18 --> 00:03:24
In this case we're talking about the washer which is the object you want to apply the modifier to.

00:03:25 --> 00:03:34
To collect info from the bottom of the modifier stack, about the selected geometry, you need to add a "Modifier: Trimesh" operator.

00:03:34 --> 00:03:41
You can search for it or drag it from the Implicit parameters section.

00:03:42 --> 00:03:48
To control the transforms of the selected mesh, you also need a TransformMesh operator.

00:03:48 --> 00:03:54
Search for it using the X key, which is often easier than browsing through the categories.

00:03:55 --> 00:04:02
Wire the mesh data together, The Modifier: Trimesh value to the TransformMesh, mesh input.

00:04:03 --> 00:04:10
You still need to define the actual transform value which is based on the tree you created a moment ago.

00:04:11 --> 00:04:20
However, note that the master objects' tree output ends with a vector, whereas the TransformMesh takes its feed from a matrix.

00:04:21 --> 00:04:24
If you tried to wire the two together, it would not work.

00:04:25 --> 00:04:29
You need a translation operator between the two.

00:04:30 --> 00:04:32
Search for that word,

00:04:34 --> 00:04:39
and add a TranslationMatrix so you can wire the sockets properly.

00:04:40 --> 00:04:48
You're almost done; all that's left is to add an Output: modifier operator to bind everything together.

00:04:56 --> 00:04:58
Save your graph,

00:05:00 --> 00:05:09
and name it: MCG_PositionConstraint, the MCG prefix is meant to make it easier to find in the modifier list.

00:05:10 --> 00:05:17
Press Ctrl+E to evaluate the graph. Select the washer and go to the Modify panel.

00:05:18 --> 00:05:23
Note you have a new MCG-based modifier, go ahead and apply it.

00:05:24 --> 00:05:27
Select the two master objects,

00:05:29 --> 00:05:34
and note that changing their positions affects the position of the washer.

00:05:35 --> 00:05:41
Note that the tool doesn't explicitly move the washer between the two other objects, not yet anyway.

00:05:42 --> 00:05:47
You still have manual control over the position of the washer. You'll adjust that in a moment.

00:05:47 --> 00:05:53
First, you take a look at creating a compound, which is really what this tutorial is all about.

00:05:54 --> 00:05:59
Look at your graph, mostly at the section related to the two master objects.

00:06:00 --> 00:06:06
You will be compiling the mid-section into a compound or a sub-graph, to simplify the layout.

00:06:07 --> 00:06:13
Select the middle section, all the blue operators and the orange constant operator.

00:06:13 --> 00:06:16
Right-click and copy them to memory.

00:06:17 --> 00:06:26
Now right-click the tab section and create a new view, and then paste the operators in with a right-click.

00:06:30 --> 00:06:35
Add an Output: compound operator at the head of that graph.

00:06:36 --> 00:06:42
Also, you need two node operators at the tail of the graph, to generate input sockets for the compound.

00:06:43 --> 00:06:50
Select the two "NodePosition" operators and with a right-click, choose Generate Inputs.

00:06:51 --> 00:06:57
Rename the inputs Node 1 and Node 2 or Object 1 and Object 2 as you see fit.

00:07:02 --> 00:07:08
Choose Save As. So far, you have been saving graphs as .maxtool files.

00:07:08 --> 00:07:13
There is also an option to save .maxcompound files.

00:07:14 --> 00:07:24
Name the new compound "MCG_ConstrainBetweenTwoNodes" and make sure you save it to the Compounds folder.

00:07:26 --> 00:07:33
You can give the file any name you want but we'll stick with the MCG_ prefix naming convention we have set up.

00:07:35 --> 00:07:41
Go back to your original graph and move the operators you used to develop your compound.

00:07:42 --> 00:07:47
In order to access any new compounds you create, you need to reload the operators.

00:07:48 --> 00:07:55
Next use the search box to search for MCG and you will find your newly-designed compound.

00:07:55 --> 00:07:58
Select it to add it to the window.

00:08:01 --> 00:08:11
Instead of using six individual operators, you can now re-route your tree through the compound, resulting in a much simpler graph.

00:08:21 --> 00:08:26
In fact you can even delete the old operators as you won't need them anymore.

00:08:32 --> 00:08:37
Save your graph one more time and press Ctrl+E to evaluate it again.

00:08:38 --> 00:08:46
If you want to be sure the new graph is behaving as before, delete the existing modifier and reapply it.

00:08:48 --> 00:08:53
Test the results; they should be identical to the previous behavior.

00:08:56 --> 00:09:02
Next you need to negate the washer's transforms, to make sure it relocates between the two master objects.

00:09:03 --> 00:09:11
For that, you need another Implicit parameter operator named Modifier: Matrix. Go ahead and add it to the graph.

00:09:12 --> 00:09:18
This represents the transform space of the selected object at the bottom of the stack, in this case the washer.

00:09:19 --> 00:09:23
You need to convert that space into the space defined by the two master objects.

00:09:24 --> 00:09:29
For that, you need another existing compound named MeshInLocalSpace.

00:09:30 --> 00:09:36
Search for it using the X key and add it to the graph.

00:09:37 --> 00:09:44
Link the Modifier: Matrix value to the matrix input socket of the new compound.

00:09:44 --> 00:09:51
Next you need to reroute the graph through this new operator before you output the final modifier.

00:09:55 --> 00:09:59
Save the graph and evaluate it again.

00:10:01 --> 00:10:08
Note that the washer is indeed between the two master objects, and that you cannot move it anymore.

00:10:08 --> 00:10:14
Its position however is still dependent on that of the nut and the bolt.

00:10:16 --> 00:10:21
Congratulations, you have learned to create a graph and a sub-graph in the form of a compound.

00:10:22 --> 00:10:26
Editing the compound at this point would update the final graph.

00:10:26 --> 00:10:35
As an example, go to the constraint compound graph you created and add a Lerp operator.

00:10:35 --> 00:10:42
Lerp enables you to specify a Linear Interpolation between two vectors by defining an amount value.

00:10:43 --> 00:10:50
Here, you will use it instead of the Add, DivideByScalar and Constant operators.

00:10:51 --> 00:10:53
Go ahead and delete those,

00:10:56 --> 00:11:00
and re-route the graph through the Lerp operator.

00:11:03 --> 00:11:08
For the amount input, use an Input: Single operator,

00:11:10 --> 00:11:13
and name it: "weight"

00:11:15 --> 00:11:19
Save your compound and go back to the main graph window.

00:11:25 --> 00:11:31
Reload the operators for good measure; you'll notice the new weight entry in the compound operator.

00:11:33 --> 00:11:36
Add a Parameter: Single to it,

00:11:40 --> 00:11:49
and set the limits form 0.0 to 1.0, with a default value of 0.5, which represents the halfway distance.

00:11:50 --> 00:11:57
Change the name to "Weight:", this name represents the label that you see in the Command panel.

00:11:57 --> 00:12:00
Save and evaluate your graph.

00:12:02 --> 00:12:06
Test out the modifier to ensure it's behaving as designed.

00:12:07 --> 00:12:12
Granted, this modifier is not particularly powerful, not when compared with animation constraints.

00:12:12 --> 00:12:19
It was only meant to showcase how you can build compounds by putting operators together to simplify graph creation.

00:12:20 --> 00:12:24
Feel free to come up with your own ideas and share them with us if you can.

Posted By
Tags
  • 3ds Max
  • Modeling
  • 2016
  • Lighting and Rendering
  • MCG
0 Comments
To post a comment please login or register
*Save $70 per month on Autodesk's Suggested Retail Price (SRP) when purchasing 1 year term 3ds Max or Maya subscription.