3D 空间中的 JavaFX 2D 形状 [英] JavaFX 2D shapes in 3D space

查看:39
本文介绍了3D 空间中的 JavaFX 2D 形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,如果我旋转一个扩展了 javafx.scene.shape.Shape 的对象,我可以将其转换为 3D 空间,即使它主要设计为 2D(至少据我所知).

I know that if I rotate an object, which extends javafx.scene.shape.Shape, I can transform it into 3D space, even though it was primarily designed to be in 2D (at least as far as I know).

假设我有一个 3D 场景(使用了透视相机和深度缓冲区),其中出现了各种 MeshView.有些用于区域,有些用于线条.在这两种情况下,必须对这些形状进行三角剖分才能使用 TriangleMesh 绘制它们,这通常很重要.

Let's say I have a 3D scene (perspective camera and depth buffer are used), where various MeshViews occur. Some are used for areas, others for lines. In both cases those shapes must be triangulated in order to draw them with a TriangleMesh, which is often nontrivial.

现在,当我将这些线条的绘制更改为使用 Polyline 类时,性能崩溃是可怕的,并且出现了奇怪的伪影.我认为我可以受益于这样一个事实,即折线的顶点较少,而且开发人员不必以编程方式进行三角测量.

Now when I change the drawing of these lines to use the Polyline class, the performance collapse is horrible and there a strange artefacts. I thought I could benefit from the fact, that a polyline has less vertices and the developer doesn't have to triangulate programmatically.

是否不鼓励在 3D 空间内使用扩展 javafx.scene.shape.Shape 的形状?它们是如何在内部绘制的?

Is it discouraged to use shapes extending javafx.scene.shape.Shape within 3D space? How're they drawn internally?

推荐答案

如果问题是我应该在 3D 空间中使用 2D Shape 对象吗?"在 JavaFX 中,答案是否定的,因为您将获得所看到的所有糟糕的性能.但是,听起来您正在尝试使用 2D 对象并在 3D 空间中旋转它们来弥补 JavaFX 缺乏 3D PolyLine 对象的问题.如果这是真的,请改用免费的开源 F(X)yz 库:

If the question is "should I use 2D Shape objects in 3D space?" in JavaFX then the answer is No because you will get all terrible performance that you are seeing. However it sounds like you are trying to make up for JavaFX's lack of a 3D PolyLine object using 2D objects and rotating them in 3D space. If that is true, instead use the free open-source F(X)yz library:

http://birdasaur.github.io/FXyz/

例如 PolyLine3D 类,它允许您简单地指定一个 Point3D 列表,它将为您连接它们:

For example the PolyLine3D class which allows you to simply specify a list of Point3Ds and it will connect them for you:

/src/org/fxyz/shapes/composites/PolyLine3D.java

/src/org/fxyz/shapes/composites/PolyLine3D.java

并且您可以在测试目录中看到有关如何使用它的示例代码:

and you can see example code on how to use it in the test directory:

/src/org/fxyz/tests/PolyLine3DTest.java

/src/org/fxyz/tests/PolyLine3DTest.java

这篇关于3D 空间中的 JavaFX 2D 形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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