python - 在 Python 中,如何将 3D 等值面导出到 Blender

标签 python scipy blender mayavi

我在 python 中有一些 3D(x、y、z、值)数据,我可以在 Mayavi 中可视化等值面。我怎样才能将这个等值面导出到一个我可以读入 Blender 的文件中?

下面是一些示例代码:

import numpy
from mayavi import mlab

x, y, z = numpy.ogrid[-5:5:64j, -5:5:64j, -5:5:64j]
values = x * x * 0.5 + y * y + z * z * 2.0
mlab.contour3d(values, contours=[.5])
mlab.show()

最佳答案

根据@timday 的建议,我添加了以下代码以将等值面保存为波前 (.obj) 格式:

mlab.savefig('surface.obj')

然后,我可以使用 File>>Import>>Wavefront (.obj) 在 Blender 中打开它

我不得不大幅缩小图像(~100 倍)以使其在 Blender 视口(viewport)中可见。

enter image description here

原点设置在实际对象的一侧,所以如果我使用对象>>变换>>原点到几何图形,对象更容易处理

enter image description here

添加了一些光照和平面后,对象看起来不错!

enter image description here

关于python - 在 Python 中,如何将 3D 等值面导出到 Blender,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25772280/

相关文章:

python - 如何在 Blender 导出脚本中导出每个顶点的 UV 坐标

eclipse - Blender 附加组件的 PyDev 和 Eclipse 设置

python - 从脚本调用蜘蛛时如何向 scrapy 蜘蛛添加随机用户代理?

python - 将距离矩阵传递给 seaborn clustermap

python - 我知道 scipy curve_fit 可以做得更好

python - 点集之间的有符号距离

php - 从 blender 导出的 .X3D 文件具有黑色背景,我无法更改

python - opencv cascade.detectMultiScale 创建错误 : (-215) ! empty()

python - 如何合并数据框和填充值

python - 我想将 Python 模型列表转换为字典