View Full Version : vertex arrays, normals and Crossroads (3DS)

04-24-2002, 11:36 AM
I am beginning to use vertex arrays and really need some help. I am trying to display a simple cube with data that looks like this:


typedef struct MeinPointStruct {
GLdouble x, y, z;
} MeinPoint;

MeinPoint Quader_vertex[] = { { -10.0, -10.0, -10.0},
{ -10.0, 10.0, -10.0},
{ 10.0, 10.0, -10.0},
{ 10.0, -10.0, -10.0},
{ -10.0, -10.0, 10.0},
{ 10.0, -10.0, 10.0},
{ 10.0, 10.0, 10.0},
{ -10.0, 10.0, 10.0} };

GLubyte Quader_face[] = { 0,1,2,
4,7,1 };


glVertexPointer(3, GL_DOUBLE, 0, Quader_vertex);

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, Quader_face);


As you can see I only select the first 6 points to be displayed to be able to see what the result looks like. Well, I really can see what I expect: The first face of the cube made out of two triangles. The problem is the light - or maybe I should say the normal vectors.
I thought that the normal vector (the one for all three point of the triangle) is given by the order of the vertices in one triangle: clockwise or counterclockwise...?
But when I look how the face is reflecting the light, that doesn't seem to be true. Then I remembered glFrontFace() but it didn't do anything. I also changed the order of the first three points to 0, 2, 1.
What am I doing wrong?

By the way: The reason why I try this is that I wanted to display some data exported with Crossroads from a 3DS file.
The original index array had a 4th column that was always -1.
Does anybody know why? I deleted this column because this doesn't seemed to be any information...
And as Crossroads didn't export any normal information I didn't activated GL_NORMAL_ARRAY.
Is there someone who can help me or has a (hopefully simple) example of how to use vertex arrays in general or especially Crossroad exported meshes?

04-24-2002, 12:29 PM
It sounds like you are expecting OpenGL to generate the normals for you. It won't. If you're using a vertex array for this, you would probably be best off creating a normal array, which should have a normal for each vertex. If you're not sure how to calculate the normal yourself, search the form. There are numerous posts describing how to do that.