Jump to content
• Advertisement

# Problem with lightening when using display list Vertex/Normal arrays

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

##### Share on other sites
Advertisement
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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
16
4. 4
JoeJ
13
5. 5
• Advertisement

• 9
• 9
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632646
• Total Posts
3007636
• ### Who's Online (See full list)

There are no registered users currently online

×

## 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!