Sign in to follow this  

Problem with lightening when using display list Vertex/Normal arrays

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

hi, i am trying to use glDrawElement() function to draw my models in my OGL project. as it is known, u need to have your vertex, normal, color,...etc arrays enabled once using this function. i am using vetex and normal arrays anly in my app. i am facing a problem with the shading issue, ie in the normals array. my model is of OBJ format. depending on the model, sometimes i get number of normals more or less than the number if vertices in my model. this is what is causing the problem in shading/lightening. i want to find a way to get a number of normals idintical to the number of vertices. i found some samples on the net, but they didnt mention the method of determining the norms for each vertex or the modeling process. and by the way, i am using 3D S Max 6 for modeling. can any one help me in this?? thanx in advance Abolfoooud

Share this post


Link to post
Share on other sites
I am not really sure why it's not exporting the normals properly, maybe you can just calculate the normals yourself?

To do that, the basic idea is, calculate the normal for each triangle, and then the normal at each vertex is the average of the normals of the surrounding triangles.

You can find the normal of a single triangle with sides A, B and C, as:
normalize(cross((B-A), (C-A)))

As for finding all the faces which surround a vertex, that's a little tougher. Probably the easiest way is when you load the model, every time you find that face x contains vertex y, add a reference to x inside the vertex.

Hope that helps..

roos

Share this post


Link to post
Share on other sites

This topic is 4556 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.

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