如何在Blender2.49中使用Python设置世界背景纹理?

2024-05-12 15:16:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着在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)

当我试图应用于这个世界时,这会抛出错误,因为,默认情况下世界.纹理包含一个None的元组。 所以这行不通:

^{pr2}$

我制作了一个材质,这样我就可以得到一个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?在哪里定义的,如何创建实例?在

或者就像标题所说的…我如何为一个世界设置一个纹理?在

谢谢


Tags: 实例imageimportnewworld错误世界元组
1条回答
网友
1楼 · 发布于 2024-05-12 15:16:05

blender2.5x有一个更好的pythonapi。我真的建议你看这篇克里斯托弗·韦伯的演讲。在

在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

相关问题 更多 >