Normalize Distance
 

The idea behind the plug-in is driving other node’s attributes by using distance between two transform nodes.
The plug-in normalizes the distance between two transform nodes and uses it as output data. Thus we can use this output data in order to drive other node’s attributes like bump map value, displacement map value and blendshape weights etc.

I have written the plug-in to use it for facial rigging and animation. However we can use normalizeDistance node pretty much everywhere especially where we need to create deformations.

 
 
Installation
 

Download Norrmalize Distance | 300 KB | rar | Maya 7.0, 8.0, 8.5, 2008, 2009

Way one: Either copy “normalizeDistance.mll” file to your plug-in folder or a folder that you have defined as a plug-in path. Example path: “C:\Program Files\Autodesk\Maya2008\bin\plug-ins”)
Way two: If you are using “Tool Server” copy “normalizeDistance.mll” file under related folder.
Example path: x:\ToolServer\Plugin_mll\2008\NormalizeDistance
Details are available about “Tool Server” on its web page at http://toolserver.safakoner.com

 
 
How To Use
 

Open “normalizeDistanceStart.ma”. Select locator1 and locator2. Type normalizeDistance; in command like and execute it.

Open hypershade, select normalizeDistance1 and click “Input Connection” icon. You must be able to see the connections among two locators and the node.

Drag and drop ramp1 into work area and connect normalizeDistance’s output attribute to ramp1’s alphaGain attribute. Since locator2 has a connected animation curve, normalizeDistance node calculates necessary output data while you are playing the scene.

Go to frame 1 and render the scene. Go to frame 50 render the scene and go to frame 100 and render the scene again. Alternatively change the positions of the locators and render the scene.

 
 
 
Demonstration Movie
 
 
 
How Does It Work
 

As you can notice the distance between two locators is 10 units at frame 1. The node initializes this distance as initial distance and compares it with the distance between these two locators while you changing the locator’s positions. With a calculation this comparison gives us a normalized result.

Thus we are using this result to drive other attributes in this case ramp1’s alphaGain attribute in order to change displacement’s affect.

Calculation method has been set to contract as default. What this does mean is the node normalizes the distance when locators get closer to each other. If you need otherwise you can select expand as calculation method.

Open “normalizeDistanceEnd.ma” and go to frame 100 and render the scene then go to frame 150 and render the scene again. You see that normalizeDistance node is still calculating even the locators are moving away from each other because we have keyframes on calculation method attribute. Since calculation method attribute is keyable, we can use it in our animation as needed.

What will we do if we need to change initial distance? Select normalizeDistance1, open attribute editor and go to frame 25, as you can see the output value is 0.485. Let’s say wee need to receive 0 as output at frame 25 and 1 at frame 50.

Select “normalizeDistance1” node and type setInitialDistance; in command line and execute it. As you can see output value has been changed to 0. Go to frame 50, output value will be 1 as we expected.

You can use “Multiplier” attribute to multiply output result as needed. However since we have limited the output value between 0 and 1 by using “Clamp Min” and “Clamp Max” attributes, you will not be able to see the changes.

Go to frame 150, notice that locator2 is 20 units away from locator1. Set “Clamp Max” attribute to 10. As soon as you change the clamp max value it affects output value. Now set “Multiplier” attribute to 2 and see the result on output value.

Play the animation between frame 100 and 150 and see the result.

Please don't hesitate to contact me. I am pleased to hear your comments, wishes and critiques for further tools. Please kindly send me bug reports.

Thank you for downloading and using the plug-in.