Firstly, do you have material information in the volume? That is, your voxel type needs to have a material component, such as Material8 or MaterialDensityPair44.
Assuming you do have this then the material ID is stored in the vertices of the generated mesh. So if you are using the CubicSurfaceExtractor then the mesh contains vertices of type PositionMaterial, wihch looks like this:
Code:
class PositionMaterial
{
public:
PositionMaterial();
PositionMaterial(Vector3DFloat positionToSet, float materialToSet);
float getMaterial(void) const;
const Vector3DFloat& getPosition(void) const;
void setMaterial(float materialToSet);
void setPosition(const Vector3DFloat& positionToSet);
public:
//Nicely fits into four floats.
Vector3DFloat position;
float material;
};
So you can access the material which is associated with each vertex. Now exactly how you use this is (you guessed it...) outside the scope of PolyVox, but there are a couple of options.
You may choose to break your mesh down into smaller meshes, each of which has only one material. There was some code to do this in PolyVox (you can still find the commented out code if you search for 'extractSubset') which might shw you where to start. The you can render each mesh one at a time with one material. Quite straightforward, but you end up rendering a lot of meshes.
Another approach is to pass the material ID to the GPU as part of the vertex data. This requires some shader skills but isn't too hard. Then it's up to you how you use it... for example you could convert it into a colour or use it as the index into a texture atlas. I guess the real question here is what visual look are you trying to achieve?