I´ve got a file from which I load a figure of a head. I´d like to assign names and colours to each polygon in this head.
I use a operation in my C++ program that reads all the vertexes, normals and textures and put it into a DisplayList that is being called when I want to display the figure. But how do I do to assign names and colours at the same time??
my operation where I load all the data:
unsigned int C3DPaintCanvas::GenerateDisplayList()
{
int i;
int j;
GLint lid=glGenLists(1);
int mcount=0;
int mindex=0;
glNewList(lid, GL_COMPILE);
glBegin(GL_TRIANGLES);
// sizeof(face_indicies) = 151488
// sizeof(face_indicies[0]) = 18
// => for loop 8416 times
for(i=0;i<sizeof(face_indicies)/sizeof(face_indicies[0]);i++)
{
// choose material - enters first time
if(!mcount)
{
SelectMaterial(material_ref[mindex][0]);
mcount=material_ref[mindex][1];
mindex++;
}
mcount–;
// set name ???
// set colour ???
////////////////////////////////
//glLoadName (i);
//glPushName (i);
// set the colour
// glColor3f(0.0,1.0,0.0);
//glPopName ();
///////////////////////////////
for(j=0;j<3;j++)
{
int vi=face_indicies[i][j];
// Vertex
int ni=face_indicies[i][j+3];
//Normal index
int ti=face_indicies[i][j+6];
//Texture index
glNormal3f (normals[ni][0],normals[ni][1],normals[ni][2]);
glTexCoord2f(textures[ti][0],textures[ti][1]);
glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
}
}
glEnd();
glEndList();
return lid;
}
// end of GenerateDisplayList()