3ds Max - MCG Clone Modifier - Part 1
In this tutorial, you learn to create a simple yet effective Clone tool that you develop as a modifier using the Max Creation Graph (MCG). In this Part 1, you build a basic graph that caters for a number of duplicates while controlling their XYZ positions or offsets.
- 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.
00:00:07 --> 00:00:14
In this tutorial, you use the Max Creation Graph (or MCG) to develop a simple yet effective Clone tool.
00:00:15 --> 00:00:20
Keep in mind you need 3ds Max 2016 or newer to access MCG.
00:00:20 --> 00:00:29
If you are new to MCG, you may first want to try the tutorial named: "An Introduction to MCG" featured on this channel to cover the basics.
00:00:30 --> 00:00:38
In a new session of 3ds Max 2016 (or newer), choose Scripting > Max Creation Graph Editor.
00:00:39 --> 00:00:46
Since you know the purpose here is to create a Clone Modifier, you may want to start with that, i.e. a Modifier Output.
00:00:47 --> 00:00:51
Drag an Output: modifier operator into the editing area.
00:00:52 --> 00:00:59
Since you're working on a modifier, you also know that you need an object for an input, an object that you want to clone.
00:00:59 --> 00:01:08
Under Implicit parameters, choose the Modifier: TriMesh operator and drag it also into the editing area.
00:01:08 --> 00:01:14
This input represents the selected object, the one that is listed at the bottom of the Modifier stack.
00:01:15 --> 00:01:24
Using this Clone modifier, you want to be able to duplicate an object and control the duplicates placement using transform offsets.
00:01:25 --> 00:01:30
For that reason, you need an operator that enables you to do both.
00:01:30 --> 00:01:37
Use the Search Box tool to look for all operators that are associated with the word "Clone".
00:01:37 --> 00:01:44
You can use the Search Box at the top of the Operators list or by pressing X with the Editing View active.
00:01:45 --> 00:01:51
You will find that there is an operator named CloneAndTransformMesh that seems to fit the bill.
00:01:51 --> 00:01:53
Add it to the working area.
00:01:53 --> 00:01:57
Note that the operators are color-coded, based on their nature.
00:01:58 --> 00:02:04
The CloneAndTransformMesh operator for example is purple, indicating it is a Compound.
00:02:04 --> 00:02:11
A Compound is a collection of operators that are designed to work together, a graph-within-a-graph sort of a thing.
00:02:12 --> 00:02:19
You can see what this sub-graph or compound is like by right-clicking its title and opening it in another tab.
00:02:20 --> 00:02:29
You can see it's made of six operators, one of which is in fact another compound which you can also be opened and viewed in its own tab.
00:02:29 --> 00:02:35
This one reveals yet another compound, which is yet another sub-graph of its own.
00:02:36 --> 00:02:43
You will learn more about compounds in another tutorial. For now, close the additional tabs to go back to your Clone Modifier project.
00:02:44 --> 00:02:52
The CloneAndTransformMesh compound has three inputs; the first one to accommodate a mesh, so that's an easy connection to make.
00:02:53 --> 00:02:59
The second input is to define a duplicate count. Here you want to be able to input a number value.
00:03:00 --> 00:03:07
Drag out the "count" input socket and type "param" for parameter. Two options are displayed.
00:03:08 --> 00:03:18
Choose the Int32 which is an integer or a whole number. You don't care about decimals when you're specifying a clone count.
00:03:18 --> 00:03:23
Give the new operator a name, such as "Number of Clones"
00:03:24 --> 00:03:30
Set the min and default values to 1 and leave the max value at 100 for now.
00:03:31 --> 00:03:37
You still need to define the Transform (Matrix) input but we'll come back to that in a second.
00:03:37 --> 00:03:43
First consider the value (IArray) output. This represents the cloned objects result.
00:03:44 --> 00:03:50
You may consider combining all the clones you create into a single object to make scene management easier.
00:03:51 --> 00:03:57
Drag out the value (IArray) socket and look for "Combine".
00:03:57 --> 00:04:03
Choose the CombineAllMeshes operator to combine all duplicates as a single object.
00:04:03 --> 00:04:09
You can now connect the CombineAllMeshes output to the Output: modifier input.
00:04:10 --> 00:04:14
Let's go back and take a look at the transform (Matrix) input.
00:04:14 --> 00:04:19
As you know, transforms relate to Position, Rotation and Scale.
00:04:19 --> 00:04:24
A Transform Matrix contains information related to all of these three transforms.
00:04:25 --> 00:04:36
Start with Position; drag out the transform(Matrix) input and look for a TranslationMatrix operator. Translation in 3D lingo is a synonym for Position.
00:04:37 --> 00:04:43
The TranslationMatrix operator has an input for a vector, which relates to the XYZ axes.
00:04:44 --> 00:04:48
Connect a Vector3 operator to it.
00:04:51 --> 00:04:54
Now you have access to define the three axis inputs.
00:04:54 --> 00:05:05
Essentially you will be feeding a position vector data into a position (or translation) matrix, which in itself feeds into the larger Transform Matrix.
00:05:05 --> 00:05:10
You still need to define the XYZ inputs of the Vector3 operator though.
00:05:11 --> 00:05:18
To make things a little easier to understand, start by setting the Y and Z inputs to a constant with a value of 0.0
00:05:19 --> 00:05:25
This means that you will temporarily only get duplicates offset in the X direction.
00:05:31 --> 00:05:41
To define the X input, add a Parameter: Single operator to it. Here you use Single so that you can use decimal numbers.
00:05:42 --> 00:05:48
Give it a name, such as "X Offset" and adjust the other values if you want.
00:05:48 --> 00:05:55
Setting a default value other than 0.0 would ensure that you see something on screen as soon as you define the number of clones.
00:05:55 --> 00:06:05
Try a value of 10.0 for starters. Always remember to add a .0 to any value you want to use as a float or decimal value.
00:06:06 --> 00:06:12
You're actually ready to test your new modifier. Choose Save As and give your new modifier a name.
00:06:12 --> 00:06:20
Name it MCG_Clone, the MCG_ prefix is meant to make it easier to find in the Modifier list.
00:06:21 --> 00:06:28
Also note that the new graph you are creating is saved under your user name, in a sub-folder named Max Creation Graph.
00:06:30 --> 00:06:37
Once it is saved, choose Build > Evaluate so you can actually use it in 3ds Max.
00:06:38 --> 00:06:45
Create a simple object such as a teapot or even a simple box, and go to the Modify panel.
00:06:46 --> 00:06:51
Note that you have a new modifier named MCG_Clone. Go ahead and select it.
00:06:51 --> 00:06:58
It has two parameters, one to define the number of clones and one to define the X Offset.
00:06:58 --> 00:07:09
Note that the Number of Clones label is too long. Change it in the graph to "# of Clones" using the number sign instead of the letters.
00:07:10 --> 00:07:17
Also add colons to both labels in the graph to add a small separation between labels and input boxes.
00:07:18 --> 00:07:26
When you change a value, make sure you press Enter to confirm the changes; otherwise they may not carry over to the modifier.
00:07:26 --> 00:07:31
Choose File > Save to update the tool and evaluate it again.
00:07:33 --> 00:07:34
This looks better.
00:07:35 --> 00:07:39
Try it out by varying the number of clones and the distances in X.
00:07:40 --> 00:07:45
This is a good start but you obviously would need offsets in the other directions as well.
00:07:48 --> 00:07:55
In the Max Creation Graph window, delete the Constant operators connected to the Y and Z inputs.
00:07:56 --> 00:08:06
To add parameters similar to the X Offset, you can clone that operator with a simple Shift + Move. This is very similar to the Slate Material Editor Workflow.
00:08:07 --> 00:08:12
Connect the new operators and rename them accordingly.
00:08:17 --> 00:08:19
Save the graph,
00:08:21 --> 00:08:23
and evaluate it again.
00:08:24 --> 00:08:30
Because of the default offset values of 10, the default placement of the clones may seem a bit odd.
00:08:31 --> 00:08:37
You may want to reset the default values to 0.0, now that you understand the offset behavior.
00:08:53 --> 00:08:59
You may need to delete and reapply the modifier for the changes to take effect this time around.
00:09:05 --> 00:09:11
This is a very good start. In the next movie, you add parameters to control the rotation and scale of the clones.