JavaFX 3D 对象的并、交、差 [英] Union, intersection and difference between JavaFX 3D objects

查看:28
本文介绍了JavaFX 3D 对象的并、交、差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在 JavaFX 3D 对象之间执行布尔运算,例如并集、交集和差异,例如在 Sphere 实例、Cylinder 实例和 Box 实例之间.

继承自 Shape 类的 JavaFX 2D 对象已经具有 union() 和减法 () 方法http://docs.oracle.com/javase/8/javafx/api/javafx/scene/shape/Shape.html

我想知道在 JavaFX 或 F(X)yz 库中是否有 Shape3D 对象这样的东西.如果没有,我很想知道实施这些操作的最佳方式.

亲切的问候,

解决方案

正如@jdub1581 所说,在 JavaFX 中,没有直接的方法来获得 3D 原始形状的布尔运算.

这并不意味着这些操作无法执行,前提是您知道或提供了网格信息.

虽然 F(X)yz 库有许多复杂的 3D 形状,在完全提供网格信息的情况下,它不会对它们执行布尔运算.

3D 布尔运算是构造实体几何技术的基础.CSG 实体是使用布尔运算(并集、交集、差集)由多个基元(立方体、棱柱体、球体、圆柱体、圆锥体和环面)构建而成的.

此技术有一个基于 Java 的实现,JCSG.来自他的作者 Michael Hoffer:

<块引用>

基于 BSP 的 CSG(构造实体几何)的 Java 实现.这是我所知道的唯一简单且免费的 Java 实现.此实现使用基于 csg.js 的优化 CSG 算法.

基于该实现,JFXScad 是一个基于 JavaFX 的项目,使用 JCSG 来创建准备就绪的复杂形状3D 打印,或导出为 STL/OBJ.

使用此项目,您可以在左侧面板上键入,然后在右侧面板上生成 3D 形状.这是可用的示例之一:

如您所见,多个臂是通过挤压创建的,并使用 uniondifference、...<与 Cylinder 结合/p>

Is there any way to perform Boolean operations like union, intersections and difference between JavaFX 3D objects, let's say for example between a Sphere instance, a Cylinder instance, and a Box instance.

JavaFX 2D objects which inherit from Shape class already have union() and subtract() methods http://docs.oracle.com/javase/8/javafx/api/javafx/scene/shape/Shape.html

I was wondering if there is such a thing for Shape3D objects in JavaFX, or the F(X)yz library. If not I would love to know about the best way to implement these operations.

Kind regards,

解决方案

As @jdub1581 says, in JavaFX there's no straight way to get boolean operations with 3D primitive shapes.

That doesn't mean those operations can't be performed, given you know or you provide the mesh info.

While F(X)yz library has many complex 3D shapes, where the mesh info is fully provided, it doesn't perform boolean operations with them.

3D boolean operations are the basis for the Constructive Solid Geometry technique. A CSG solid is constructed from several primitives (cube, prism, sphere, cylinder, cone and torus) using boolean operations (union, intersection, difference).

There is a Java based implementation of this technique, JCSG. From Michael Hoffer, his author:

Java implementation of BSP based CSG (Constructive Solid Geometry). It is the only simple and free Java implementation I am aware of. This implementation uses an optimized CSG algorithm based on csg.js.

Based on that implementation, JFXScad is a JavaFX based project using JCSG for creating complex shapes ready to be 3D printed, or exported as STL/OBJ.

Using this project, you can type on the left panel and the 3D shape is generated on the right one. This is one of the available samples:

As you can see, several arms are created by extrusion, and combined with Cylinders using union, difference, ...

这篇关于JavaFX 3D 对象的并、交、差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆