jujut
Hello,

Is it possible with a Deformer to have more than the point position in the output?
Actually i am building a MPxDeformerNode in c++.
The deformation is computed with the distance between a  locator and the point of the mesh.
It's work nice, but now i would like to display the weight/float attribute on the mesh (distance between the mesh and the locator).
Someone can help me?

Thanks
Quote 0 0
pshipkov
Not really.
You will need to make mpxlocator node for that.
Quote 0 0
jujut
Thanks you for the reply.
But what i need it's to create a vertex color, which can be use for rendering. If i've right understand the mpxlocator can be use only to display information in the viewport and not for rendering. I 'am right?
Quote 0 0
pshipkov
I see what you are saying.
Yes, you can do that from within deformer node.
Just use the input mesh object in MFnMesh and then use one of its methods to set colors to the vertices.
Quote 0 0
jujut
ok, i've try do this :

    ....
    MFnMesh myMesh ( inputObject, &returnStatus);
    MColor temp(1.0,0.0,0.0);


    for ( ; !iter.isDone(); iter.next()) {
        MPoint pt = iter.position();
        myMesh.setVertexColor(temp, iter.index(),0,MFnMesh::MColorRepresentation::kRGB    );
        .....

Compilation is ok, defromation is ok but nothing append with the color :(
Quote 0 0
pshipkov
did you turn-on the "display colors" flag in the mesh node's AE ?
Quote 0 0
jujut
yes, i put display colors "on" into the Mesh Componet Display of the mesh but nothing change
Quote 0 0
pshipkov
Just looking more carefully at your code - i think you have to initialize the MFnMesh using the output object.

Also, the way you are doing the loop - things are going to be unnecessary slow.
Quote 0 0
jujut
ok

so i've use now the outpouGeom and try to use an array of color to change the color of the vertex, but it still not working :(


.......
MFnMesh myMesh ( outputGeom, &returnStatus);

MIntArray index;
MColorArray colors;

for ( ; !iter.isDone(); iter.next()) {

        index.append(iter.index());
        MColor col;
        col.r = 1.0;    col.g = 0.0;    col.b = 0.0;    col.a = 0.0;
        colors.append(col);
}

myMesh.setVertexColors(colors, index);

.....
Quote 0 0
pshipkov
For ::setVertexColors to work you have to pass a complete list of points. If your deformer has some of the points trimmed by setMembership tool this will not work.
Wonder if that's the case ?
Quote 0 0
jujut
i just test (print length of the color array) to see if i get all the point and yes i get all the points in the list.
Quote 0 0
jujut
it's ok now i can write color.

My mistake was to don't use the right MFnMesh.

Now i use it :
MArrayDataHandle outputArray = block.outputArrayValue(MPxDeformerNode::outputGeom    , &returnStatus );
MDataHandle outPut = outputArray.inputValue(&returnStatus);
MFnMesh myMeshO ( outPut.data(), &returnStatus);

//THE LOOP//

myMeshO.setVertexColors(colours, vertexIndecies);

Now i have the color, but the color is not updated, so i've to investigate more. But i think i'am on the way

Quote 0 0
jujut
The color works fine now, but i 've still have a problem with the update of theVertexColor.
The vertexcolor works only one time, when i load and apply the plugin deformer.
Someone have an idea on the problem?
Below an example of the code that i'am using inside the deformer for implementing teh vertexcolor.

Quote:
MColorArray colours;      
MIntArray vertexInd;

for ( ; !iter.isDone(); iter.next()) {                
MPoint point = iter.position();                
MPoint newPoint = iter.position();
               
//modify the y value of the point                
newPoint.y +=myParam;                

//modify the r value of the vertexColor                
colours.append(myParam, 0, 0, 1);                

vertexInd.append(iter.index());                

iter.setPosition(newPoint);
}

MArrayDataHandle outputArray = block.outputArrayValue(MPxDeformerNode::outputGeom , &returnStatus );
MDataHandle outPut = outputArray.inputValue(&returnStatus );
MFnMesh myMesh ( outPut.asMesh());
myMesh.setVertexColors(colours, vertexInd);

outPut.setClean();


Thanks :)
Quote 0 0
pshipkov
There is a method in MFnMesh that refreshes the mesh data it is called updateSurface or something like that. Try using it and see what happens.
Quote 0 0
jujut
I've already try to use this :( but the same problem nothing happen, vertexcolor are not updated.
Quote 0 0

Add a Website Forum to your website.