Python 中 3D 模型(点/线)的渲染器
我有一个由空间中的点、线和球组成的 3D 模型。对于调试来说,实时渲染这些对象并可旋转会很好。
在 python 中实现此目的最简单的选择是什么? 由于我对图形编程一无所知,因此我想编写尽可能少的样板代码。
I have a 3d model that consists of points, lines and balls in space. For debugging, it would be nice to render these objects in real time and rotateable.
What are my easiest options to achieve this in python?
Since I know nothing about graphical programming, I'd like to write as litte boilerplate code as possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 python 中在屏幕上显示 3D 图形的最简单方法是 VPython,不过如果您的模型以 CAD 文件格式存储,您将需要一些其他库来加载数据。仅使用 VPython,您要么需要对模型进行硬编码,要么实现您自己的加载器。
The easiest way to get 3d graphics on screen in python is VPython, though if your model is stored in a CAD file format, you'll need some other library to load the data. With just VPython, you will either need to hard-code the model or implement your own loader.
我自己会考虑两个选择(取决于您最终想要做什么):
Blender 具有相当惊人的 Python 集成。简单示例此处。据我了解,Blender自己的文件保存格式是可执行python,它刺激Blender Python API 用于重建场景。还有一种机制可以将 游戏逻辑引入 Blender 世界,但我知道甚至对此知之甚少。 Blender 确实有一个非常陡峭的学习曲线。
使用 Python OpenGL 绑定 进入 OpenGL。 “简单”示例。
如果您对创建模型更感兴趣,请选择前者;如果您对它们的渲染更感兴趣,请选择后者。
Two options I'd consider myself (depends what you're trying to do in the end):
Blender has fairly amazing Python integration. Simple example here. As I understand it, Blender's own file save format is executable python which prods the Blender Python API to reconstruct the scene. There's also a mechanism for introducing gamey logic into the Blender world but I know even little about it. Blender does have a crazy steep learning curve though.
Get into OpenGL using the Python OpenGL bindings. "Simple" example.
If you're more interested in creating the models, go with the former; if you're more interested in the rendering of them, go with the latter.
首先想到的是 processing,这是一个易于使用的可视化工具包。虽然你实际上是用 java 实现可视化的,但快速谷歌一下就发现了这个,它可以让你在其中编写草图改为蟒蛇。
The first thing that springs to mind is processing which is an easy to use visualization toolkit. Although you actually implement your visualizations in java, a quick google found this which lets you write your sketches in python instead.