我正在将一个旧脚本改编为 Blender 2.6,该脚本从自定义文件类型中读取网格数据,然后使用该数据创建一个网格数组。
我实现了将每个顶点的 uv 值设置为网格。
我像这样创建网格数组:
for i in range(0,numeroparts):
malla.append(bpy.data.meshes.new(name="2k_Part"+str(i)))
uv = []
xyz= []
for j in range(0,numerovertxpart[i]):
line=file.readline()
x,y,z,u,v=float(line.split()[0].replace(',','.')),float(line.split()[1].replace(',','.')),float(line.split()[2].replace(',','.')),float(line.split()[3].replace(',','.')),float(line.split()[4].replace(',','.'))
uv.append((u,v))
xyz.append((x,y,z))
print(x,y,z)
aa = []
bb = []
cc = []
faces= []
for j in range(0,numerofacexpart[i]):
line=file.readline()
a,b,c=int(line.split()[0]),int(line.split()[1]),int(line.split()[2])
faces.append((a,b,c))
aa.append(a)
bb.append(b)
cc.append(c)
print(a,b,c)
malla[i].from_pydata(xyz, [], faces)
for q in range(len(malla[i].polygons)):
#malla[i].faces[q].mode |= Blender.Mesh.FaceModes['TWOSIDE']
#malla[i].faces[q].transp = Blender.NMesh.FaceTranspModes['ALPHA']
#malla[i].faces[q].uv=Mathutils.Vector(uv[aa[q]]), Mathutils.Vector(uv[bb[q]]), Mathutils.Vector(uv[cc[q]])
我的问题在这里:
for q in range(len(malla[i].polygons)):
#malla[i].faces[q].mode |= Blender.Mesh.FaceModes['TWOSIDE']
#malla[i].faces[q].transp = Blender.NMesh.FaceTranspModes['ALPHA']
#malla[i].faces[q].uv=Mathutils.Vector(uv[aa[q]]), Mathutils.Vector(uv[bb[q]]), Mathutils.Vector(uv[cc[q]])
我不知道如何设置 uv 值,注释的行是我为搅拌机 2.49 所做的