Register Latest Topics
 
 
 


Reply
  Author   Comment   Page 1 of 2      1   2   Next
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #1 
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
0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #2 
Not really.
You will need to make mpxlocator node for that.
0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #3 
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?
0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #4 
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.
0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #5 
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 :(
0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #6 
did you turn-on the "display colors" flag in the mesh node's AE ?
0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #7 
yes, i put display colors "on" into the Mesh Componet Display of the mesh but nothing change
0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #8 
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.
0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #9 
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);

.....
0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #10 
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 ?
0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #11 
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.
0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #12 
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

0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #13 
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 :)
0
pshipkov

SOuP Jedi
Registered:
Posts: 4,732
Reply with quote  #14 
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.
0
jujut

Asking for seconds
Registered:
Posts: 33
Reply with quote  #15 
I've already try to use this :( but the same problem nothing happen, vertexcolor are not updated.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.