Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

Adjacent Vertices in a .3ds mesh

This topic is 3806 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

I have a .3ds loader that I found on the net and cleaned up the code due to many bugs, but sometimes some models I load in have darkened polygons and not all models that are loaded are like this. The best I can come up with is the triangles that are darkened and don't light up are sharing vertices with other polygons and never gets a normal calculated for it? If I take a simple cube and load the cube it looks fine, as is the TBN vectors. Any ideas why the polygons are darkened? Please don't ask for code as for one I am at work, and the code isn't here. There must be some common reasons why this happens, and I can look at those first and then post the code after those are eliminated. Thanks [Edited by - MARS_999 on June 15, 2008 8:32:42 AM]

Share this post


Link to post
Share on other sites
Advertisement
Could it be that you have normals that are pointing into the model? You should use the functions in 3ds to make sure that the normals are all pointing towards the outside.

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by cppcdr
Could it be that you have normals that are pointing into the model? You should use the functions in 3ds to make sure that the normals are all pointing towards the outside.

Hope this helps.


what functions are these? Do you mean in the .3ds modeler program?

No the normals are pointing outward as I draw lines for the TBN vectors and they point outward, what I think is happening and I am guessing here, because I noticed that when I load a .3ds mesh e.g. a cube that has 12 polygons with 8 vertices the mesh isn't correctly lit either, why well if I want to use per vertex normals I need 3 per corner so 24 normals are needed correct, as each face points left,right ,up or down on the 3 corners. And with my loader it reads there are 8 vertices not 24 as that is what is saved in the file. So I am guessing I need to add 16 more normals, or 16 more vertices? See I understand the idea to use 8 vertices and use the IBO to render the 12 polygons, from the 8 vertices. But for calculating the normals there aren't 8 normals when you have per vertex. When I look at the code from Nvidia for there .obj loader they do some adjacent checks on vertices, where my loader doesn't, would this be the problem?

Thanks

Share this post


Link to post
Share on other sites
So if I understand correctly, you are trying to get per face lighting, using per vertex lighting?

If that is the case, then I guess that the best way to do it would be to create some extra vertices (36 total) and calculate the normals afterwards based on the triangle information (from the indices).

If you are actually trying to get 1 normal per vertex, you could do it this way:

Create temporaty extra vertices (3 per triangle), calculate the face normals on each one (so 36 verts (6 per quad because there are 2 tris), 12 face normals). Then iterate through each real vertex (8 in this case) and average the normals of the vertices that have the same position. So in other words, you would be doing the average of the face normal of each triangle that touches the vertex.

It might not be the best way to do it, but I found that it worked great on my models.

If the method I described is not clear, tell me and i'll reexplain tomorrow... i'm tired right now so i don't know if what i am writing makes any sense :)

Share this post


Link to post
Share on other sites
They're called smoothing groups in 3d studio. which is a list of faces whos vertices can be welded. If the entire box is one smoothing group it will weld all its vertices, generating 8. If each face is it's own smoothing group, there will be 24 unique vertices.

At least this is how I believe it works :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!