|
 |
Ilya Razmanov <ily### [at] gmail com> wrote:
> Greeting,
Interesting what you do with the sharp transitions.
Other method that could work in various cases:
1. First calculate the face normal, either by cross product of three edges or
Newell's method
Newell:
for i in 0..<vertices.len:
let curr = vertices[i]
let next = vertices[(i + 1) mod vertices.len]
normal.x += (curr.y - next.y) * (curr.z + next.z)
normal.y += (curr.z - next.z) * (curr.x + next.x)
normal.z += (curr.x - next.x) * (curr.y + next.y)
return normalize(normal)
2. Now calulate the vertex normals, there several weighting types can be used,
based on properties of the adjacent polygons.
Weighted by area, weighted by angle or just average the face normals as they
are.
Regarding usefulness, always. Users do crazy things :) It may also be useful if
you provide an export as arrays, so one can (ab)use the data in SDL.
ingo
Post a reply to this message
|
 |