Maya API MFnMesh::setFaceColor


#1

how I make to place color in one face of a mesh with the MFnMesh::setFaceColor ?
I have that active some thing before?
I can use inside of funçao MPxNode::compute?

thanks,
Tyler.


#2

There are some example code that will help you in the devkit folder. Also, read the first chapters of the API docs to get an idea of what the API works like.

Basically, retrieve you mesh as a dagpath, you could use a selection list like:

MDagPath meshDagPath;
selectionList.getDagPath(0, meshDagPath);

Then use the constructor for MFnMesh which accepts a dagpath,

MFnMesh ( const MDagPath & object, MStatus * ReturnStatus = NULL )

There you are!

The code above is by no mean complete, its a start an perhaps a little bit of help when reading the API or looking through example code.

Try this and get back to the forum if you have more questions! Im sure there a lot of people around that knows Maya API :slight_smile:

-mk-


#3

thanks mk,

I made this code,

MStatus pickExample::doIt( const MArgList& )
{
MDagPath node;
MObject component;
MSelectionList list;
MFnDagNode nodeFn;

   MGlobal::getActiveSelectionList( list );
   list.getDagPath( 0, node, component );
   nodeFn.setObject( node );
   printf("%s is selected

", nodeFn.name().asChar() );

   MFnMesh meshFn(node);
   MColor red(1.0f, 0.0f, 0.0f);
   printf("setFaceColor...");
   if (meshFn.setFaceColor(red, 0) == MS::kSuccess)
           printf("kSuccess!

");
else printf("kFailure!
");

   return MS::kSuccess;

}
the setFaceColor return kSuccess, but the color does not appear in the face.

what I make to appear the color?

Tyler.


#4

Are you creating a valid MFnMesh? I think that it might be possible for SetFaceColor() to return success if the meshFn is invalid. Do a quick check to see if thats ok:

 MStatus meshStatus; 
MFnMesh meshFn(node, &meshStatus);
 
if(meshStatus != MS::kSuccess)
	// Doh!

Other than that, are you viewing meshes in Maya in the appropriate mode to see vertex colors?

cheers,
stoo


#5

yes the mesh is valid.

which is the appropriate mode in maya to see vertex colors?

thanks,
Tyler.


#6

Use the menu to go to Display->Custom Polygon Display and click on the box to alter the options. Inside the new panel, set “Colour Material Channel” to “Emmision”, check the box labelled “Color in Shaded Display” (i.e. make sure its on). To have this work over all objects, set “Objects Affected” to “All” at the top of the panel.

Hope that helps.
stoo


#7

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.