Maya tooling concept

Hey guys, currently working on a simple tool(coded in python) for animators and started wondering what would be the best technique store/access the data.

My first guess was to have a class named CenterOfMass wich has a list of targets that are CenterOfMassTarget.

Then I would have a network node with two attributes. First attribute is metanetwork to link to my rig metanetwork. Second attribute is named data and would store an instance of the class CenterOfMass (serialized in json)


class CenterOfMass(object):
    def __init__(self):
        self.display_radius = 10.0
        self.target_list = []

class CenterOfMassTarget(object):
    def __init__(self):
        self.object = None
        self.weight = None

class CenterOfMassNode(object):
    def __init__(self):
        self.metanetwork = None
        self.data = None

This stuff works but my question is: Is there a better way of doing this?

My second guess would be to have a node in maya for each of my classes and they would all be interconnected.

Any thoughts?

Not 100% sure what you’re trying to achieve, can you give us more detail, are you simply after some form of code based metaData network for your rigs?

I’ll try to explain a bit more.

I want to create a tool to represent the center of mass of a character.

To represent the center of mass, I need a mass for each joint of my character.

So basically yes I need to store metadata.

My question is, what is the best way to store and access that metadata?

[ol]
[li]Add a weight attribute to each of my character joint.
[/li][li]Serialize a list of tuples (object name, weight) and store it in a script/network node.
[/li][li]Create a hierarchy of nodes: A “center of mass” node, connected to multiple “center of mass part” nodes which have a weight attribute and are connected to the skeleton joints.
[/li][li]Any other way?
[/li][/ol]

Hope I’m a little more clear…

I think the vanilla way to do this is to add data-only attributes on the skeleton and then use an expression or a node network to do the math at runtime. If the data is not intended to be editable you can lock it. Since the mass # and the transform data are intimately connected it makes sense to keep them together and storing them in some other structure isn’t adding any real value.

The slightly slicker option would be to create a point-constrained transform to represent the center of mass and use the mass values to set the constraint weights (sum the masses, normalize the results, and use the normalized values to drive the constraints). That keeps more of the math in C++ where it belongs and the graph structure that results is pretty simple – you’d have to decide if it was worth making the weights editable or not…

Keeping the mass on the same objects the position is stored seems a good idea.

For the point-constraint, thats a good idea but I’ll bake the results and remove the point-constraint after. This way the animators will be able to visualize the center of mass curve and I’d like to have the possibility to animate the character using the center of mass.

Here’s an example of what I’m trying to achieve presented by Richard Lico.