Flipping all mesh normals in the positive direction #3309
Answered
by
Grantim
aseglorstw
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
Grantim
Sep 5, 2024
Replies: 1 comment 2 replies
-
Hello! We have import meshlib.mrmeshpy as mr
mesh = mr.loadMesh(path_to_mesh))
# check if it is needed to flip
avgNorm = mr.Vector3f()
for v in mesh.topology.getValidVerts():
avgNorm = avgNorm mesh.normal(v)
avgNorm = avgNorm / mesh.topology.getValidVerts().count()
if ( mr.dot( avgNorm, mr.Vector3f(0,0,1) ) < 0 ): # assume that you want your normals to look in positive Z direction
mesh.topology.flipOrientation() # flip all normals |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
aseglorstw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
We have
flipOrientation
function to do it: