获得基本的3D模型引入一个OpenGL应用程序 [英] Getting basic 3D models into an OpenGL app

查看:197
本文介绍了获得基本的3D模型引入一个OpenGL应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧......我做的​​简单的OpenGL ES编程当我说简单,是最复杂的事情,我做的并不比荣耀的斜面多维数据集和L形等等。 (想得很俄罗斯方块,但在3D)。但是,让所有的顶点数据到一个应用程序或者是一个)手工codeD(啊!)或b)第三方游戏引擎(双UGH!)或你使用一些第三方文件类型进口国。 (部分噢!)

Ok... I'm doing simple OpenGL ES programming and when I say simple, the most complicated things I do aren't much more than glorified beveled cubes and L-shapes. (Think very Tetris but in 3D.) However, getting all that vertex data into an app is either a) hand-coded (UGH!) or b) 3rd-party game engine (double-UGH!!!) or you use some 3rd-party filetype importer. (Partial Ugh!)

有一个例外。

我一直在使用一个程序在Mac上叫Cheetah3D这是pretty的良好的建模(不是很大,但实...好),但有一件事是有,我还没有在其他地方看到的是能够直接导出模型,以C-准备的头文件。它导出所有的数组你,甚至给你code,以使它们(尽管在一个注释块作为参考。)

I've been using a program on the Mac called Cheetah3D which is a pretty good modeler (not great, but solid... good) and the one thing it has that I haven't seen elsewhere is the ability to export your models directly to c-ready header files. It exports all the arrays for you and even gives you the code to render them (albeit in a commented out block as a reference.)

虽然这是伟大的90%,我们做什么,有一些事情建模不能像让我指定相同的顶点两个不同的面孔,但使用不同的标准,每一个...甚至混合平面和曲面的法线(或更确切地说它们如何呈现)在同一个模型

While this is great for 90% of what we do, there are some things the modeler can't, like allowing me to specify the same vertex for two different faces but using a different normal for each one... or even to mix flat and curved normals (or rather how they render) in the same model.

请注意这些功能很容易在obj文件,因为你描述的法线和顶点在不同的阵列可以与面孔很容易地指定,但他们不出来头文件的方式。

Note those features are easily described in an .obj file since your normals and vertices are in different arrays that you can easily specify together with faces but they don't come out in the header file that way.

所以... OBJ文件(或任何其他文件类型,将工作为此事......)来获取到您的code最好的方法是什么?

SO... obj files (or any other file type that will work for that matter...) best way to get it into your code?

思考?

推荐答案

任何人做3D的工作,应该在某个时候写一个 OBJ 型号装载机。

OBJ file format.

Anyone doing 3D work, should at sometime write a obj model loader.

它是一种非常简单的文件格式。

Its a very simple file format.

v
t
n
f

其中:

  • v是顶点。
  • t是纹理坐标。
  • n是正常的。
  • f是脸。

这是例子OBJ文件片段:

An example obj file segment:

v 1.0 0.1 0.1
t 1.0 0.0
n 1.0 1.0
f 1/1/1 1/1/1 1/1/1

所有需要的是存储4集以上的,当它涉及到渲染顶点的面,使用索引并进行简单的外观起伏。简单的文件I / O是很容易做到的任何语言​​,所以一切的一切,用一个OBJ文件是很容易的。

All it takes is storing four collections of the above, and when it comes to rendering the face of a vertex, use the index and perform simple look ups. Simple file I/O is very easy to do in any language, so all in all, using an obj file is quite easy.

当然,缺点OBJ文件是他们可以得到相当大的。就个人而言,我从来没有发现这个问题,并经常采取OBJ文件格式为出发点,并去除一些重复的,专门创建一个自定义的文件格式为我的申请。

Naturally, the downside to obj files is they can get quite big. Personally, I've never found this an issue, and often take the obj file format as a starting point and remove some of the duplication to create a custom file format specially for my application.

这篇关于获得基本的3D模型引入一个OpenGL应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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