You can calculate the angle between two edges as follows:
given: edge vectors E and F for a given face of your vertex, E_normalized = normalize(E) F_normalized = normalize(F) cross_normal = cross(E_normalized, F_normalized) sin_theta = length( cross_normal ) cos_theta = dot(E_normalized, F_normalized) results: face normal = normalize(cross_normal) face angle theta = atan2(sin_theta, cos_theta)
Then the weight normals, respectively:
total_vector = vec(0,0,0) for(each face adjacent to a particular vertex): [compute normal and theta as above] total_vector += normal * theta return normalize(total_vector)
To optimize for real time, I would first profile to see what actually slows down. I would suggest that calculating atan2() several times per vertex can be expensive, but an improvement on this would really require some sort of replacement for angular weighted normals.
comingstorm
source share