def get_panel(self, subs, altitude, panel_x, panel_z, sub_offset_x, idmat, verts, faces, matids, uvs):
n_subs = len(subs)
if n_subs < 1:
return
f = len(verts)
x0 = sub_offset_x - 0.5 * panel_x
x1 = sub_offset_x + 0.5 * panel_x
z0 = 0
z1 = panel_z
profile = [Vector((x0, z0)), Vector((x1, z0)), Vector((x1, z1)), Vector((x0, z1))]
user_path_uv_v = []
n_sections = n_subs - 1
n, dz, zl = subs[0]
p0 = n.p
v0 = n.v.normalized()
for s, section in enumerate(subs):
n, dz, zl = section
p1 = n.p
if s < n_sections:
v1 = subs[s + 1][0].v.normalized()
dir = (v0 + v1).normalized()
scale = 1 / cos(0.5 * acos(min(1, max(-1, v0 * v1))))
for p in profile:
x, y = n.p + scale * p.x * dir
z = zl + p.y + altitude
verts.append((x, y, z))
if s > 0:
user_path_uv_v.append((p1 - p0).length)
p0 = p1
v0 = v1
# build faces using Panel
lofter = Lofter(
# closed_shape, index, x, y, idmat
True,
[i for i in range(len(profile))],
[p.x for p in profile],
[p.y for p in profile],
[idmat for i in range(len(profile))],
closed_path=False,
user_path_uv_v=user_path_uv_v,
user_path_verts=n_subs
)
faces += lofter.faces(16, offset=f, path_type='USER_DEFINED')
matids += lofter.mat(16, idmat, idmat, path_type='USER_DEFINED')
v = Vector((0, 0))
uvs += lofter.uv(16, v, v, v, v, 0, v, 0, 0, path_type='USER_DEFINED')
评论列表
文章目录