def __call__(self, bm: BMesh = Required,
mat: Matrix = None):
color = self.node.face_color[:]
if mat is not None:
if self.node.use_ops_trans:
bm = bm.copy()
matrix = mu.Matrix(mat)
bmesh.ops.transform(bm, matrix=matrix, verts=bm.verts)
verts = [v.co[:] for v in bm.verts]
bm.normal_update()
normals = [f.normal[:] for f in bm.faces]
else:
matrix = mu.Matrix(mat)
verts = [matrix * v.co for v in bm.verts]
bm.normal_update()
mat33 = matrix.to_3x3()
normals = [(mat33 * f.normal)[:] for f in bm.faces]
else:
verts = [v.co[:] for v in bm.verts]
bm.normal_update()
normals = [f.normal[:] for f in bm.faces]
tess_faces = bm.calc_tessface()
vert_index = [l.vert.index for l in itertools.chain(*bm.calc_tessface())]
face_index = [t_f[0].face.index for t_f in tess_faces]
edges_index = [(e.verts[0].index, e.verts[1].index) for e in bm.edges]
colors = []
for idx in face_index:
normal = mu.Vector(normals[idx])
normal_nu = normal.angle((0, 0, 1), 0) / np.pi
r = (normal_nu * color[0]) + 0.1
g = (normal_nu * color[1]) + 0.1
b = (normal_nu * color[2]) + 0.1
colors.append((r, g, b))
self.vertices.append(verts)
self.faces.append(vert_index if self.node.display_face else [])
self.colors.append(colors)
self.edges.append(edges_index)
评论列表
文章目录