2017-07-03 90 views
1

我正在導入一個3D模型(obj文件)並使用JavaFX三角網格將它添加到場景中。三角網格,無法在JavaFX中添加對象到場景

首先,我讀取obj文件,解析它並將其內容保存到(浮點陣列「頂點」,以及「Faces」的整數數組。我的網格點:[0.0,0.0,0.0,0.0,0.0,1.0 ,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0]和網眼面:[1,0,7,0 ,5,0,1,0,3,0,7,0,1,0,4,0,3,0,......]

然後我將它添加到我的場景中

MeshView cubeMesh = new MeshView(mesh); 
    cubeMesh.setDrawMode(DrawMode.FILL); 
    cubeMesh.setTranslateX(20); 
    cubeMesh.setTranslateY(10); 
    cubeMesh.setTranslateZ(20); 

    displayPane.getChildren().add(cubeMesh); 

不幸的是,沒有被添加到場景中。會有人能夠提出一個解決方案,教程或一本書嗎?

回答