gpt4 book ai didi

java - 如何使用 JavaFX、JCSG 和 FXyz 进行差分运算后获得闭合的 3D 网格?

转载 作者:行者123 更新时间:2023-12-01 09:49:00 28 4
gpt4 key购买 nike

我正在使用 JCSG 库来切割 3D 对象,但是经过差分操作后生成的 3D 网格并不完全闭合,即切割表面的许多边缘都是开放的,它们不属于任何三角形。

我正在使用下面的源代码来切割 3D 网格。

MeshView box = new MeshView(cube);
CSG boxCSG = MeshUtils.mesh2CSG(box);
CSG testmesh = MeshUtils.mesh2CSG(test.getMesh());
CSG cutCSG = testmesh.difference(boxCSG.transformed(Transform.unity().translateZ(-10000)));
CSGMesh cutMesh = new CSGMesh(cutCSG);

测试对象显示如下here

对测试网格执行差分操作后,生成的网格如下所示:this

在上图中,如果你看到切面,只有 5 个三角形,并且许多边是开放的。顶面上存在的三角形也会变形。

有没有其他API可以得到完全封闭的曲面,并且在差分运算后还保留三角形的对称性?

初始3D形状的点和面如下:

    Points : [3143.0,643.8,-3391.5,2843.1,643.8,-3391.0,3143.0,-643.8,-3391.5,2000.0,-227.0,-3367.2,2000.0,227.0,-3367.2,2000.0,559.9,-3367.2,2000.0,-559.9,-3367.2,2843.1,-643.8,-3391.0,3143.0,0.0,-3391.5,2264.4,586.2,-3378.7,2273.1,-587.1,-3379.0,3143.0,378.2,-3391.5,2560.1,-615.6,-3387.1,3143.0,-381.1,-3391.5,2525.3,612.2,-3386.4,2433.3,28.1,-3384.3,2788.8,84.0,-3390.5,2670.6,347.8,-3389.0,2751.3,-352.0,-3390.1,2312.6,-300.8,-3380.4,2373.0,329.8,-3382.4,2000.0,559.9,-3000.0,3205.0,650.0,-3000.0,2905.0,650.0,-3000.0,2276.6,587.4,-3000.0,2560.3,615.7,-3000.0,2000.0,-559.9,-3000.0,3205.0,-650.0,-3000.0,2905.0,-650.0,-3000.0,2298.6,-589.6,-3000.0,2653.1,-624.9,-3000.0,3205.0,332.5,-3000.0,3205.0,16.6,-3000.0,3205.0,-237.5,-3000.0,2000.0,-227.0,-3000.0,2000.0,227.0,-3000.0,2287.6,104.2,-3000.0,2635.5,238.3,-3000.0,2273.2,-151.8,-3000.0,2650.8,-252.1,-3000.0,2912.7,239.9,-3000.0,2922.2,-23.5,-3000.0,2937.4,-339.6,-3000.0,]
Faces : [6, 0, 26, 0, 3, 0, 26, 0, 34, 0, 3, 0, 5, 0, 4, 0, 21, 0, 21, 0, 4, 0, 35, 0, 4, 0, 3, 0, 34, 0, 35, 0, 4, 0, 34, 0, 35, 0, 36, 0, 21, 0, 38, 0, 36, 0, 34, 0, 38, 0, 34, 0, 26, 0, 39, 0, 36, 0, 38, 0, 40, 0, 31, 0, 37, 0, 31, 0, 23, 0, 37, 0, 31, 0, 22, 0, 23, 0, 31, 0, 40, 0, 32, 0, 32, 0, 40, 0, 41, 0, 39, 0, 37, 0, 36, 0, 39, 0, 41, 0, 37, 0, 37, 0, 41, 0, 40, 0, 39, 0, 32, 0, 41, 0, 39, 0, 33, 0, 32, 0, 28, 0, 42, 0, 39, 0, 28, 0, 27, 0, 42, 0, 28, 0, 39, 0, 30, 0, 39, 0, 42, 0, 33, 0, 38, 0, 29, 0, 39, 0, 39, 0, 29, 0, 30, 0, 29, 0, 38, 0, 26, 0, 34, 0, 36, 0, 35, 0, 25, 0, 37, 0, 23, 0, 24, 0, 21, 0, 36, 0, 24, 0, 37, 0, 25, 0, 24, 0, 36, 0, 37, 0, 33, 0, 42, 0, 27, 0, 8, 0, 31, 0, 32, 0, 11, 0, 31, 0, 8, 0, 13, 0, 32, 0, 33, 0, 8, 0, 32, 0, 13, 0, 27, 0, 2, 0, 33, 0, 33, 0, 2, 0, 13, 0, 31, 0, 0, 0, 22, 0, 11, 0, 0, 0, 31, 0, 12, 0, 7, 0, 28, 0, 29, 0, 10, 0, 12, 0, 30, 0, 29, 0, 12, 0, 30, 0, 12, 0, 28, 0, 28, 0, 2, 0, 27, 0, 28, 0, 7, 0, 2, 0, 29, 0, 6, 0, 10, 0, 26, 0, 6, 0, 29, 0, 9, 0, 21, 0, 24, 0, 22, 0, 0, 0, 23, 0, 24, 0, 14, 0, 9, 0, 25, 0, 14, 0, 24, 0, 1, 0, 14, 0, 25, 0, 1, 0, 25, 0, 23, 0, 9, 0, 5, 0, 21, 0, 0, 0, 1, 0, 23, 0, 5, 0, 9, 0, 4, 0, 15, 0, 4, 0, 9, 0, 15, 0, 9, 0, 20, 0, 9, 0, 17, 0, 20, 0, 10, 0, 6, 0, 3, 0, 3, 0, 15, 0, 19, 0, 15, 0, 16, 0, 18, 0, 10, 0, 19, 0, 18, 0, 16, 0, 11, 0, 8, 0, 17, 0, 1, 0, 11, 0, 1, 0, 9, 0, 14, 0, 1, 0, 16, 0, 9, 0, 1, 0, 17, 0, 16, 0, 7, 0, 13, 0, 2, 0, 7, 0, 18, 0, 13, 0, 19, 0, 10, 0, 3, 0, 15, 0, 3, 0, 4, 0, 17, 0, 15, 0, 20, 0, 8, 0, 18, 0, 16, 0, 17, 0, 9, 0, 16, 0, 17, 0, 16, 0, 15, 0, 13, 0, 18, 0, 8, 0, 15, 0, 18, 0, 19, 0, 12, 0, 18, 0, 7, 0, 12, 0, 10, 0, 18, 0, 15, 0, 16, 0, 17, 0, 15, 0, 17, 0, 16, 0, 1, 0, 0, 0, 11, 0, 16, 0, 17, 0, 11, 0,]

最佳答案

JCSG 有一个扩展库(JCSG-MeshExtensions)可以解决这个问题。它可用于在执行 CSG 操作后优化网格。这是一个链接:https://github.com/miho/JCSG-MeshExtensions

Optimization

关于java - 如何使用 JavaFX、JCSG 和 FXyz 进行差分运算后获得闭合的 3D 网格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37743043/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com