python - 如何在Vpython中添加纹理?

标签 python vpython

我想知道如何在我的 Vpython 脚本中将纹理放在我的盒子上?

最佳答案

from visual import *

box(pos=(-1,-1,-2), length=2, height=2, width=4, material=materials.wood)

enter image description here

更多详情,请参阅 http://vpython.org/contents/docs/visual/materials.html

编辑:在上面的链接中查找标题为“从照片制作纹理”的部分

编辑2:不确定是什么导致了您的错误;这对我有用:

from visual import *
import Image

im = Image.open('flower.jpg')  # size must be power of 2, ie 128 x 128
tex = materials.texture(data=im, mapping='rectangular')

box(material=tex)

enter image description here

Edit3:我找出了导致您错误的原因:

box(material=materials.loadTGA(filename))

失败;

tex = materials.texture(data=loadTGA(filename), mapping='rectangular')
box(material=tex)

工作正常。

关于python - 如何在Vpython中添加纹理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11379325/

相关文章:

python - Pandas 查找半小时数据帧索引的每日系列值

python - 在 python 中使用 sklearn 进行连续数据的逻辑回归

python - 对于 Pandas 系列,s.sort_index(inplace=True) 不应该改变 s 吗?

python - 在 VPython 中创建一个面孔?

python - Visual Python 工作非常缓慢

python - 如何在 vpython 中固定 Canvas 和图形的位置?

python - Holoviews 与 xarray 数据集 : How to scatter-plot two variables?

python使用内部类作为静态类变量奇怪的行为

python - vpython Axis 的问题,仅接受诸如 (1,0,0) 之类的向量,即一个轴,而不接受诸如 (2,2,1) 之类的向量

python - "Property ' pos ' must be a vector"运行VPython代码时出错