Feedback

What's your question?

By: Asked

How do I use the paint attribute tool to paint values into objects located at mesh vertices

I have laid out the info here on my blog:

a href=http://www.hodge.net.au/sam/blog/?p=176

Basically I would like to be able to paint the scale offset of a bunch of geometry hugging to a surface

As scales or feathers.

Ideally I would like to be able to paint 9 grey scale maps tx,ty,tz,rx,ry,rz,sx,sy,sz

I am wanting to do this as a vertex map, looking up the vert for each scale.

But trying to get at a component via an expression or connected attribute seems tougher than it should be.

Is there some mapping that I am not observing.

I guess polyBlindData and a bunch of plugin code would work, but I cant see why what I am doing isnt working

I have done this kind of stuff in XSI before and it wasnt this hard, there was an extra layer ie mesh vert ID != cluster component ID, but the mapping was well documented and accesible.

Where is the mapping between control points array position and vertex position?

  • 3

julian [ Admin ]

Here's some MEL which should be enough to test the attribute-paint vertex indices. It doesn't paint offsets, just direct values to scale and rotate. I tested it on very messy mesh, with a lot of booleans and deleted components, and it seems to hold ok. If you get it working with python, feel free to post it here as another answer ;) Meanwhile I'll add a MEL tag.

To use it, select a mesh and type paintedLocators(); Then use Modify->Paint Attributes Tool

// a proc to place a locator at every vertex
global proc string[] makeLocatorsAtVertices(string $shape) {
    string $locators[]; 
    string $vts[] = `ls -flatten  ($shape+".vtx[*]")`;
    for ($v in $vts) {
        float $p[] = `pointPosition -w $v`;
        string $locs[] = `spaceLocator`;
        setAttr  ($locs[0] + ".t") $p[0] $p[1] $p[2];
        $locators[`size $locators`] = $locs[0] ;
    }
    return $locators;
}


global proc paintedLocators() {

    string $sel[] = `ls -sl -dag -leaf -type "mesh"`;
    string $shape = $sel[0];

    string $locs[] = makeLocatorsAtVertices($shape);
    int $n = size($locs);

    // Make paintable scale and rotate attributes - data type will be multi-float
    // Connect paintable attribute elements to the locator at the matching array position.
    // Set scale default value to 1
    for ($att in {"rx","ry","rz","sx","sy","sz"}) {
        int $isScaleAtt = (substring($a,1,1) == "s");
        addAttr -ln ("feather_"+$att) -im 1 -m -at "float" $shape; 
        makePaintable  -at "multiFloat" "mesh" ("feather_"+$att) ;
        for ($i=0;$i<$n;$i++){
            connectAttr -f ($shape + ".feather_"+$att+"["+$i+"]")   ($locs[$i] + "."+$att) ;
            if ($isScaleAtt) setAttr ($shape + ".feather_"+$att+"["+$i+"]") 1.0;
        }
    }
    select $shape; 
}

One more thing I got some errors at first. There were some lines in an installed maya script that were failing. If you get "procedure not found" errors when you try to select the attribute in the paint attributes tool, comment out the lines in artAttrCreateMenuItems.mel as follows:

change Line 190: to:

} else if ( $paintableNodeType == "mesh") {

and comment out lines 200 - 205

// if ( $currTool != "artClothPaint" ) 
// {
//  artClothPaintToolScript( 4 );
// } else {
//  clothPaintToolOn();
// }

and re source it

NN comments
sam hodge
-

This code seems to do what I need. I will have a look into making it in Python as soon as I get a chance.

or Cancel