def create_texture(name, tex_type, filename, use_alpha=True):
if filename in img_cache:
# Image has been cached already, so just use that.
img = img_cache[(filename, use_alpha)]
else:
# We haven't cached this asset yet, so load it from disk.
try:
img = bpy.data.images.load(filename)
except:
raise IOError("Cannot load image: %s" % filename)
img.use_alpha = use_alpha
img.pack()
# Cache the asset
img_cache[(filename, use_alpha)] = img
# Create and return a new texture using img
tex = bpy.data.textures.new(name, tex_type)
tex.image = img
return tex
# Adds a hull normal map texture slot to a material.
spaceship_generator.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录