SHARE
TWEET

Untitled

a guest Aug 14th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2. import collections
  3.  
  4.  
  5. def get_weights(controls, joints):
  6.     distribution = len(joints) / (len(controls) - 1)
  7.  
  8.     weights = collections.OrderedDict()
  9.  
  10.     for cidx, ctrl in enumerate(controls):
  11.         offset = cidx * distribution
  12.         weights.setdefault(ctrl, collections.OrderedDict())
  13.         for jidx, jnt in enumerate(joints):
  14.             weight = (abs(jidx - offset) - distribution) / distribution
  15.             weight = abs(weight) if weight <= 0 else 0.0
  16.  
  17.             weights[ctrl][jnt] = weight
  18.  
  19.     return weights
  20.  
  21.  
  22. joints = ['joint{}'.format(x + 1) for x in range(6)]
  23. controls = ['ctrl{}'.format(x + 1) for x in range(3)]
  24.  
  25.  
  26. print(joints)
  27. print(controls)
  28.  
  29. weigts = get_weights(controls=controls, joints=joints)
  30.  
  31. # No se puede hacer pretty print de un diccionario ordenado
  32. print(json.dumps(weigts, indent=4))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top