Batch design advice requested

I’m writing an indexed mesh exporter for Maya, and I’d like some design advice for its (OpenGL) viewer.

The data will be static VBO for the most part, but I’m not sure how I should batch it. Meshes can have materials applied to individual faces, so I thought about :

struct submesh {
int *indices;
material *pMaterial;

struct mesh {

float *vertexBuffer;
float *normalBuffer;
submesh *subMeshes;
uint numSubMeshes;


This is nice, because only one instance of the vertex and normal data needs to be stored. Pretty bad for material state changes though.

Large meshes typically have most of their faces covered with one material, and a small group of faces with other materials.

I suppose I could store the small set of ‘other material’ faces as unindexed data, and not worry about spacial culling for them. I’d batch these by material, and then draw. Since hopefully there are few of these unique faces, there’s no real benefit from culling them early. I’m not sure if it’s worth it from a transform-saving cost viewpoint to make them indexed.

The rest of the normal large meshes would be culled and then batched by material.

Materials will be ARB_fp heavy, so I think this is the way I should be doing it, but I don’t have the years of experience most of you do.

Any advice is welcome.

[This message has been edited by CatAtWork (edited 09-26-2003).]