I want to export meshes to my own file format, exactly the way they look in the editor. I already figured out how to get a bmesh with modifiers applied, which I also triangulate right then and there so I don’t have to deal with quads/ngons later:
depsgraph = bpy.context.evaluated_depsgraph_get() myObjectEvaluated = myObject.evaluated_get(depsgraph) bm = bmesh.new() bm.from_mesh(myObjectEvaluated.data) bmesh.ops.triangulate(bm, faces=bm.faces[:]) bm.verts.ensure_lookup_table() bm.edges.ensure_lookup_table() bm.faces.ensure_lookup_table() // ... bm.free()
When trying to figure out vertex normals, I end up here:
for face in bm.faces: for loop in face.loops: normal = face.normal // ALWAYS flat if face.smooth: normal = loop.vert.normal // ALWAYS smooth, angle-weighted
This breaks as soon as I use the Bevel modifier’s normal hardening, and will probably break when using custom split normals as well. How do I get exactly those normals which I see in the 3D view?