Assimp 人脸指数 [英] Assimp faces indices
问题描述
我已经使用 Assimp 一段时间了,现在我正在尝试加载 .obj 文件.它加载完美,但我想在加载后操作面部数据.
I have been using Assimp for a while and now I'm trying to load a .obj file. It loads perfectly, but I would like to manipulate the face data after loading it.
基本上我在简单的 cube.obj 文件中有这个(完整文件 - http://pastebin.com/ha3VkZPM)
Basically I have this in the simple cube.obj file (Full file - http://pastebin.com/ha3VkZPM)
# 8 Vertices
v -1.0 -0.003248 1.0
v 1.0 -0.003248 1.0
v -1.0 1.996752 1.0
v 1.0 1.996752 1.0
v 1.0 -0.003248 -1.0
v -1.0 -0.003248 -1.0
v 1.0 1.996752 -1.0
v -1.0 1.996752 -1.0
# 36 Texture Coordinates
vt 1.0 0.0
vt 0.0 0.0
...
# 36 Vertex Normals
vn 0.0 0.0 1.0
vn 0.0 0.0 1.0
...
f 1/1/1 2/2/2 3/3/3
f 2/4/4 4/5/5 3/6/6
f 5/7/7 6/8/8 7/9/9
f 6/10/10 8/11/11 7/12/12
f 3/13/13 6/14/14 1/15/15
f 3/16/16 8/17/17 6/18/18
f 7/19/19 2/20/20 5/21/21
f 7/22/22 4/23/23 2/24/24
f 3/25/25 7/26/26 8/27/27
f 3/28/28 4/29/29 7/30/30
f 2/31/31 6/32/32 5/33/33
f 2/34/34 1/35/35 6/36/36
据我所知,面部输入是 V/T/N(顶点索引、tex 坐标索引和法线索引).
And as I understand face entry is V/T/N (Vertex indicies, tex coord indices and normal indices).
所以f 1/1/1 2/2/2 3/3/3
表示顶点为 (1,2,3) 的三角形 - 对吗?
so
f 1/1/1 2/2/2 3/3/3
represents a triangle of vertices (1,2,3) - right?
从这个人脸条目 - 我只想提取顶点索引.
From this face entry - I want to extract only the vertex indices.
现在进入 Assimp - 我现在有了这个 - Indices
是一个 stl::vector
Now enters Assimp - I have this now - Where Indices
is a stl::vector
for (uint32 i = 0; i < pMesh->mNumFaces; i++) {
const aiFace& Face = pMesh->mFaces[i];
if(Face.mNumIndices == 3) {
Indices.push_back(Face.mIndices[0]);
Indices.push_back(Face.mIndices[1]);
Indices.push_back(Face.mIndices[2]);
}
这里是 pMesh->mNumFace = 12
的值 - 所以这是正确的.
Here are the values of pMesh->mNumFace = 12
- So thats correct.
(for 1st face)
Face.mindices[0] should probably point to 1/1/1
Face.mindices[1] should probably point to 2/2/2
Face.mindices[2] should probably point to 3/3/3
现在如何只提取顶点索引?当我检查 Face.mIndices[0] 的值时,它的索引分别为 0,1,2....
为什么会这样?Assimp Faces 都有索引 (0,1,2)
Now how do I extract only the vertex indices? And when I check the values of Face.mIndices[0] its index as 0,1,2...respectively.
Why so? Assimp Faces all have indices (0,1,2)
我在 Google 和 StackOverflow 上搜索过 - 这里有一些类似的问题,但我似乎无法弄清楚.
I searched on Google and StackOverflow - here are some similar question but I cant seem to figure it out.
Assimp 和 D3D 模型加载:网格未在 D3D 中显示
如果您需要更多信息,请告诉我.谢谢.
Please let me know if you need more info. Thanks.
推荐答案
OpenGL 和 DirectX 使用与 obj 格式稍有不同的顶点数据索引方式.与可以对位置/texcoords 等使用不同索引的文件格式相比,图形卡需要一个用于整个顶点的索引缓冲区.
OpenGL and DirectX use a slightly different way of indexing vertex data then the obj format does. In contrast to the file format where it is possible to use different indices for positions/texcoords etc, the graphic card requires one single index buffer for the whole vertex.
蜜蜂说:Assimp 传递 obj 格式并将其转换为单索引缓冲区表示.基本上这意味着,每个唯一的顶点-texcoord-normal 组合都会给出一个顶点,而 indexbuffer 指向这个新的顶点列表.
That beeing said: Assimp passes the obj format and transforms it into a single-index-buffer representation. Basically this means, that each unique vertex-texcoord-normal combination will give one vertex while the indexbuffer points to this new vertex list.
据我所知,使用 Assimp 无法访问原始索引.
As far as I know, it is not possible to access the original indices using Assimp.
这篇关于Assimp 人脸指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!