是否有特定或非常适合光线追踪的 3D 场景格式?
我正在开发光线追踪器,并且我不想在 3D 场景的文件格式方面重新发明轮子。我还希望能够用其他人制作的场景来测试我的程序。我是一名程序员,而不是 3D 建模师。
是否有特定或非常适合光线追踪的 3D 场景格式?
I'm working on a raytracer and I don't want reinvent the wheel when it comes to file formats for 3D scenes. I also want to be able to test my program with scenes made by others. I'm a programmer not a 3D modeller.
Is there a 3D scene format specific or well-suited for raytracing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当我编写光线追踪器时,我为 Blender 编写了一个导出器(它是免费的)。 Blender 本身可以加载数十种格式,然后一个简单的 20 行 python 脚本将为您提供所需的点。
超级好的功能是,在 Blender 中,您可以将模型的所有面转换为三角形。大多数光线追踪器仅适用于三角形(或在内部将多边形转换为三角形)。因此,让 Blender 完成处理这些多边形的繁重工作是非常好的。
首先,20 行代码将允许您仅导出多边形。从那里,您可以将其扩展到输出材质、法线等。我喜欢这种方法,因为我可以以我想要的格式获取我想要的数据,但仍然可以选择导入更复杂的模型。
其他方法也可以,但您首先必须弄清楚如何解析文件,然后以您想要的格式获取它。我宁愿编写光线追踪器而不是解析器。
When I wrote my ray tracer, I wrote an exporter for Blender (it's free). Blender itself can load dozens of formats, then a simple 20 line python script will give you the points you need.
The super nice feature is that within Blender you can convert all the model's faces to triangles. Most ray tracers will only work with triangles (or convert polygons to triangles internally). So having Blender do the heavy work of crunching those polygons is super nice.
To start with 20 lines of code will allow you to export just the polygons. From there, you can extend it to output materials, normals, etc. I like this method, because I can get the data I want in the format I want, but still have the option of importing more complex models.
Other methods will work, but you first have to figure out how to parse a file, then get it in the format you want. I'd rather code a ray tracer than a parser.
实际上没有特定于光线追踪的格式(除非算上 PovRay 格式)。光线追踪是一种渲染图像的方法,可以应用于任何场景。人们对场景进行建模将使用他们选择的建模软件,并通常以建模器的默认格式保存。
看起来您没有任何加载特定格式的要求(或者您不会询问),所以我猜您只是希望能够从网络上导入各种几何图形进行测试。如果是这种情况,请查看 ompf 论坛:http://ompf.org/ 他们有一个包含链接的部分到免费可用的场景。您可以感受到那里的共同点。
另一种选择是利用开放资产导入库:
http://assimp.sourceforge.net/
这可以为您导入大量文件格式。它将它们全部加载到内部数据结构中,然后您可以根据需要进行处理。它使用 BSD 许可证,因此它应该与您正在做的任何事情合理地兼容。
There really isn't a format specific to ray tracing (unless you count PovRay format). Ray tracing is a method of rendering images, which can be applied to any scene. People modeling scenes will be using the modeling software of their choice and save usually in the default format of the modeler.
It looks like you don't have any requirements to load a particular format (or you wouldn't be asking) so I'm guessing you just want to be able to import various geometry from around the net for testing. If that's the case, check out the ompf forum at: http://ompf.org/ They have a section with links to freely available scenes. You can get a feel for what's common there.
Another option is utilize the Open Asset Import Library:
http://assimp.sourceforge.net/
this can import a large number of file formats for you. It loads them all into an internal data structure, which you can then process as you see fit. It uses a BSD license so it should be reasonably license compatible with whatever you're doing.
我不相信使用任何特定的场景格式,因为不同的建模者需要不同的参数和设置指令等。
WaveFront
.obj
格式 对于描述场景中的单个对象以及许多文件来说非常流行该格式可在互联网上找到。I don't believe there's any particular scene format in use, because different modellers require different parameters, and setup directives, etc.
The WaveFront
.obj
format is however very popular for describing individual objects within a scene, and many files in that format are available on the internet.