#### Archived

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

# Vertex Array Lighting

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

## Recommended Posts

I am having trouble getting my lighting to render correctly to the models that I create using the indexed vertex array method I use the following function to calculate the normals. Can anyone please help. void Humanoid::ReduceToUnit(float vector[3]) { float length; length = (float)sqrt((vector[0]*vector[0]) + (vector[1]*vector[1]) + (vector[2]*vector[2])); if (length == 0.0f) length = 1.0f; vector[0] /= length; vector[1] /= length; vector[2] /= length; } void Humanoid::calcNormal(GLfloat v[3][3], GLfloat out[3]) { float v1[3],v2[3]; static const int x = 0; static const int y = 1; static const int z = 2; v1[x] = v[0][x] - v[1][x]; v1[x] = v[0][y] - v[1][y]; v1[x] = v[0][z] - v[1][z]; v2[x] = v[1][x] - v[2][x]; v2[x] = v[1][y] - v[2][y]; v2[x] = v[1][z] - v[2][z]; out[x] = v1[y]*v2[z] - v1[z]*v2[y]; out[y] = v1[z]*v2[x] - v1[y]*v2[z]; out[z] = v1[x]*v2[y] - v1[y]*v2[x]; ReduceToUnit(out); }

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632946
• Total Posts
3009363
• ### Who's Online (See full list)

There are no registered users currently online

×