PDA

View Full Version : Vertex Normals



detzel
02-02-2001, 07:10 AM
I just finished up my ASE file loader for my project(so I thought)and I started testing it on my models. The model itself gets loaded fine but what I also extracted from the ASE file were the individual vertex normals. I made my loop so it would get the values and apply them to each vertex as I go but for some reason its not working properly. I know it's not because I load in just a normal box with simple face normals and it works fine with my lighting, but if I laod one of my imports the light looks messed up. Here is some of the code i made.
This is how I am storing the values of everything.
struct CVertex
{
float x,y,z;
};
struct CFace
{
int a,b,c,ab,bc,ca;
};
struct CNormal
{
int v[3];
float xs[3],ys[3],zs[3];
};
struct CModel
{
CVertex* verts;
CFace* faces;
CNormal* normals;
int numverts;
int numfaces;
};
pretty self explantory. I then have some C stuff to read the file and store all the values in those structs, which works. Then in my program I outpout everything like this.
glBegin(GL_TRIANGLES);
for (int v=0;v<mymodel.numfaces;v++){
for (int j=0;j<3;j++){
if (j==0)vert = mymodel.faces[v].a;
else if (j==1) vert = mymodel.faces[v].b;
else if (j==2) vert = mymodel.faces[v].c;
glNormal3f(mymodel.normals[v].xs[j],mymodel.normals[v].ys[j],mymodel.normals[v].zs[j]);
glVertex3f(mymodel.verts[vert].x,mymodel.verts[vert].y,mymodel.verts[vert].z);
}
}
glEnd();

Can someone help me out, I don't know how to fix this or what im doing wrong. If you want the full source I will send, just email me, ladetz@usa.net

Bob
02-03-2001, 11:31 AM
I don't have much to do nowadays, pass the code to e98msv@du.se and I can have a look at it.

DFrey
02-03-2001, 12:07 PM
Might want to check this thread http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/001665.html some people have had problems getting the normals out of ase files (this is a fairly common occurance in fact http://www.opengl.org/discussion_boards/ubb/tongue.gif).