我正在尝试在 Blender 2.49 中设置背景世界纹理。
我制作了纹理:
import Blender
from Blender import *
import bpy
world = World.GetCurrent()
worldTex = Texture.New('worldTex')
worldTex.setType('Image')
worldIm = Image.Load('//blender_scene/tex/bg 001.jpg')
worldIm.source = Image.Sources.SEQUENCE
worldTex.setImage(worldIm)
当我尝试应用于世界时,会抛出错误,因为默认情况下 world.textures 包含一个 None 元组。 所以这行不通:
world.textures[0].tex = worldTex
我已经制作了一个 Material ,以便我可以获得 MTex 实例:
worldMat = Material.New('WorldMat')
worldMat.setTexture(worldTex)
如果我尝试设置第一个纹理:
world.textures[0] = worldMat.textures[0]
这会引发错误,因为我无法为已初始化的元组分配值。
如果我尝试替换它:
world.textures = worldMat.textures
我又收到一个错误:
TypeError: expected tuple or list containing world MTex objects and NONE
“world MTex”对象让我思考了一下。还有另一种 MTex 对象吗?世界MTex?它在哪里定义的,如何创建实例?
或者如标题所述...如何为世界设置纹理?
谢谢
最佳答案
Blender 2.5x 拥有更好的 Python API。我真的推荐看这个video from PyCon克里斯托弗·韦伯 (Christopher Webber) 对此进行了谈论。
在 2.5x API 中设置纹理:
import bpy
# create new clouds texture
bpy.ops.texture.new()
t = bpy.data.textures[-1]
# set World texture
w = bpy.data.world['World']
slot = w.texture_slots.add()
slot.texture = t
slot.use_map_horizon = True
关于python - 如何使用 Python 在 Blender 2.49 中设置世界背景纹理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3284382/