i wrote a program for read a file format and here is the code:

struct Vertex

{

GLfloat unknown_0;

GLfloat x;

GLfloat y;

GLfloat z;

GLfloat u;

GLfloat v;

GLfloat unknown_1;

};struct Triangle

{

GLfloat unknown_0;

int indices[3];

int normals[3];

GLfloat unknown_1;

};struct Normal

{

GLfloat x;

GLfloat y;

GLfloat z;

};class Mesh

{

public:

unsigned short num_Vertex;

Vertex* vertices;

unsigned short num_Triangle;

Triangle* tris;

unsigned short num_Normal;

Normal* norms;

void Load(char* filename);

void Render(void);

};

void Mesh::Load(char* filename)

{

ifstream ifs(filename);

ifs >> num_Vertex;

vertices = new Vertex [num_Vertex];

for(int i = 0; i < num_Vertex; i++)

{

ifs >> vertices[i].unknown_0;

ifs >> vertices[i].x;

ifs >> vertices[i].y;

ifs >> vertices[i].z;

ifs >> vertices[i].u;

ifs >> vertices[i].v;

ifs >> vertices[i].unknown_1;

}

ifs >> num_Normal;

norms = new Normal [num_Normal];

for(int c = 0; c < num_Normal; c++)

{

ifs >> norms[c].x;

ifs >> norms[c].y;

ifs >> norms[c].z;

}

ifs >> num_Triangle;

tris = new Triangle [num_Triangle];

for(int j = 0; j < num_Triangle; j++)

{

ifs >> tris[j].unknown_0;

ifs >> tris[j].indices[0];

ifs >> tris[j].indices[1];

ifs >> tris[j].indices[2];

ifs >> tris[j].normals[0];

ifs >> tris[j].normals[1];

ifs >> tris[j].normals[2];

ifs >> tris[j].unknown_1;

}

return;

}

void Mesh::Render(void)

{

glBegin(GL_TRIANGLES);

for(int i = 0; i < num_Triangle; i++)

{

glNormal3f(norms[tris[i].normals[0]].x, norms[tris[i].normals[0]].y, norms[tris[i].normals[0]].z);

glVertex3f(vertices[tris[i].indices[0]].x, vertices[tris[i].indices[0]].y, vertices[tris[i].indices[0]].z);

glNormal3f(norms[tris[i].normals[1]].x, norms[tris[i].normals[1]].y, norms[tris[i].normals[1]].z);

glVertex3f(vertices[tris[i].indices[1]].x, vertices[tris[i].indices[1]].y, vertices[tris[i].indices[1]].z);

glNormal3f(norms[tris[i].normals[2]].x, norms[tris[i].normals[2]].y, norms[tris[i].normals[2]].z);

glVertex3f(vertices[tris[i].indices[2]].x, vertices[tris[i].indices[2]].y, vertices[tris[i].indices[2]].z);

}

glEnd();

return;

}

it loads fine and renders fine but i dont think the normals are rightâ€¦ how exactly do normals work? and whats wrong with the normals in this code?

thanks