要在网格中加载,我使用来自Assimp的Importer::ReadFile()。
在Assimp的文档中,它指出aiMesh::mVertices和aiMesh::mFaces总是被定义的。当我加载stl文件时,定义了顶点,但没有定义面。我的场景只包含一个网格,并且应该包含这个网格的面的指针始终是1B1B1B1B1B1B1B。
我在网上找到的唯一一个类似的问题就是这个https://sourceforge.net/p/assimp/discussion/817654/thread/a7c953a7/。他也有同样的问题,只是指针是空指针。他通过使用较新版本的Assimp解决了这个问题,即assimp 3.0.1264。我使用的是Assimp 5.0.4162681867,所以我认为这是可以的,但我还没有尝试他的特定版本。
我的代码和输出如下
Assimp::DefaultLogger::create("", Assimp::Logger::VERBOSE, aiDefaultLogStream_STDOUT);
// Create an instance of the Importer class
Assimp::Importer importer;
const aiScene* temp_scene = importer.ReadFile( file,
aiProcess_CalcTangentSpace |
aiProcess_GenNormals |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType |
aiProcess_ValidateDataStructure
);
//kill here the logger, just to see what has happened with the importer
Assimp::DefaultLogger::kill();
//check if scene
if (temp_scene == NULL)
{
std::cout << __LINE__ << ": Error importing scene. Check if file exists ! " << std::endl;
return -1;
}
else
{
int meshIdx = temp_scene->mRootNode->mChildren[0]->mMeshes[0];
std::cout << __LINE__ << ": idx " << meshIdx << std::endl;
std::cout << __LINE__ << ": mNumFaces: " << temp_scene->mMeshes[meshIdx]->mNumFaces << std::endl;
std::cout << __LINE__ << ": HasFaces(): " << temp_scene->mMeshes[meshIdx]->HasFaces() << std::endl;
std::cout << __LINE__ << ": ptr mFace[0]: " << &(temp_scene->mMeshes[meshIdx]->mFaces[0]) << std::endl;
}
exit(0);Info, T21520: Load C:/Users/Woute/Documents/2021-2022/computationalFabrication/files/balanced_die.stl
Debug, T21520: Assimp 5.0.4162681867 amd64 msvc debug shared singlethreadedsingle :
Info, T21520: Found a matching importer for this file format: Stereolithography (STL) Importer.
Info, T21520: Import root directory is 'C:/Users/Woute/Documents/2021-2022/computationalFabrication/files\'
Info, T21520: STL: Taking code path for Materialise files
Debug, T21520: UpdateImporterScale scale set: 1
Debug, T21520: ValidateDataStructureProcess begin
Debug, T21520: ValidateDataStructureProcess end
Info, T21520: Entering post processing pipeline
Debug, T21520: TriangulateProcess begin
Debug, T21520: TriangulateProcess finished. There was nothing to be done.
Debug, T21520: SortByPTypeProcess begin
Info, T21520: Points: 0, Lines: 0, Triangles: 1, Polygons: 0 (Meshes, X = removed)
Debug, T21520: SortByPTypeProcess finished
Debug, T21520: GenFaceNormalsProcess begin
Debug, T21520: GenFaceNormalsProcess finished. Normals are already there
Debug, T21520: Generate spatially-sorted vertex cache
Debug, T21520: CalcTangentsProcess begin
Error, T21520: Failed to compute tangents; need UV data in channel0
Debug, T21520: CalcTangentsProcess finished
Debug, T21520: JoinVerticesProcess begin
Info, T21520: JoinVerticesProcess finished | Verts in: 6486 out: 4029 | ~37.8816
Info, T21520: Leaving post processing pipeline
47/ idx0
48: mNumFaces: 2162
49: HasFaces(): 1
50: ptr mFace[0]: 1B1B1B1B1B1B1B1B发布于 2021-11-18 20:24:49
检查你的日志后,我猜你的模型中只有一个三角形,但有6486个顶点。
您是否正在使用点云模型?如果没有:您可以在我们项目空间中为该模型创建一个新的问题报告,网址为Github
https://stackoverflow.com/questions/69995392
复制相似问题