我正在使用JCSG和以下代码来制作多边形。我希望它看起来像附加的图像,但结果是一个三角形。
List<Vertex> vertices = new ArrayList<>();
Vector3d normal = Vector3d.xyz(0, 0, 0);
vertices.add(new Vertex(Vector3d.xyz(0, 0, 0), normal));
vertices.add(new Vertex(Vector3d.xyz(100, 0, 0), normal));
vertices.add(new Vertex(Vector3d.xyz(0, 100, 0), normal));
vertices.add(new Vertex(Vector3d.xyz(50, 25, 0), normal));
Polygon p = new Polygon(vertices);
List<Polygon> t = p.toTriangles();
CSG csg = CSG.fromPolygons(t.get(0));
我尝试了很多代码,但我总是得到相同的结果。我会很感激任何指针。
标准构造函数使用你的三个点,尝试这个,并让我知道它是否有效:
List<Vector3d> vertices = new ArrayList<>();
vertices.add(Vector3d.xyz(0, 0, 0));
vertices.add(Vector3d.xyz(50, 25, 0));
vertices.add(Vector3d.xyz(100, 0, 0));
vertices.add(Vector3d.xyz(0, 100, 0));
List<Polygon> t = Polygon.fromConcavePoints(vertices);
CSG csg = CSG.fromPolygons(t);