Hi folks,

I have created a mesh of vertices. I have also been able to color some reqd no. of. vertices in SMOOTH shading mode. But I want to color different vertices with different material properties , how can I do so???

Simple. Just set the material properties before you set each vertex.

glBegin(GL_TRIANGLES);

SetMaterialForVert1();

glVertex3f(…);

SetMaterialForVert2();

glVertex3f(…);

SetMaterialForVert3();

glVertex3f(…);

// etc.

glEnd();

You’re also gonna have to work with vertex normals, which can be somewhat of a difficult task at first. Basically, first you calculate the surface normal of each face (the normalized cross product of 3 vertices of the faces). Then, you average the surface normals of adjacent surfaces to get a vertex normal. However, with sharp objects, you might not want the vertex normal to be generated, so you only average the surface normals if the dot product of the normals is >= the cosine of the angle of choice.

Thank you , for your contribution Its working fine after using vertex normals.