View Full Version : assign names and colour to premade object

06-11-2001, 08:22 AM
Ive got a file from which I load a figure of a head. Id 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);
// sizeof(face_indicies) = 151488
// sizeof(face_indicies[0]) = 18
// => for loop 8416 times
// choose material - enters first time
// set name ??????
// set colour ???????
//glLoadName (i);
//glPushName (i);
// set the colour
// glColor3f(0.0,1.0,0.0);
//glPopName ();

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]);
glVertex3f (vertices[vi][0],vertices[vi][1],vertices[vi][2]);
return lid;
// end of GenerateDisplayList()

06-11-2001, 11:45 PM
OpenGL doesn't have the concept of a triangle having a name, so you're going to have to store that information somewhere yourself.

As to colors, how do you want to select colors? I mean, for a given triangle, how do you want to determine what color it is? Once you figure that out, stick that into the loading code.

06-12-2001, 05:11 AM
But is it not possible to use naming??
or does the namestack has a limited depth??

I thought for a while that I could store the polygons in a namestack and then use picking to figure out which polygon I want to draw. But if I dont understand wrong, picking is
only for figure out which polygon or object is choosed by the mouse. But how can I do if I have coordinates for the object i.e Id like to draw polygons I cant see from the screen until I rotate my figure... mouse coordinates are not intresting...