Sunday, July 2, 2017

Vectors in Maya 2: Nodes

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)

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 normalize

normalizeNode = 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

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





No comments:

Post a Comment

Maya 2018 Auto Retopo Function

I just found this handy hidden function in Maya 2018 to turn your Mesh into even Quads or Triangles. // MEL //  turn selected mesh int...