2017-09-02 125 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();