def execute(self, context):
if not hasattr(bpy, "wow_game_data"):
print("\n\n### Loading game data ###")
bpy.ops.scene.load_wow_filesystem()
game_data = bpy.wow_game_data
for ob in bpy.context.selected_objects:
mesh = ob.data
for i in range(len(mesh.materials)):
if mesh.materials[i].active_texture is not None \
and not mesh.materials[i].WowMaterial.Texture1 \
and mesh.materials[i].active_texture.type == 'IMAGE' \
and mesh.materials[i].active_texture.image is not None:
path = (os.path.splitext(bpy.path.abspath(mesh.materials[i].active_texture.image.filepath))[0] + ".blp", "")
rest_path = ""
while True:
path = os.path.split(path[0])
if not path[1]:
print("\nTexture <<{}>> not found.".format(mesh.materials[i].active_texture.image.filepath))
break
rest_path = os.path.join(path[1], rest_path)
rest_path = rest_path[:-1] if rest_path.endswith("\\") else rest_path
sys.stdout = open(os.devnull, 'w')
if game_data.read_file(rest_path):
mesh.materials[i].WowMaterial.Texture1 = rest_path
break
sys.stdout = sys.__stdout__
self.report({'INFO'}, "Done filling texture paths")
return {'FINISHED'}
operators.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录