When using Vector Match in Rigs, we need life update. Creating custom Maya nodes can be done via API scripting but Maya comes with a number of built-in Vector Nodes we can use (even sometimes with a workaround)
# see how i connect the objecsts at the end
normalizeNode = pm.createNode('vectorProduct')
normalizeNode.attr('operation').set(0)
normalizeNode.attr('normalizeOutput').set(1)
multiplyNode.attr('input2').set(3,3,0)
# connect nodes
obj1.translate >> normalizeNode.input1
normalizeNode.output >> multiplyNode.input1
multiplyNode.output >> obj2.translate
obj1, obj2 = pm.PyNode('pSphere1'), pm.PyNode('pSphere2')
# normalize node
normalizeNode = pm.createNode('vectorProduct')
normalizeNode.attr('operation').set(0)
normalizeNode.attr('normalizeOutput').set(1)
# vector length node
dotNode = pm.createNode('vectorProduct')
# connect
normalizeNode.output >> dotNode.input1
obj1.t >> dotNode.input2
dotNode.output >> multiplyNode.input1
Define the objects
obj1, obj2 = pm.PyNode('locator1'), pm.PyNode('locator2')# see how i connect the objecsts at the end
# Normalize
Maya hs node vectorProduct, if we set it to Operation 'None' and Enable 'Normalize' it simple acts as a normalizenormalizeNode = pm.createNode('vectorProduct')
normalizeNode.attr('operation').set(0)
normalizeNode.attr('normalizeOutput').set(1)
# Scale to any length, Lock in one axis if needed
multiplyNode = pm.createNode('multiplyDivide')multiplyNode.attr('input2').set(3,3,0)
# connect nodes
obj1.translate >> normalizeNode.input1
normalizeNode.output >> multiplyNode.input1
multiplyNode.output >> obj2.translate
# Vector Magnitude (length)
To get a vectors length in Maya we 1. normalize it and 2. create dot product of normalized and non normalized
# normalize node
normalizeNode = pm.createNode('vectorProduct')
normalizeNode.attr('operation').set(0)
normalizeNode.attr('normalizeOutput').set(1)
# vector length node
dotNode = pm.createNode('vectorProduct')
# connect
normalizeNode.output >> dotNode.input1
obj1.t >> dotNode.input2
dotNode.output >> multiplyNode.input1
No comments:
Post a Comment