Soft selection vertex color

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.