Hi everyone,
I’m glad to share with you a custom node that I developed as part of my learning curve with Maya API. This time I wanted to play a little bit with vectors and angles, so I created a custom node that will read the angles created between two objects. Those angles are passed into a curve ramp attribute, that will return a value between zero and one, depending on the curve.
One of the first uses that came to my mind is to drive some corrective blendshapes.
This custom node, is done in Maya Python API 2.0, and it contains three files. The .py node file, where everything happens, the .mel template file, where the node layout it is defined and the .png icon file.
To download the latest version of the node, and read the installation instructions, please visit the wiki page.
I will go a little bit through the idea and the code, so if you are learning by yourself, as me, maybe you could find it interesting.
The concept was to get two objects in the world, and calculate the angles that are generated between them, so to begin, I needed to get the information of two objects. I used the world matrix to get all the information that I needed for the calculations, positions and rotations.
With that information, I calculated the vector from the position of those two objects.
With the reader object rotations and that recently calculated vector, I got the angle generated between then.
I decided that I would have two outputs, for each one of the reader axis. One output that will drive the positives angles and another for the negative ones.
Also I thought that could be nice to be able to determine how those values were going to be returned, having more control over them. So I decided to use a ramp curve attribute, to provide that extra functionality.
At the end, the user will get six outputs from the ramp attributes, two per axis, and another three outputs, will the angle generated on each axis.
If it sounds interesting to you and you want to take a look and try it, please feel free to download it.
dcReader
To make sure you are downloading the latest version, please visit my Bitbucket repository.
Also, there you will find all the necessary instructions of how to install and run properly my reader node.
Please let me know if you find it interesting, if you see it useful, and don’t doubt on get in touch, I will very happy to answer. Let me know if you are using it, I would love to see and know how. Don’t hesitate on visit me on LinkedIn.