如何使用Python在Blender 2.49中设置世界背景纹理?

如何使用Python在Blender 2.49中设置世界背景纹理?,python,3d,textures,blender,bpython,Python,3d,Textures,Blender,Bpython,我正在尝试在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.sourc

我正在尝试在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包含一个无元组。 所以这是行不通的:

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
“worldMTex”对象让我思考了一下。还有其他类型的MTex对象吗?世界MTex?在何处定义,如何创建实例

或者如标题所述…如何设置世界的纹理


感谢Blender 2.5x提供了更好的Python API。我真的建议你看看克里斯托弗·韦伯的演讲

在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

Blender2.5x有一个更好的Python API。我真的建议你看看克里斯托弗·韦伯的演讲

在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

非常有趣的演讲,谢谢你的资源。事实上,Blender 2.5会更好,但Blender 2.49是当时的一项要求,这就是为什么特别提到2.49的原因。作为一个肮脏的解决办法,我在默认的blender模板中添加了一个材质槽,以便继续,但我仍然对那里发生的事情以及真正的解决方案感兴趣。我从2.5x开始使用blender,所以我在这里帮不了你。抱歉,非常有趣的谈话,谢谢你的资源。事实上,Blender 2.5会更好,但Blender 2.49是当时的一项要求,这就是为什么特别提到2.49的原因。作为一个肮脏的解决办法,我在默认的blender模板中添加了一个材质槽,以便继续,但我仍然对那里发生的事情以及真正的解决方案感兴趣。我从2.5x开始使用blender,所以我在这里帮不了你。很抱歉