如何使用 Python 在 Blender 2.49 中设置世界背景纹理?
我正在尝试在 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
我已经制作了一种材质,这样我就可以获得一个 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?它在哪里定义的,如何创建实例?
或者正如标题所述......我如何为世界设置纹理?
谢谢
I'm trying to set a background World Texture in Blender 2.49.
I've made a texture:
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)
When I try to apply to the world, that will throw and error, because, by default world.textures contains a tuple of None.
so this wouldn't work:
world.textures[0].tex = worldTex
I've made a material so I can get an MTex instance:
worldMat = Material.New('WorldMat')
worldMat.setTexture(worldTex)
If I try to set the first texture:
world.textures[0] = worldMat.textures[0]
That will throw an error, since I can't assign a value to an already initialized tuple.
If I try to replace it:
world.textures = worldMat.textures
I get yet another error:
TypeError: expected tuple or list containing world MTex objects and NONE
'world MTex' objects got me thinking a bit. Is there another kind of MTex object ? a world MTex ? Where is it defined, how can I create an instance ?
Or as the title states...how do I set a texture to a world ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Blender 2.5x 拥有更好的 Python API。我真的建议观看来自 PyCon 的视频演讲克里斯托弗·韦伯对此进行了介绍。
在 2.5x API 中设置纹理:
Blender 2.5x has a much better Python API. I really recommend watching this video from PyCon talk by Christopher Webber about it.
Setting texture in 2.5x API :