After years with Softimage/3dsmax I just moved over to Maya and I’m having problems trying to assign targetweights to blendshapes through scripting. Essentially I am trying to implement the Paint Blendshape Weights tool’s import attribute map functionality.
I’m having trouble finding a function that lets me lookup color values from a texture map per vertex that I would then pass onto the blendshape targetweights as an component array. Echoing all commands to the script editor’s history gives me nothing to work with while painting weights for blendshapes. I noticed this is not the case with vertex colors as artAttrPaintVertexCtx has a importfileload flag which I probably could then query with polyColorPerVertex…
Our team is using a custom plugin written in C++ now to do something very similar. We we’re using the Python Imaging Library previously, but this was slow. Before you ask, no I can’t share the code, but I don’t think it was too difficult to figure out from the examples of similar stuff that Autodesk includes in the SDK. If you do plan on writing your own, and don’t want to jump all the way into C++, take a look at the OpenMaya API. It is faster that the regular Python stuff for most of this.
A quick MEL idea (maybe for prototyping) to get the RGB at vertex is to get the vertex u,v position then use it to get the texture’s RGB via colorAtPoint (i think using this method would depend on uv edge cuts like getting multiple uvs map objects for one vertex, also its probably slow)
I made a short post on some of these prototyping ideas Nathaniel Anozie: Mel Query RGB of Polygon UV.
A quick MEL idea (maybe for prototyping) to get the RGB at vertex is to get the vertex u,v position then use it to get the texture’s RGB via colorAtPoint (i think using this method would depend on uv edge cuts like getting multiple uvs map objects for one vertex, also its probably slow)
I made a short post on some of these prototyping ideas Nathaniel Anozie: Mel Query RGB of Polygon UV.
Thank you for the input! I was hoping for an import function (fast like when using the UI) but did exactly as you described in the end. It is really slow, like 10 seconds to lookup the color values and set the weights for every vertex(~4000 verts)! We’re going to make the lookup a custom node with the API… Nodes are supposedly the strong suit of Maya but I miss Softimage (ICE in particular) a lot right now, but I think it’ll pass once I get more comfortable with Maya