Auto Calculate Normals

The lazy programmer hits again:

has anyone any fragment of code that given a trimesh vertices and indices calculates the normals?

Good question -> how do you compute good normals?

I always used an algorithm, where I took the cross product and weighted it by the angle between two edges and then just added them all together for one vertex and renormalized it afterwards …


One can compute "smooth" normals (for organic shapes) or one can compute "flat" normals (for things like boxes, diamonds, crystals etc).

There is plane normal calculation in TerrainBlock, and vertex normal calculation in AseToJme . The later one works well with models. And there is GeometryInfo which purpose seems to be exactly that, but haven't tried it. There might be others too.

Thanks the method from AsetoJme worked fine for now.