java - 想将 FXML 导入为场景,然后使用 FXML 中的相机
问题描述
我想制作 3d 对象(使用搅拌器)并使用交互式网格:模型浏览器将它们放入 javaFx 中。这会生成一个包含我需要的所有信息的 FXML。我在那个 FXMl 中有一个摄像头(基本上来自搅拌机),我希望它使用那个摄像头作为主摄像头。
我尝试使用查找和 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();
}
}
提前致谢! 这是使用 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:Model Browser->FXML->javaFx
解决方案
推荐阅读
- rust - 使用带有字符串 url 的 std::net::UdpSocket
- jsx - After Effects 从 JSX 更改表达式变量
- vue.js - vue 2 @click 处理程序未按预期工作
- shell - 为多个输入参数文件调用 jar 的 Cron 作业
- php - Composer 使用 OR 运算符更新包到特定版本
- c# - 如何从带有连接表的数据库动态创建 WPF 窗口?
- sql-server - 在一个数据库中检查约束失败
- java - 当我传递 URI 时,音乐文件可以正常工作,但是当我传递字符串路径时它不起作用。为什么?
- python - 如何使用Python在多个进程中运行pycuda
- android - 如何在通过 Apply{} 启动处理程序及其可运行对象时停止它