【发布时间】:2017-06-04 07:28:21
【问题描述】:
我正在尝试访问 .Obj 文件的顶点,然后对它们进行一些操作。但是 assimp lib 显示的顶点数。实际上与我通过使用文本编辑器(例如 notepad++)打开 .Obj 文件来检查它们不同。在这方面的任何建议都会非常好,在此先感谢。 我正在使用以下代码 sn-p:
std::string path = "model.obj";
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate);
//i've changed the parameters but the issue is same
auto mesh = scene->mMeshes[0]; //Zero index because Im loading single model only
ofstream outputfile; //write the vertices in a text file read by assimp
outputfile.open("vertex file.txt");
for (int i = 0; i < mesh->mNumVertices; i++) {
auto& v = mesh->mVertices[i];
outputfile << v.x <<" " ;
outputfile << v.y << " ";
outputfile << v.z << " "<<endl;
}
outputfile.close();
Difference between the no. of vertices in both files can be seen at index value here
【问题讨论】:
-
你能显示点坐标的差异吗?
-
@jonas_toth 我附上了快照,你可以在我的问题中看到它..
-
好吧。我对它不是很熟悉。您是否尝试过一个最小的示例,例如一个立方体或类似的东西?
-
@jonas_toth 是的,我已经尝试过有 8 个顶点的立方体,而 assimp 显示了 24 个顶点,所以它已经成功了 3 次..!!这个 ×3 背后的逻辑是什么?有什么想法吗?
-
也许它不重用顶点。当你有一个四边形时,你可以把它分成两个三角形。它可以为每个三角形相应地复制顶点。在一个立方体中,每个顶点应该属于3个面(三角形),这样可以解释它