Java - 加载.OBJ文件 [英] Java - Loading .OBJ files

查看:643
本文介绍了Java - 加载.OBJ文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从.obj文件中获取信息(如子组件的名称)。那边有装载机吗? Java3D有一个ObjectFile,但是我看到的方法列表让我觉得它并不是我想要的。我自己解析文件会更好吗?

I want to be able to get information (like names of sub-components) from an .obj file. Is there a loader out there somewhere to do this? Java3D has an ObjectFile, but the list of methods I've seen makes me think it is not exactly what I want. Would I be better off just parsing the file myself?

谢谢
-Will

Thanks -Will

推荐答案

几个月前我写了一个java obj文件格式加载器,应该可以轻松地完成你需要的工作。
它位于git hub上;

I wrote a java obj file format loader a few months ago that should easily do what you need. It's on git hub at;

https: //github.com/seanrowens/oObjLoader

请注意,README表示它是pre-alpha - 这主要是因为几乎没有其他人见过它。

Note that the README says it's pre-alpha - this is primarily because pretty much nobody else has seen it yet.

它解析大多数.obj格式以及.mtl格式。现在用它解析的内容做了什么...好吧,我尝试采用类似SAX的方法。有一个Parser,它使用每个已解析的元素调用BuilderInterface上的方法。 BuilderInterface有一个简单的示例实现,还有一个简单的LWJGL查看应用程序,将它们连接在一起。

It parses most all of the .obj format as well as the .mtl format. Now what it DOES with what it parses... well, I tried to take a SAX like approach. There is a Parser that calls methods on a BuilderInterface with each parsed element. There is a simple sample implementation of the BuilderInterface and also a simple LWJGL viewing app that ties it all together.

它目前没有对更奇特的几何语句做任何有用的事情,即顶点和多边形以外的任何东西,换句话说它忽略除顶点和多边形之外的任何几何。它解析并捕获.mtl文件,但实际的查看器除了非常非常简单的纹理外没有实现任何东西。

It doesn't currently do anything useful with more exotic geometry statements, i.e. anything other than vertices and polygons, in other words it ignores any geometry except for vertices and polygons. It parses and captures .mtl files but the actual viewer doesn't implement anything except very very very simple textures.

我非常乐意听到任何和所有反馈和建议。许可证非常宽松;

I'd more than happy to hear any and all feedback and advice. The license is extremely liberal;


此代码由我自己撰写,Sean R. Owens,sean at guild dot net,
并发布到公共领域。分享和享受。由于一些
的人认为无法向公共
域发布软件,因此您也可以在任何版本的
GPL,LPGL,Apache或BSD许可下使用此代码。 ,或联系我使用另一个
许可证。

This code was written by myself, Sean R. Owens, sean at guild dot net, and is released to the public domain. Share and enjoy. Since some people argue that it is impossible to release software to the public domain, you are also free to use this code under any version of the GPL, LPGL, Apache, or BSD licenses, or contact me for use of another license.

这篇关于Java - 加载.OBJ文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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