Modifying terrain page color buffer

Hey all:



I am trying to set the color buffer of a single mesh from a terrain page; during init I create the page then go through all the sub-meshes and set random colors on the verts (to test my logic).  This works great, I get random colors all over the terrain page; however I can't modify those buffers one rendering has started.  I tried unlock() and unlockBranch() on both the mesh and the page itself to no avail.  I also have not forgotten a updateRenderstate();






    private void colorTriangle( TriMesh mesh ) {

//      if ( true ) {
//        color( mesh, ColorRGBA.randomColor(), 0 );
//      return;
//      }


      //  page.unlockBranch();
        FloatBuffer cb = mesh.getColorBuffer(0);
        cb.clear();

        int[] indexBuffer = new int[3];
       
       
        for (int triangles = 0; triangles < mesh.getTriangleCount(); ++triangles) {

            mesh.getTriangle(0, triangles, indexBuffer);
            ColorRGBA color = ColorRGBA.randomColor();

            BufferUtils.setInBuffer(color, cb, indexBuffer[0]);
            BufferUtils.setInBuffer(color, cb, indexBuffer[1]);
            BufferUtils.setInBuffer(color, cb, indexBuffer[2]);
        }
        cb.flip();
       
        mesh.updateRenderState();
        mesh.updateGeometricState(0, true);

        page.updateRenderState();
        page.updateGeometricState(0, true);
        System.out.println(mesh.getName());
    }




What makes me scratch my head is that if I just change the material states (un-comment the first part) then the entire mesh is set to that color as expected.

Also, I can't get the vertex colors to blend with the texture, only the material state will do it. However if I turn off lighting then vertex colors and textures blend nicely.  Is it possible to have vertex colors, lighting, and blending with the textures?

As always any help or hints are appreciated.

Vertex colors only work when lighting is off.

As soon as you have light in the scene you need to use the MaterialStates or Textures to Color Objects.



I guess there is not much use for simple vertex colors in a 'real' scene.

yeah, after remembering that GL rule I felt kinda dumb even asking