用于 opengl 的 3DS 文件加载器
这是我在网站上的第一个问题。 我需要一个用于 opengl 应用程序的 3DS 模型加载器。加载器还应该能够加载 .jpg 纹理。我尝试使用 OpenSceneGraph 来实现此目的,但这次我还必须使用整个 OpenSceneGraph 数据结构来渲染场景。是否可以仅使用 OpenSceneGraph 进行模型加载,并使用标准 opengl 代码完成其余工作,尤其是 glTranslate、glRotate 等。
this is my 1st question in the site.
I need a 3DS model loader for opengl applications. Loader should also be able to load .jpg textures. I tried to use OpenSceneGraph for this purpose but this time I have to also use the whole OpenSceneGraph data structure to render the scene. Is it possible to use OpenSceneGraph only for model loading and do the rest with standart opengl code, especially glTranslate, glRotate, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谷歌搜索发现了这个: lib3ds
不确定它是否可以读取 JPEG,但这应该很容易使用 libjpeg 或同等版本。
Googling turned up this: lib3ds
Not sure if it can read JPEGs but that should be easy enough with libjpeg or equivalent.
OpenSceneGraph 使用“插件”来加载文件格式 - 模型和纹理。有适用于 3ds 和 jpeg 的可用插件,但至少 jpeg 插件(我相信)不是在默认配置中构建的 - 创建 OpenSceneGraph makefile(或 Windows 上的项目)时,您需要指定 libjpeg 的位置文件以便构建它(因为该插件基于该库)。一旦您拥有这两个插件,您就可以毫无问题地读取 3ds 文件和 jpeg 纹理。另一种选择是使用其他同时支持 osg(或 ive)(OpenSceneGraph 的本机格式)和 3ds 的转换器。我想到了 Blender,而且它是免费的...
至于将 openGL 调用与 OpenSceneGraph 混合 - 这可能很棘手,但也是可能的。一种选择是从 Drawable 派生您自己的类,然后重写其绘制实现方法,并将其放置在图形中您想要的任何位置,尽管手动绘制 3ds 文件违背了使用场景图的全部目的...
OpenSceneGraph uses "plugins" to load file formats - both models and textures. There are working plugins for 3ds and for jpeg, though at least the jpeg one (I believe) isn't built in the default configuration - when creating the OpenSceneGraph makefiles (or projects on Windows), you need to specify the location of the libjpeg files in order for it to be built (as the plugin is based on that library). Once you have these two plugins, you'll have no problem reading 3ds files and jpeg textures. Another option is to use some other convertor which supports both osg (or ive) - OpenSceneGraph's native format- and 3ds. Blender comes to mind, and it's free...
As for mixing openGL calls with OpenSceneGraph - that can be tricky, but possible. One option is to derive your own class from Drawable, then override its draw implementation method, and place it anywhere you want in the graph, though manually drawing the 3ds files defeats the whole purpose of using a scene-graph...