Rigging

‘Fake’ callbacks in 3DSMAX

By August 19, 2011 August 20th, 2011 No Comments

I haven’t used callbacks a lot. I guess I barely needed them, but for advanced behaviours they are amazing. According to MAXScript help…

Callbacks are used to register with 3ds Max functions that are called when specific events occur within 3ds Max. Events that can be monitored are changes to the time slider time and redrawing of viewports. Callbacks are not stored in a 3ds Max scene.

So here I present you an easy way to have a piece of code running without digging too much into complex stuff…

In the same way having a lot of callbacks could make your scene refresh slower, having a lot of these ‘fake’ callbacks could make MAX behave the same way. So be careful when using this ‘perpetual’ behaviours.

Basically the trick consists on executing some code inside a Script Controller, and then returning something according to the property that holds the controller. I’ve used external objects that are not related to the rig to run some calculations that modify it. Just create an object to hold the script, let’s say a Point. Assign a Script Controller to any property, for example, Box. That parameter can be True (returns 1) or False (returns 0). If you open the controller it’s quite probable that says 0. Your last line always has to return the type of value that property is expecting to. If you set this controller on XPosition, it will expect a float. If you put it on a Diffuse channel of a material, it will expect a vector. In this case, it will ask for a boolean.

But before that line you can write whatever you want. For example, a function to change the wirecolor of an object depending of the distance between it and another one. And that’s nice, because the wirecolor property is not animatable, so you are not able to set a controller on it! And that’s brought to you by the magic of Script Controllers, which evaluates non-stop.

This widens your possibilities when building a rig. I tend to use this to prototype quick ideas. And to sum up, the main point is you can use external objects to continuously run code that affects a system.