Author: Not specified Language: python
Description: Not specified Timestamp: 2018-06-04 04:10:09 +0000
View raw paste Reply
  1. def getNormals(obj):
  2.     data = bmesh.new()
  3.     data.from_mesh(obj.data)
  4.     normals = []
  5.     print("the number of vertices is => ", len(data.verts))
  6.     for v in data.verts:
  7.         v_normal = np.array([0,0,0],dtype=float)
  8.         for f in v.link_faces:
  9.             f_normal = np.array(f.normal,dtype=float)
  10.             v_normal += f_normal
  11.         if not (len(v.link_faces) <= 0 ):
  12.             v_normal /= float(len(v.link_faces))
  13.         normals.append(v_normal)
  14.        
  15.     print("the number of normals is => ", len(normals))
  16.    
  17.     return np.array(normals, dtype=float)
View raw paste Reply