Sign in to follow this  
Aragon

OpenGL 3ds loader .. calc normals with multiple vertices used?!

Recommended Posts

hi i got an loader for 3ds files in openGL an it works nearly perfect, ok ,there are no NORMAL's saved in 3ds file format i GOOGELD a lot of things with "+opengl +calculating +normals etc [i hate google ] and i found some examples of calculatin face normal, ok,but there is one mistake in it when calculatin round objects like tree there are points that should have a normal direction mixed because that point is used by some faces (sorry for my english,i normally speak only german) for example this are 8 faces and 8 points (watching from top) problem when calculating point '0' with '2' and '3' they miss '6' and '7' normally the normal of 0 must look North and not northeast like here what formula is there to combine all vertices that are mutiple used by faces (please no google answers anymore)

Share this post


Link to post
Share on other sites
First off: 3ds files do support normals.
Second: Learn to use google. :D

If you want to calculate the "average" normal for those points..
1) calculate the normals of ALL faces that is connected to one vertex. (simple cross-product..)
2) Average those (should be depending on the area of the face) and you have your normal.

For a cube, you normally want "hard" edges, that is, no shared normals, but to use the face-normals instead, which means you have to split each vertex into 3 vertcies...

Good luck!

Share this post


Link to post
Share on other sites

chunk
0x4110 == vertices
chunk
0x4120 == face polys
chunk
0x4140: == texture coordinates

etc..etc

google tell not about the mistery what chunk
uses/stores normals but it looks that
YOU "gugli" know more about it :)

please feel free to tell us more about it here


or did anybody else know a complete serious describtion of .3ds files
with "normal" definitions inside..so i can stop thinking about normals
when using 3d editors (only watching face orientation when creating objects)

a lot of "google" result tells that 3ds did NOT store normals










Share this post


Link to post
Share on other sites
set the normal for the vertex to be the average face normal for all the triangles that use the vertex. this will look "right" and will provide smoother shading than having the vertex have a different normal for each triangle that uses it.


for ( each vertex )
{
find all the triangles that use it;
for (each triangle)
{
add the tri normal to the average;
}
normalize the average;
}


-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Palidine
set the normal for the vertex to be the average face normal for all the triangles that use the vertex. this will look "right" and will provide smoother shading than having the vertex have a different normal for each triangle that uses it.


for ( each vertex )
{
find all the triangles that use it;
for (each triangle)
{
add the tri normal to the average;
}
normalize the average;
}


-me


Agree. In addition, I've just written a basic 3ds loader (tell me if you want the source to look at, and I could mail it to you, if you're interested) and AFAIK there are no normals stored in the 3ds format file. Most of the others formats I looked at don't keep normals simply because they can be calculated from vertices. Only a couple of formats do that (but I don't remember wich).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this