JavaFX 2D在3D空间中塑造 [英] JavaFX 2D shapes in 3D space

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

问题描述

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

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 s发生。有些用于区域,有些用于线路。在这两种情况下,这些形状必须进行三角测量,以便用 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.

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

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

推荐答案

如果问题是我应该在3D空间中使用2D形状对象吗?在JavaFX中,答案是否定的,因为您将获得所有可怕的性能。然而,听起来您正在尝试弥补JavaFX缺少使用2D对象并在3D空间中旋转它们的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

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

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