Gunfighter

08-02-2000, 09:43 PM

Hi ppl.

I am using Blender to create my simple model, and save it as an OBJ file (has only ASCII vertice data and face data)

It went well until I added lighting.

As the file does not have the Normals, I needed to calc them by hand (I made that by vectorial multiplication), and used GL_NORMALIZE to ease my work.

Then I noticed that some normals were working "inversed", lighting blocks where there should be shadow. Browsing the Forum, I found out about GL_LIGHT_MODEL_TWO_SIDE.

My doubts are :

Is there a cleaner way to get the normals than :

for (j=0;j<3;j++) {

aux1[j]=vertices[faces[i][2]][j]-vertices[faces[i][1]][j];

aux2[j]=vertices[faces[i][3]][j]-vertices[faces[i][1]][j];

}

glNormal3f(aux1[1]*aux2[2]-aux1[2]*aux2[1],aux1[2]*aux2[0]-aux1[0]*aux2[2],aux1[0]*aux2[1]-aux1[1]*aux2[0]);

(I know I should normalize them instead of using GL_NORMALIZE, but I'm too lazy to do that.)

What is the cleaner way, using GL_LIGHT_MODEL_TWO_SIDE with GL_FRONT_AND_BACK or using GL_FRONT without Gl_LIGHT_MODEL_TWO_SIDE?

I also want to know how to get my model Gouraud shaded (It is a rough model, with sharp edges, and just a few (125) vertices.).

I tried GL_SMOOTH, but the faces are still of uniform color.

Thanks in advance,

Gunfighter

I am using Blender to create my simple model, and save it as an OBJ file (has only ASCII vertice data and face data)

It went well until I added lighting.

As the file does not have the Normals, I needed to calc them by hand (I made that by vectorial multiplication), and used GL_NORMALIZE to ease my work.

Then I noticed that some normals were working "inversed", lighting blocks where there should be shadow. Browsing the Forum, I found out about GL_LIGHT_MODEL_TWO_SIDE.

My doubts are :

Is there a cleaner way to get the normals than :

for (j=0;j<3;j++) {

aux1[j]=vertices[faces[i][2]][j]-vertices[faces[i][1]][j];

aux2[j]=vertices[faces[i][3]][j]-vertices[faces[i][1]][j];

}

glNormal3f(aux1[1]*aux2[2]-aux1[2]*aux2[1],aux1[2]*aux2[0]-aux1[0]*aux2[2],aux1[0]*aux2[1]-aux1[1]*aux2[0]);

(I know I should normalize them instead of using GL_NORMALIZE, but I'm too lazy to do that.)

What is the cleaner way, using GL_LIGHT_MODEL_TWO_SIDE with GL_FRONT_AND_BACK or using GL_FRONT without Gl_LIGHT_MODEL_TWO_SIDE?

I also want to know how to get my model Gouraud shaded (It is a rough model, with sharp edges, and just a few (125) vertices.).

I tried GL_SMOOTH, but the faces are still of uniform color.

Thanks in advance,

Gunfighter