JavaFX标记3D轴 [英] JavaFX Label an Axis in 3D

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

问题描述

所以我有这个场景

Axes只是我为表示轴而创建的JavaFX Box。

The Axes are just JavaFX Boxes that I created to represent the axes.

我如何标记轴?我已经尝试过使用JavaFX Label和Text对象,但它们只是以2D显示,但我可能错误地使用它们。是否有某种方法可以标记(例如沿轴排列数字1,2,3,4,5)这些轴是否为3D?

How would I label the axes? I've tried using JavaFX Label and Text objects but they just display in 2D, but I may be using them wrong. Is there some way to label (e.g. put the numbers 1, 2, 3, 4, 5 along the axes) these axes in 3D?

推荐答案

我们在fxyz3d.org中添加了一个浮动标签示例...查看示例:
FloatingLabels.java

We've added a Floating Label example to fxyz3d.org... check out the sample: FloatingLabels.java

要一般管理连接到Point3D的2D标签,您需要执行以下转换:

To generically manage 2D labels connected to a Point3D you need to do a transform along the following:

        Point3D coordinates = node.localToScene(javafx.geometry.Point3D.ZERO);
        SubScene oldSubScene = NodeHelper.getSubScene(node);
        coordinates = SceneUtils.subSceneToScene(oldSubScene, coordinates);
        double x = coordinates.getX();
        double y = coordinates.getY();
        label.getTransforms().setAll(new Translate(x, y));

还有其他一些细节需要担心,比如正确添加到子场景和裁剪但是包含这些细节在示例中。

There are other details you have to worry about like properly adding to the subscene and clipping but those are included in the example.

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

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