我正在编写一个简单的程序,它应该使用 assimp 库导入一个步骤文件并将其转换为 collada 格式。
这是我的代码:
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/Exporter.hpp>
#include <iostream>
int main()
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile( "../cad/excavator.STEP",
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
if (!scene)
{
std::cout << "ERROR: model could not be loaded. \n";
return 1;
}
// export the scene as a Collada file
Assimp::Exporter exporter;
exporter.Export(scene, "collada", "../solutions/newFile.dae");
return 0;
}
这个脚本输出
Segmentation fault (core dumped)
CMake 输出警告,不知道有没有关系:
CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimpTargets.cmake:54 (if):
if given arguments:
"ON"
An argument named "ON" appears in a conditional statement. Policy CMP0012
is not set: if() recognizes numbers and boolean constants. Run "cmake
--help-policy CMP0012" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/assimp-5.0/assimp-config.cmake:1 (include)
CMakeLists.txt:5 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
使用以下 CMakeList.txt:
find_package(assimp REQUIRED)
add_executable(AssimpTest AssimpTest.cpp)
target_link_libraries(AssimpTest ${ASSIMP_LIBRARIES})
我在 Ubuntu 20.04.6 LTS 上,我正在使用 assimp 版本 5.0.1~ds0-1build1
非常感谢解决此问题的任何帮助。谢谢。