I'm trying to color 3D PShape. if I perform vertex.setEmissive(color) on each vertex this does color the object as expected but this is simply emissive color unaffected by the scene lighting. if instead I try to use .setFill() or .setTint() or .setAmbient() on each vertex I get a completely black and opaque object. if I don't do anything at all then the object has a white or gray fill that does respond to the scene lighting.
I don't understand what I'm doing wrong. How do I assign a color to each vertex in a PShape???
DETAILS: I read in a .obj file which creates a PShape object that is simple a list of GROUPs in which each group contains 3 verticies (a triangular face).
I then iterate over this list of lists setting the color of each vertex with the outcome described above.
My thinking is that I must not understand what setFill or setTint or setAmbient do. I'd like to know. But I'd also like to know how to do what I want which is to paint the faces.
here's a code snippet that I'm using:
sts = p.loadShape("stshuttle.obj");
sts.rotateZ(p.PI/2);
sts.rotateY(-p.PI/2);
// loop over the list of GROUP PShapes
// set odd faces red and even faces yellow
for (int i =0; i<sts.getChildCount();i++){
PShape foo = sts.getChild(i);
int colr2 = (0==i%2)? 0xFF1000 : 0xFFFF00;
// loop over all three of the verticies in the GROUP.
for (int j = 0; j<foo.getVertexCount();j++) {
foo.setFill(j,colr2); // This turns it black
// foo.setEmissive(j,colr2); // works as expected
// foo.setTint(j,colr2) // this turns it black.
}
}