Notifications
Clear all

[Closed] [SDK] Explanation on applying vertec color?

Can some one explain how the Vertex Color Works in the sdk ?, I have looked at the help but there is no much information about it in there, And I have looked at the samples but I’m trying to understand how does it work.

For example The code below is from the utility AVCMode.cpp

The mesh.vertCol is self explanatory but what I don’t understand is the mesh.vcFace part, Do we need them ?, Is it always the same order as the mesh faces ?

Appreciate any information.
Guillermo Leal

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++;
}

2 Replies

the faces are the same order (geometry face == vertex colour face) but the vert indices within each can be different.

for example in the above quad there are 4 geometry verts but 6 vertex colour verts

so geometry faces would be (2,0,3) and (1,3,0)
but cpv faces are (2,4,5) and (1,3,0)

oh and vertex colour works exactly the same in the sdk as it does in mxs apart from starting at 0 for indexing

Thanks for the explanation Klvnk, I got it to work now.