OK, so I've been trying to find out how to impliment colour per vertex
functionality into a deformer node, without much luck.
>From what information I have gathered already, I have been able to create a
>simple MPxNode that takes an input mesh, and outputs a new mesh, with vertex
>colours set by a colour attribute in the node. This works fine.
Here is what I wrote in that compute function-
def compute(self, plug, pDataBlock):
# inputs
hInMesh = pDataBlock.inputValue( ecs_Colour.aInMesh )
colourValue =
pDataBlock.inputValue(ecs_Colour.aColour).asFloatVector()
# output data handle
hOutMesh = pDataBlock.outputValue( ecs_Colour.aOutMesh )
# create MFnMesh on copy of input mesh
hOutMesh.copy(hInMesh)
meshFn = OpenMaya.MFnMesh(hOutMesh.asMesh())
# get the number of vertecies
vertexCount = meshFn.numVertices()
# create empty variables
colours = OpenMaya.MColorArray()
vertexIndecies = OpenMaya.MIntArray()
# apply all vertecies in mesh with the colour value of the
colour attribute
for i in range(vertexCount):
colours.append(colourValue.x, colourValue.y,
colourValue.z, 1)
vertexIndecies.append(i)
# set the colours
meshFn.setVertexColors(colours, vertexIndecies)
# set plug clean
hOutMesh.setClean()
The problem is that I can't figure out how to get this kind of functionality
working in a deformer node, where I'm not using my own output mesh attribute
any more, but instead need to use the pre made array attribute (outputGeom)
that comes from inheriting MPxDeformerNode.
Can I assume the only change that is needed is the line where I get a
datahandle to the outMesh attribute, to instead get the outputGeom at the
correct index? (several guessed attempts haven't worked so far)
But to be honest I'm not even sure whether I'm going about this the right way,
so does anyone know where I'm going wrong?
Thanks.
Ethan
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.