Soft selection vertex color

Soft selection vertex color

Anonymous
Not applicable
709 Views
2 Replies
Message 1 of 3

Soft selection vertex color

Anonymous
Not applicable

Hi Team,

 

I want to know the code behind soft selection in edit mesh(getting vertex color).

I have to apply soft selection through c++ code. I need to know how to set the vertex color in case of soft selection in edit mesh. 

I tried with the following code:

 

Mesh &mesh = obj->GetMesh();

if (mixedVertexColors.Count() > 0) {
mesh.setNumVertCol(mesh.numVerts);
mesh.setNumVCFaces(mesh.numFaces);

for (int i=0; i<mesh.numVerts; i++) {
mesh.vertCol[i] = i<mixedVertexColors.Count() ?
Point3(mixedVertexColors[i]->r, mixedVertexColors[i]->g, mixedVertexColors[i]->b) :
Point3(1.0f, 1.0f, 1.0f);
}

for (int i=0; i<mesh.numFaces; i++) {
mesh.vcFace[i].t[0] = mesh.faces[i].v[0];
mesh.vcFace[i].t[1] = mesh.faces[i].v[1];
mesh.vcFace[i].t[2] = mesh.faces[i].v[2];
}
}
else if (faceColors.Count() > 0) {
int numVCVerts = mesh.numFaces*3;
mesh.setNumVCFaces(mesh.numFaces);
mesh.setNumVertCol(numVCVerts);

int faceVert = 0;
for (int i=0; i<mesh.numFaces; i++) {
for (int j=0; j<3; j++) {
mesh.vertCol[faceVert] = i<faceColors.Count() ?
Point3(faceColors[i]->colors[j].r, faceColors[i]->colors[j].g, faceColors[i]->colors[j].b) :
Point3(1.0f, 1.0f, 1.0f);
faceVert++;
}
}

faceVert = 0;
for (int i=0; i<mesh.numFaces; i++) {
mesh.vcFace[i].t[0] = faceVert++;
mesh.vcFace[i].t[1] = faceVert++;
mesh.vcFace[i].t[2] = faceVert++;
}
}

NotifyDependents(Interval(t,t), PART_VERTCOLOR & PART_EXCLUDE_RADIOSITY, REFMSG_CHANGE);
NotifyDependents(Interval(t,t), PART_TOPO & PART_EXCLUDE_RADIOSITY, REFMSG_CHANGE);
obj->UpdateValidity(VERT_COLOR_CHAN_NUM, valid);

 

but it is setting the faces color.

I just want to apply the vertex color when i do soft selection.

 

Attached is the image of what i want what is happening.

 

Please help me.

 

 

0 Likes
710 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor

@Anonymous wrote:

 

I just want to apply the vertex color when i do soft selection.

 


when you set softselection you don't need to care about vertex color. The soft selection mechanism will do this for you.

 

but if you want to color the vertices the way softselection does, you have to take some normalized value per vertex into account and use the corresponding color obtained with using SoftSelectionColor method defined in meshadj.h

 

I think we understand that coloring vertices as a soft selection does not mean the same thing as applying a soft selection.

0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi denis,

 

Thanks for your support.

Yes, we understand coloring vertices does no mean applying soft selection.

For applying soft selection, I have written the code. It is working as soft selection.

The only thing left is to apply vertex colors (vertices falling in falloff area, pinch and bubble)same as soft selection does through code.

So, I want the logic behind SoftSelectionColor method defined in meshadj.h

0 Likes