要导入FXML作为场景,然后从FXML使用摄像机

问题描述 投票:0回答:1

我想制作3d对象(使用Blender),并使用Interactive Mesh:Model Browser将它们放在javaFx中。这样就可以得到一个FXML,其中包含我需要的所有信息。我在FXMl中有一个摄像头(基本上来自搅拌机),我希望它使用该摄像头作为MAIN摄像头。

我已经尝试使用查找和getNamespace从fxml加载对象。

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.*;
import javafx.stage.Stage;

import java.io.IOException;


public class main extends Application {
    public static void main(String[] args) {
        launch(args);
    }
    public void start(Stage stage){
        FXMLLoader loader = new FXMLLoader(getClass().getResource("ground.fxml"));
        Group base = new Group();
        PerspectiveCamera camera;
        Parent root=new Parent(){};
        try {
            root = loader.load();
        }catch (IOException e){
            e.printStackTrace();
        }
        base=(Group)root.lookup("#Full3DScene");
        camera= (PerspectiveCamera) base.lookup("#camera");
        Scene scene = new Scene(base,1920,1080);
        stage.setScene(scene);
        scene.setCamera(camera);
        stage.show();
        camera.getId();
    }
}

谢谢!This is a view from the camera using InteractiveMesh:ModelBrowserJFX 0.4.1

FXML看起来像:

<Group fx:id="Full3DScene" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.121" fx:controller="Controller">
  <transforms>
    <Rotate angle="-90.0" pivotX="0.0" pivotY="0.0" pivotZ="0.0">
      <axis>
        <Point3D x="1.0" y="0.0" z="0.0" />
      </axis>
    </Rotate>
  </transforms>
  <children>
    //...all objects for the scene...
    //+
    <PerspectiveCamera fx:id="camera">
    </PerspectiveCamera>
  </children>
</Group>

我做了什么Blender->。dae(Collada)-> InteractiveMesh:模型浏览器-> FXML-> javaFx

java javafx fxml
1个回答
0
投票

我希望拥有我在Blender中甚至从Modelviewer中获得的视角。和您一样,我没有nullExeptions,只是它没有将我放置在应用程序中我想要的位置...

© www.soinside.com 2019 - 2024. All rights reserved.