我正在尝试访问.Obj文件的顶点,稍后对它们进行一些操作。但assimp lib显示的Vertices数量。实际上与我通过使用文本编辑器(例如记事本++)打开.Obj文件来检查它们是不一样的。在这方面的任何建议将非常好,预先感谢。 我使用下面的代码片段:使用Assimp无法访问3D模型(.OBJ)的正确顶点数目
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我附上了快照,你可以在我的问题中看到它.. –
好吧。我不太熟悉它。你有没有试过像一个立方体这样的小例子? –