在Python中,如何将3D等值面导出到Blender中 [英] In Python, how can I export a 3D isosurface into Blender

查看:109
本文介绍了在Python中,如何将3D等值面导出到Blender中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python中有一些3D(x,y,z,value)数据,并且可以在Mayavi中可视化等值面.如何将该等值面导出到可以读入Blender的文件中?

I have some 3D (x,y,z,value) data in python and I can visualize the isosurfaces in Mayavi. How can I export this isosurface into a file that I can read into 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)格式保存等值面:

Using @timday's suggestion, I added the following code to save the isosurface in a wavefront (.obj) format:

mlab.savefig('surface.obj')

mlab.savefig('surface.obj')

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

Then, I can open it in Blender with File>>Import>>Wavefront (.obj)

我不得不大幅度缩小图像(〜100倍),以使其在Blender视口中可见.

I had to scale down the image considerably (~100x) to make it visible in the Blender viewport.

原点设置在实际对象的侧面,因此如果我使用Object >> Transform >> Origin to Geometry,则更易于处理对象

The origin is set way off to the side of the actual object, so the object is easier to deal with if I use Object>>Transform>>Origin to Geometry

添加一些照明和平面后,该对象看起来非常不错!

After adding some lighting and a plane, the object looks pretty good!

这篇关于在Python中,如何将3D等值面导出到Blender中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆