This post covers a way on how to quickly insert any kind of controllers into a 3ds Max CAT rig.
The cool thing about this is, that you have some sort of animation control in the base layer. Each additional CAT animation layer can access and use these controllers! This saves a lot of extra rigging efforts and is really useful and cool.
How to read this post:
Basically, I wrote the tutorial in reverse. The final script is at the end.
I started with a simple task and simple code snippets. They can be copy and pasted in the 3ds Max Script Editor and executed but may not work properly, since it’s missing a function call or some variables.
3ds Max Main Bar – Scripting – MAXScript Editor…
CTRL + E – to execute the code
But to make it all work together you should read till the end.
This is clearly not very max script beginner friendly. I don’t want to cover stuff, that others explained already so well.
-> Check the links from my little 3ds Max Scripting foreword.
Check this simple function to insert a rotation noise in a rotation list:
fn createNoiseControllersOn obj = ( obj.layertrans.controller.Setup.controller.Rotation.controller = Euler_XYZ() obj.layertrans.controller.Setup.controller.Rotation.controller = rotation_list () noiseRotationCtl = Noise_rotation () obj.layertrans.controller.Setup.controller.Rotation.controller.Available.controller = noiseRotationCtl obj.layertrans.controller.Setup.controller.Rotation.controller.active = 1 noiseRotationCtl.seed = random 0 64000 )
What it does:
- It takes an variable „obj“ as input to work on.
- obj tells 3dsMax to use the transform controller of the passed object
- .layertrans.controller.Setup.controller.Rotation.controller -> drills down the controller hierarchy to the currently assigned rotation controller (which is a Euler_XYZ by default)
- You could also write obj.controller. It’s just the hierarchy and the number of sub-controllers. See Image2 for reference.
- I am resetting it here by assigning it again (just in case I had a list or something else before. Carful! You are deleting any animation you might have on that controller!)
- = rotation_list() is assigning a new list controller
- noiseRotationCtl gets a new Noise Rotation controller assigned, which we then insert in the rotation list „available“ slot.
- .active = 1 – sets the first controller (the Euler_XYZ controler) as active list controller again. (to be still able to grab and rotate the bone)
- then we simply randomize the noise seed of the current noise controller, so the fingers are not wiggleing all in the same way
ATTENTION: You have to enable „Animation Controllers“ in 3ds Max CAT rig Setup mode to be able to insert controllers in the base layers. See Image1.
Now to use this function, you need to call it for each selected object.
You could do it like this:
for obj in selection where classof obj == CATbone and classOf obj.digitData == CATDigitSegTrans do ( createNoiseControllersOn obj )
What it does:
- selection – is a keyword in max script, that holds an array of all currently selected objects. very handy (and sometimes tricky..)!
- for obj in selection do ( … ) – a simple for loop that takes each array item as „obj“ and do stuff with it
- the optinal „where classof obj == CATbone“ and „and classOf obj.digitData == CATDigitSegTrans“ checks if you actually selected a CATBone and also if it’s a finger. (You can change that or delete the second part of course, if you like to do this on other objects)
- then inside the do ( … ) part, we call the function „createNoiseControllersOn“ and pass the current obj
3ds Max Script Test Interface
To have a little interfaceuse the following simple MaxScript Rollout snippet (I recommend reading this article about rollouts).
All you need now is to take a 3ds Max CAT rig and play around with the fingers.
Controlling and connecting all these new noise rotation controllers will be covered in another blog post.
try(DestroyDialog pixhellmann_Insert_CAT_Controllers_Demo)catch() Rollout pixhellmann_Insert_CAT_Controllers_Demo "pixhellmann.com Insert CAT Controllers Demo" ( -- our button to execute the function on each object button btn_process "Do it!" -- our function fn createNoiseControllersOn obj = ( -- reset to default euler XYZ (in case there is already a list) obj.layertrans.controller.Setup.controller.Rotation.controller = Euler_XYZ() --Alternatively: obj.controller = Euler_XYZ() -- now add the list and a new noise rotation controller and make euler XYZ active again, so we can controll it obj.layertrans.controller.Setup.controller.Rotation.controller = rotation_list () -- create a new noise rotation controller noiseRotationCtl = Noise_rotation () -- and assign it to the rotation list obj.layertrans.controller.Setup.controller.Rotation.controller.Available.controller = noiseRotationCtl -- make the Euler XYZ active again so we can still rotate it obj.layertrans.controller.Setup.controller.Rotation.controller.active = 1 -- sets each time a random seed noiseRotationCtl.seed = random 0 64000 ) on btn_process pressed do ( for obj in selection where classof obj == CATbone and classOf obj.digitData == CATDigitSegTrans do ( -- CARFULL IT MAY CRASH, IF YOU HAVE NOT SET TO USE ANIMATION CONTROLLERS IN SETUP MODE IN THE CAT BONE HIERARCHY LINK INFO TAB createNoiseControllersOn obj ) ) ) CreateDialog pixhellmann_Insert_CAT_Controllers_Demo