Bonjour,

Je calcule présentement la normal pour une face mais j'aimerais calculer la normal pour chacun des vertex pour obtenir un meilleurs effet avec la lumière.

private static float[] calcNormal(float[] v1, float[] v2, float[] v3)
{
float[] vector1 = new float[3];
float[] vector2 = new float[3];
float[] norm = new float[3];
int x = 0;
int y = 1;
int z = 2;

// Calculate two vectors from the three points
vector1[x] = v1[x] - v2[x];
vector1[y] = v1[y] - v2[y];
vector1[z] = v1[z] - v2[z];

vector2[x] = v2[x] - v3[x];
vector2[y] = v2[y] - v3[y];
vector2[z] = v2[z] - v3[z];

// Take the cross product of the two vectors to get
// the normal vector which will be stored in out
norm[x] = vector1[y] * vector2[z] - vector1[z] * vector2[y];
norm[y] = vector1[z] * vector2[x] - vector1[x] * vector2[z];
norm[z] = vector1[x] * vector2[y] - vector1[y] * vector2[x];

return norm;
}
Pouvez-vous m'éclairer sur la manière de s'y prendre?

DestinyWar