def set_connection_offsets(connection_data): '''applies offset positions to the input dictionary input > [{'source':string, 'target':string, 'setPosition':bool, 'setRotation':bool}...] output > [{'source':string, 'target':string, 'setPosition':bool, 'setRotation':bool, 'offsetPosition':(3), 'offsetForward':(3), 'offsetUp':(3)}...]''' for i, connection in enumerate(connection_data): source_pos = POS.get(connection['source'], asEuclid=True) target_pos = POS.get(connection['target'], asEuclid=True) v = target_pos - source_pos connection['positionOffset'] = [v.x, v.y, v.z] v = TRANS.transformInverseDirection( connection['source'], TRANS.transformDirection(connection['target'], euclid.Vector3(0, 0, 1))) connection['offsetForward'] = [v.x, v.y, v.z] v = TRANS.transformInverseDirection( connection['source'], TRANS.transformDirection(connection['target'], euclid.Vector3(0, 1, 0))) connection['offsetUp'] = [v.x, v.y, v.z]
def bake(connection_data, start, end): bake_range = range( int(math.floor(start)), int(math.floor(end+1))) if end < start: bake_range = range(int(math.floor(end)),int(math.floor(start+1))) bake_range.reverse() for i in bake_range: mc.currentTime(i) for conn in connection_data: source_pos = POS.get(conn['source']) if conn['setPosition']: positionOffset = euclid.Vector3(0,0,0) if 'positionOffset' in conn: pos = conn['positionOffset'] positionOffset = euclid.Vector3(pos[0], pos[1], pos[2]) wanted_position = source_pos + positionOffset POS.set(conn['target'], [wanted_position.x, wanted_position.y, wanted_position.z]) mc.setKeyframe('%s.translate' % conn['target']) target_pos = POS.get(conn['target']) if conn['setRotation']: offsetForward = euclid.Vector3(0,0,1) if 'offsetForward' in conn: fwd = conn['offsetForward'] offsetForward = euclid.Vector3(fwd[0], fwd[1], fwd[2]) offsetUp = euclid.Vector3(0,1,0) if 'offsetUp' in conn: up = conn['offsetUp'] offsetUp = euclid.Vector3(up[0], up[1], up[2]) fwd = TRANS.transformDirection(conn['source'], offsetForward) up = TRANS.transformDirection(conn['source'], offsetUp) SNAP.aim_atPoint(conn['target'], target_pos + fwd, vectorUp=up, mode='matrix') mc.setKeyframe('%s.rotate' % conn['target'])
cgmMeta.cgmObject(_root).getListPathTo(_rootRoot) TRANS.get_listPathTo(_root, _rootRoot,False) TRANS.is_parentTo(_root,TRANS.parents_get(_root)[0]) _root = 'NotBatman_master_block' _root = 'NotBatman_master_block|curveShape2' _root = 'NotBatman_master_block.cv[50]' _root = 'NotBatman_master_block.ep[26]' _root = 'NotBatman_master_block2' TRANS.sibblings_get(_root,False) TRANS.shapes_get(_root) TRANS.get_rootList() #...transform matrix stuff... _v = [1,1,1] TRANS.worldMatrix_get(_root,True) TRANS.transformDirection(_root,_v) TRANS.transformPoint(_root,_v) TRANS.transformInverseDirection(_root,_v) TRANS.transformInversePoint(_root,_v) TRANS.euclidVector3Arg([0,0,0]) #...creation TRANS.child_create(_root) TRANS.parent_create(_root) TRANS.group_me(_root)