3索引缓冲区 [英] 3 index buffers

查看:192
本文介绍了3索引缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,在这两个D3D和OpenGL有一个从索引缓存绘制的能力。

So, in both D3D and OpenGL there's ability to draw from an index buffer.

OBJ文件格式,但确实很奇怪。它指定了一堆顶点,如:

The OBJ file format however does something weird. It specifies a bunch of vertices like:


v -21.499660 6.424470 4.069845
v -25.117170 6.418100 4.068025
v -21.663851 8.282170 4.069585
v -21.651890 6.420180 4.068675
v -25.128481 8.281520 4.069585

然后指定如..

Then it specifies a bunch of normals like..


vn 0.196004 0.558984 0.805680
vn -0.009523 0.210194 -0.977613
vn -0.147787 0.380832 -0.912757
vn 0.822108 0.567581 0.044617
vn 0.597037 0.057507 -0.800150
vn 0.809312 -0.045432 0.585619

然后指定喜欢

Then it specifies a bunch of tex coords like


vt 0.1225 0.5636
vt 0.6221 0.1111
vt 0.4865 0.8888
vt 0.2862 0.2586
vt 0.5865 0.2568
vt 0.1862 0.2166

然后,它规定了该模型的面孔,如:

THEN it specifies "faces" on the model like:


f 1/2/5 2/3/7 8/2/6
f 5/9/7 6/3/8 5/2/1

如果我们 V / T / N 中的第一个数字是一个索引入顶点数组,第二中的索引tex的坐标数组,第三,进法线数组。

Where we're v/t/n the first number is an index into the vertices array, the second an index into the tex coord array, the third, into the normals array.

因此​​,试图用顶点缓冲区渲染这个,

So, in trying to render this with vertex buffers,

在OpenGL的,我可以使用的glVertexPointer glNormalPointer glTexCoordPointer 设置指针到每个顶点的,正常和纹理坐标数组分别..但是当它归结为与与glDrawElements ,我只能指定 ONE 设置指数,即指数应该访问的顶点时使用。

In OpenGL I can use glVertexPointer, glNormalPointer and glTexCoordPointer to set pointers to each of the vertex, normal and texture coordinate arrays respectively.. but when it comes down to drawing with glDrawElements, I can only specify ONE set of indices, namely the indices it should use when visiting the vertices.

好了,然后呢?我仍然有 3 套​​指标的访问。

Ok, then what? I still have 3 sets of indices to visit.

在D3D的大致相同的 - 我可以设置3个数据流:一个顶点,一个用于texcoords,一个用于法线,但是当涉及到​​使用的IDirect3DDevice9 :: DrawIndexedPrimitive,我仍然只能指定 ONE 索引缓冲,这将指数到顶点数组。

In d3d its much the same - I can set up 3 streams: one for vertices, one for texcoords, and one for normals, but when it comes to using IDirect3DDevice9::DrawIndexedPrimitive, I can still only specify ONE index buffer, which will index into the vertices array.

那么,是不是可能从顶点缓冲区使用不同的数组索引每个顶点,TEXCOORD的,和正常的缓冲区(无论是D3D和OpenGL的!)来绘制,或必须创建一个单独的交错数组,然后访问它?

So, is it possible to draw from vertex buffers using different index arrays for each of the vertex, texcoord, and normal buffers (EITHER d3d or opengl!), or must I create a single interleaved array and then visit IT?

推荐答案

OBJ没有设计映射到OpenGL或DirectX的。

OBJ was not designed to map to OpenGL or DirectX.

你说的一切都是真的,并没有,这是不可能的使用每个属性的索引。

Everything you said is true, and no, it's not possible to use per-attribute indices.

您必须转换OBJ重新presentation的东西,只用每个顶点的单一指标(可能是复制一些沿途的顶点数据)。

You have to convert the OBJ representation to something that only uses a single index per vertex (possibly duplicating some vertex data along the way).

这篇关于3索引缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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