2017-09-02 124 views
1

我的目标是在JavaFX中3D场景叠加2D文本作为this image静态2D文本在3D场景中的JavaFX的Java

看到使用子场景是不是一个有效的选择,因为我想要的3D模型,以便能够占据屏幕上的整个空间。

我试着给场景添加一个标签并关闭深度缓冲,但一旦模型旋转(实际摄像机改变位置),正确的定位就会中断。 (使用的代码来控制camera

我可以以某种方式在我的3D场景上叠加一个静态2D GUI,可能是通过使用锚窗格并使用具有透明背景的2D场景?

在堆栈溢出,我只发现了这些问题:
Question No.1
Question No.2
这不符合我的实际需要。

回答

2

我误解了subscenes的概念,因为它们都显示完全分离的控件。覆盖3D文字可以使用以下结构...

  • 根容器(例如锚定窗格)
    • 2D内容(标签)
    • 子场景
      • 立体相机
      • 根3D
        • 3D content

代码例如:

//Add 2D content here 
AnchorPane globalRoot = new AnchorPane(); 
globalRoot.getChildren().add(new Label("Hello World")); 
Scene scene = new Scene(globalRoot, 1024, 768, true); 

SubScene sub = new 
SubScene(root3D,1024,768,false,SceneAntialiasing.BALANCED); 
sub.setCamera(camera); 
globalRoot.getChildren().add(sub); 

//Add all 3D content to the root3D node  

primaryStage.setScene(scene); 
primaryStage.show();