Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Calculating Vertex Normals

This topic is 6621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites