use of com.jme3x.jfx.injfx.JmeToJFXApplication in project TeachingInSimulation by ScOrPiOzzy.
the class TestJmeToJFXCanvas method makeJmeApplication.
@NotNull
private static JmeToJFXApplication makeJmeApplication() {
final AppSettings settings = JmeToJFXIntegrator.prepareSettings(new AppSettings(true), 60);
final JmeToJFXApplication application = new JmeToJFXApplication() {
protected Geometry player;
Boolean isRunning = true;
@Override
public void simpleInitApp() {
super.simpleInitApp();
flyCam.setDragToRotate(true);
Box b = new Box(1, 1, 1);
player = new Geometry("Player", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
player.setMaterial(mat);
rootNode.attachChild(player);
// 添加鼠标监听
inputManager.addMapping("pick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener((ActionListener) (name, isPressed, tpf) -> {
if (isPressed) {
System.out.println(inputManager.getCursorPosition());
System.out.println(settings.getWidth());
System.out.println(settings.getHeight());
// @Nullable
// Geometry picked = JmeUtil.getGeometryFromCursor(root, cam, inputManager);
// if (picked != null) {
// System.err.println(picked);
// }
@Nullable Vector3f point = JmeUtil.getContactPointFromCursor(rootNode, cam, inputManager);
if (point != null) {
Geometry ball = JmeUtil.getSphere(assetManager, 32, 0.1f, ColorRGBA.Red);
rootNode.attachChild(ball);
ball.setLocalTranslation(point);
}
}
}, "pick");
// initKeys(); // load my custom keybinding
}
};
application.setSettings(settings);
application.setShowSettings(false);
return application;
}
use of com.jme3x.jfx.injfx.JmeToJFXApplication in project TeachingInSimulation by ScOrPiOzzy.
the class TestJmeToJFXImageView method makeJmeApplication.
@NotNull
private static JmeToJFXApplication makeJmeApplication() {
final AppSettings settings = JmeToJFXIntegrator.prepareSettings(new AppSettings(true), 60);
final JmeToJFXApplication application = new JmeToJFXApplication() {
protected Spatial player;
@Override
public void simpleInitApp() {
super.simpleInitApp();
// stateManager.attach(new SceneCameraState());
float aspect = (float) cam.getWidth() / cam.getHeight();
// flyCam.setDragToRotate(true);
cam.setFrustumPerspective(45f, aspect, 0.01f, 1000);
assetManager.registerLocator("E:\\JME_SDKPROJ_HOME\\robot_assets\\assets\\", FileLocator.class);
assetManager.registerLocator("http://192.168.1.19:8082/assets/", UrlLocator.class);
player = assetManager.loadModel("Models\\elecComp\\DZ47LEC32.j3o");
// player = assetManager.loadModel("Model/RT28N-32X/RT28N-32X.j3o");
// Box b = new Box(1, 1, 1);
// player = new Geometry("Player", b);
// Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
// mat.setColor("Color", ColorRGBA.Blue);
// player.setMaterial(mat);
rootNode.attachChild(player);
}
};
application.setSettings(settings);
application.setShowSettings(false);
return application;
}
use of com.jme3x.jfx.injfx.JmeToJFXApplication in project TeachingInSimulation by ScOrPiOzzy.
the class TestJmeToJFXImageView method start.
@Override
public void start(@NotNull final Stage stage) {
final ImageView imageView = new ImageView();
imageView.setFocusTraversable(true);
imageView.setOnMouseClicked(event -> imageView.requestFocus());
final StackPane stackPane = new StackPane(imageView);
final Scene scene = new Scene(stackPane, 600, 600);
imageView.fitWidthProperty().bind(stackPane.widthProperty());
imageView.fitHeightProperty().bind(stackPane.heightProperty());
stage.setTitle("Test");
stage.setScene(scene);
stage.show();
stage.setOnCloseRequest(event -> System.exit(0));
// creates jME application
final JmeToJFXApplication application = makeJmeApplication();
// integrate jME application with ImageView
JmeToJFXIntegrator.startAndBindMainViewPort(application, imageView, Thread::new);
}
use of com.jme3x.jfx.injfx.JmeToJFXApplication in project TeachingInSimulation by ScOrPiOzzy.
the class TestJmeToJFXCanvas method start.
@Override
public void start(@NotNull final Stage stage) {
final Canvas canvas = new Canvas();
canvas.getProperties().put(JFXMouseInput.PROP_USE_LOCAL_COORDS, true);
canvas.setFocusTraversable(true);
canvas.setOnMouseClicked(event -> canvas.requestFocus());
final Button button = new Button("BUTTON");
final StackPane stackPane = new StackPane(canvas, button);
final Scene scene = new Scene(stackPane, 600, 600);
canvas.widthProperty().bind(stackPane.widthProperty());
canvas.heightProperty().bind(stackPane.heightProperty());
stage.setTitle("Test");
stage.setScene(scene);
stage.show();
stage.setOnCloseRequest(event -> System.exit(0));
// creates jME application
final JmeToJFXApplication application = makeJmeApplication();
// integrate jME application with Canvas
JmeToJFXIntegrator.startAndBindMainViewPort(application, canvas, Thread::new);
}
Aggregations