Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import collections
- def get_weights(controls, joints):
- distribution = len(joints) / (len(controls) - 1)
- weights = collections.OrderedDict()
- for cidx, ctrl in enumerate(controls):
- offset = cidx * distribution
- weights.setdefault(ctrl, collections.OrderedDict())
- for jidx, jnt in enumerate(joints):
- weight = (abs(jidx - offset) - distribution) / distribution
- weight = abs(weight) if weight <= 0 else 0.0
- weights[ctrl][jnt] = weight
- return weights
- joints = ['joint{}'.format(x + 1) for x in range(6)]
- controls = ['ctrl{}'.format(x + 1) for x in range(3)]
- print(joints)
- print(controls)
- weigts = get_weights(controls=controls, joints=joints)
- # No se puede hacer pretty print de un diccionario ordenado
- print(json.dumps(weigts, indent=4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement