Having explored many of the possibilities of Python script to a point where I can say I am comfortable with it, I've recently started looking at the Maya Python API, and have been working on my own custom deformer node. Although I am still fairly new and inexperienced with the Maya API.
I'm attempting to recreate a displacement node. So far, the node has three attributes. InputTexture, Magnitude and Offset. I have gotten the node working basically. The problem I have is that I've tried putting animated textures into my InputTexture attribute, but when I play, or scrub through the timeline, the node does not re-evaluate. Despite having used the attributeAffects() method on all three attributes to the output mesh. OK, so from what I have researched, the only way to sample texture nodes is with the sampleShadingNetwork() method in the MRenderUtil class. The very first argument needs the name of a texture attribute as a string. e.g. "noise1.outColor" I had initially gotten the node working by just hard coding the name of a noise nodes outColor attribute (created in the Maya scene beforehand) into the sampleShadingNetwork() method. It was obvious that the deformer node would not re-evaluate when the texture is animated, because the node is in no way connected to the texture. This is when I decided to create my own custom InputTexture attribute for the deformer node. I then got the name of the current instance of the deformer nodes InputTexture attribute, and used that as the string in the sampleShadingNetwork(). That didn't seem to work for whatever reason, and just caused Maya to fatal error when the deformer node is created. My latest and current solution was to instead get the name of the attribute that is connected into my custom InputTexture attribute, and put that into the sampleShadingNetwork(). Again, this only partially worked. The node does re-evaluate when you click through the timeline, and whenever you change the attributes in the texture node, however, scrubbing through the timeline or doing a playblast or render, doesn't cause the node to re-evaluate. A current workaround is to put a tiny (barely noticeable) amount of animation into one of the other attributes in the deformer node. Doing that at least causes the node to re-evaluate, but it still doesn't explain why the texture attribute doesn't seem to detect any changes. Am I to assume that there is a difference between a user manually changing an attribute in Maya or an animation curve/expression/connection changing an attribute? So does anyone know what the problem might be and a possible fix? I've attached a picture of the node network. Also, another minor issue that I have noticed is that there are 2 of several other inherited attributes in the deformer when there should be 1. Has anyone experienced that before? 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 python_inside_maya+unsubscr...@googlegroups.com. To post to this group, send email to python_inside_maya@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
<<attachment: Nodes.JPG>>