有没有人成功编译和使用 Carve CSG 库?我正在尝试在一个项目中使用它,但我无法让它工作。此外,文档非常糟糕。我一直在查看 Blender 源代码,它似乎成功地使用了 Carve,但我在复制它时遇到了麻烦。
这是我一直在尝试使用的代码,只是为了创建一个与 Carve 一起使用的立方体:
std::vector<carve::geom3d::Vector> vertices;
vertices.push_back(carve::geom::VECTOR(+1.0, +1.0, +1.0));
vertices.push_back(carve::geom::VECTOR(-1.0, +1.0, +1.0));
vertices.push_back(carve::geom::VECTOR(-1.0, -1.0, +1.0));
vertices.push_back(carve::geom::VECTOR(+1.0, -1.0, +1.0));
vertices.push_back(carve::geom::VECTOR(+1.0, +1.0, -1.0));
vertices.push_back(carve::geom::VECTOR(-1.0, +1.0, -1.0));
vertices.push_back(carve::geom::VECTOR(-1.0, -1.0, -1.0));
vertices.push_back(carve::geom::VECTOR(+1.0, -1.0, -1.0));
std::vector<int> f;
int numfaces = 6;
f.push_back(4);
f.push_back(0);
f.push_back(1);
f.push_back(2);
f.push_back(3);
f.push_back(4);
f.push_back(7);
f.push_back(6);
f.push_back(5);
f.push_back(4);
f.push_back(4);
f.push_back(0);
f.push_back(4);
f.push_back(5);
f.push_back(1);
f.push_back(4);
f.push_back(1);
f.push_back(5);
f.push_back(6);
f.push_back(2);
f.push_back(4);
f.push_back(2);
f.push_back(6);
f.push_back(7);
f.push_back(3);
f.push_back(4);
f.push_back(3);
f.push_back(7);
f.push_back(4);
f.push_back(0);
carve::mesh::MeshSet<3> *poly = new carve::mesh::MeshSet<3> (vertices, numfaces, f);
它似乎卡在最后一行,陷入长时间运行的循环,然后出现段错误。