import maya.OpenMayaMPx as OpenMayaMPx
import maya.OpenMaya as OpenMaya
class BlendNode(OpenMayaMPx.MPxDeformerNode):
kPluginNodeId = OpenMaya.MTypeId(0x00000002)
aBlendMesh = OpenMaya.MObject()
aBlendWeight = OpenMaya.MObject()
def __init__(self):
OpenMayaMPx.MPxDeformerNode.__init__(self)
self.matchedVertices = {}
def compute(self, pPlug, data):
if pPlug == self.outputGeom:
iBlendMesh = data.inputValue(BlendNode.aBlendMesh).asMesh()
fnBlendMesh = OpenMaya.MFnMesh(iBlendMesh)
blendPoints = OpenMaya.MPointArray()
fnBlendMesh.getPoints(blendPoints)
outputMeshHandle = data.outputValue( self.outputGeom ).asMesh()
fnOutputMesh = OpenMaya.MFnMesh(outputMeshHandle)
outputPoints = OpenMaya.MPointArray()
fnOutputMesh.getPoints(outputPoints)
print outputPoints.length()
def deform(self, data, itGeo, localToWorldMatrix, mIndex):
pass
def creator():
return OpenMayaMPx.asMPxPtr(BlendNode())
def initialize():
tAttr = OpenMaya.MFnTypedAttribute()
nAttr = OpenMaya.MFnNumericAttribute()
BlendNode.aBlendMesh = tAttr.create('blendMesh', 'bm', OpenMaya.MFnData.kMesh)
BlendNode.addAttribute( BlendNode.aBlendMesh )
outputGeom = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
BlendNode.attributeAffects(BlendNode.aBlendMesh, outputGeom)
BlendNode.aBlendWeight = nAttr.create('blendWeight', 'bw', OpenMaya.MFnNumericData.kFloat)
nAttr.setKeyable(True)
BlendNode.addAttribute(BlendNode.aBlendWeight)
BlendNode.attributeAffects(BlendNode.aBlendWeight, outputGeom)
# Make deformer weights paintable
cmds.makePaintable('blendNode', 'weights', attrType='multiFloat', shapeMode='deformer')
def initializePlugin(obj):
plugin = OpenMayaMPx.MFnPlugin(obj, 'Chad Vernon', '1.0', 'Any')
try:
plugin.registerNode('blendNode', BlendNode.kPluginNodeId, creator, initialize, OpenMayaMPx.MPxNode.kDeformerNode)
except:
raise RuntimeError, 'Failed to register node'
def uninitializePlugin(obj):
plugin = OpenMayaMPx.MFnPlugin(obj)
try:
plugin.deregisterNode(BlendNode.kPluginNodeId)
except:
raise RuntimeError, 'Failed to deregister node'
Basically what I want to do is to compare the vertices of the input mesh and the output mesh and check which ones are in the same worldSpace, store them in a list, and perform the desired operations in the deform method, I want to move the matched output vertices to the input vertices as shown in the video I shared,
I'm stuck at reading the points from the output Mesh.