Sign in to follow this  

paintable attribute C++ Maya

This topic is 3300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I need to create an array attribute, which defines a value per vertex in a Mesh. My goal is to define a initial value for each vertex in the array attribute and later on, trough the paintable system of Maya change this values to another ones. I can't do this because I have the following issues: If I create an attribute "paintAttr" and make it paintable: addAttr -ln "paintAttr" -dataType "doubleArray"; makePaintable "mesh" "paintAttr"; I'm able to paint the vertex attribute with the values that I choose. But if I want to start the attribute with a default value, and later on to change its values with the instruction makePaintable I can't do it. I tried two approaches in c++, the first one: MPointArray particles; newMesh.getPoints(particles); MGlobal::executeCommand( MString( "addAttr -ln paintAttr -dataType doubleArray " + newMesh.fullPathName(&stat))); MFnDependencyNode fnNode(newMesh.object()); MPlug f = fnNode.findPlug("paintAttr "); int d; MPlug is; for( d = 0; d < particles.length(); d++) { is = f.elementByLogicalIndex(d); is.setValue(0.5); } The program creates the attribute, but it doesn't add the value 0.5 to each position of the array. In the second approach: MPointArray particles; newMesh.getPoints(particles); MObject test; MFnNumericAttribute numFn; test = numFn.create("paintAttr ", "pt", MFnNumericData::kDouble); numFn.setArray(true); newMesh.addAttribute(test); MFnDependencyNode fnNode(newMesh.object()); MPlug f = fnNode.findPlug("paintAttr "); int d; MPlug is; for( d = 0; d < particles.length(); d++) { is = f.elementByLogicalIndex(d); is.setValue(0.5); } The attribute "paintAttr" is defined with the initial value of 0.5 for each vertex, and apparently it can be paintable with: makePaintable "mesh" "paintAttr"; But in reality, when I try to paint the vertex with the Maya painting system, to change the value 0.5 for another, it doesn't change the values at all. Can you help me to solve this problem? Thanks, Malu

Share this post


Link to post
Share on other sites

This topic is 3300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this