• Create Account

## Calculating Vertex Normals

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1 Anonymous Poster_Anonymous Poster_*   Guests

Likes

Posted 26 October 1999 - 01:35 AM

Alright, I wrote a file loader for the caligari ".cob" file. It works pretty well, except cob files don't include vertex normals. Since I want to use the lighting engine of DirectX, i'm going to have to calculate these myself. So, here's where the problem starts. I know that if I could calculate all the face normals (the cross product of two edge vectors) surrounding a vertex, I could basically get the average of these and would then have a vertex normal. But when reading through a file, how am i going to know which faces surround each vertex?! Maybe I am not doing this correctly. Could someone explain therefore how I would calculate all the vertex normals? I have gotten all the vertices from the file and put them in order so that each face is in order too (as a set of three).

### #2Auday  Members

122
Like
Likes
Like

Posted 23 October 1999 - 02:46 AM

There is a function "ComputeNormals" in d3dfile.cpp ( find it under d3dframe ) u can take it and modify it, I did that with my .LWO loader.
You will find the answer for your question in the first loop of that function , I completed my loader successfuly yesterday so u can ask me if have any troubles with the function

### #3 Anonymous Poster_Anonymous Poster_*   Guests

Likes

Posted 23 October 1999 - 04:18 AM

I don't have a "d3dfile.cpp" or anything like that in the d3dframe folder, or anywhere on my computer for that matter. I also searched through all the d3dframe files, none of them have any function like you described. help?

### #4Auday  Members

122
Like
Likes
Like

Posted 23 October 1999 - 08:24 PM

I have DX7 SDK which I downloaded from MS website the file is in c:\mssdk\samples\Multimedia\D3DIM\src\D3DFrame\d3dfile.cpp .
If u couldnt find it u can Email me or ICQ me on:
auday@softhome.net , ICQ 50534800
and I'll send it to u

### #5 Anonymous Poster_Anonymous Poster_*   Guests

Likes

Posted 26 October 1999 - 01:35 AM

I'm not sure how objects are stored in .cob files, or if this is the "proper" way to do it. But for each object mesh, i'm storing a vertex list, with the polygon list storing pointers to the verticies in the vertex list.
After i've calculated all of the polygon normals, i calculate the vertex normal's by traversing through the vertex list, and comparing the address of the vertex with every vertex pointer stored by the polygons in the polygon list.

So once i find the polygons that point to this particular vertex, it's a simple matter of getting the weighted average of the polygon normals.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.