JavaFX embedded in jme3

Hi.

I am not sure what has gone wrong as I had the test working. But after I setup a new test project, and cloned the repo I now get this error:

INFO: Extraction Directory: /home/rob/Projects/jme3_tests/01_3rdParty/JME3-JFX-master
Exception in thread “LWJGL Renderer Thread” java.lang.UnsatisfiedLinkError: Can’t load library: /home/rob/Projects/jme3_tests/01_3rdParty/JME3-JFX-master/liblwjgl.so

I am not sure why it is looking in this location for the .so?

Never Mind. I have build the current jme3 source and added the libs and all is now good.

There is a good chance that your build includes the provided librarys, make sure it’s not the case, they are meant to be provided by the librarys consumer.

Also merged the pull request.

@david.bernard.31 said: I made the pull request. It always need some refactor to fix the issue (sync of raw image between Threads) but it's usage.

Do you plan to work on bridging events from jfx into jme3, or is it not needed for your use cases?

Hi,

Currently, I experiment mapping of jfx input events to final action, eg mouse to change camera location, like I mapped jfx properties to some action, eg slider to set x orientation…

So it’s out of my current need, but it’possible I give it a try to be able to reuse existing jme rules for inputmanager.

I’m trying to implement embedding jfx scenes inside jme3 textures. This would allow embedding interactive huds directly into scene geometry. Display works already, but of course event management is the complicated part.

I was going to cast rays from camera/mouse location onto geometry, get collision results, convert into scene coordinates and process further. Unfortunately, it turns out that CollisionResult doesn’t have texture coordinates of the hit! I have a feeling that even contact normal is not true normal given in geometry, but rather computed one from triangle points.

I suppose that I could compute it somehow, by retrieving triangle data by index from mesh, and then using contact point to interpolate between positions of vertices and use it for interpolation of tex coordinates. Do you think that having

public void getTriangleData(VertexBuffer.Type type, int index, Vector3f v1, Vector3f v2, Vector3f v3)
public void getTriangleData(VertexBuffer.Type type, int index, Vector2f v1, Vector2f v2, Vector2f v3)

in Mesh class would be ok? If yes, I’ll create pull request for that against jme3.

Hm using a ray, then the hit tirangle, then thats uv’s shoud work work

@david.bernard.31 said: I made the pull request. It always need some refactor to fix the issue (sync of raw image between Threads) but it's usage.

I tried to provide :

  • a readable and complete test sample.
  • a wrapper/helper to hide config for common cases, it’s used by the sample, and I’ll use it for my own app.

Hi, I have been trying this out and have it working inside and undecorated stage.

I am getting a null pointer error when I try to close the stage, which I is from the code jme.stop(true);

But the real problem I have is that I cant debug it in eclipse. The app seems to freeze just before displaying the jme scene. Is there some problem with debuggign jme in eclipse that any one knows of?

@robbb said: Hi, I have been trying this out and have it working inside and undecorated stage.

I am getting a null pointer error when I try to close the stage, which I is from the code jme.stop(true);

Can you share the stacktrace of the NPE. I’d got a NPE cause by DebugKeysAppState + settings.setUseInput(false). It’s why I detach this AppState in JmeForImageView.

@robbb said: But the real problem I have is that I cant debug it in eclipse. The app seems to freeze just before displaying the jme scene. Is there some problem with debuggign jme in eclipse that any one knows of?

I just try to breakpoint on eclipse. I can debug but, the mouse doesn’t work when the app is suspended : I can’t use it with eclipse, my tested app or any application.

I just try to breakpoint on eclipse. I can debug but, the mouse doesn't work when the app is suspended : I can't use it with eclipse, my tested app or any application.

It’s ok. The problem was with my knowledge of Java and scope of variables etc…

Hi, I have jme showing in an ImageView as per David’s example, I have the imageview as a child to a javafx Pane object and am resizing the window using this code for resizing the imageview

[java]
//jmeImage.setPreserveRatio(true);
jmePane = (Pane) jmeImage.getParent();
jmePane.heightProperty().addListener(new ChangeListener<Object> () {
@Override
public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) {
jmeImage.setFitHeight((double) newValue);
}
});
jmePane.widthProperty().addListener(new ChangeListener<Object> () {
@Override
public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) {
jmeImage.setFitWidth((double) newValue);
}
});
[/java]

what I am seeing is a lot of flicker when resizing. Is this to be expected or is there some way to get the imageview to some how buffer the image?

Also is there any point in doing jmeImage.setPreserveRatio(true) for use with jme?

cheers,

Hi, when I resize the sampleTestDisplayInImageView , I’ve got flicker with “blank” screen with similar code.
[java]
//To resize image when parent is resize
//image is wrapped into a “VBOX” or “HBOX” to allow resize smaller
//see http://stackoverflow.com/questions/15951284/javafx-image-resizing
Pane p = (Pane)image.getParent();
image.fitHeightProperty().bind(p.heightProperty());
image.fitWidthProperty().bind(p.widthProperty());
[/java]

I’ve got less flicker if I increase the framerate, because resize request are applied at next frame. But the code is buggy, concurrent thread update and can crash with java.lang.IndexOutOfBoundsException. It’s my current manual test case ‘increase framerate + resize’ to test my the thread issue. I’ll try to fix it today and may be, the fix will also hide the flickering.

The setPreserveRatio is ignored, because the size of the image is used to define the dimension of the jme’s viewport.

The setPreserveRatio is ignored, because the size of the image is used to define the dimension of the jme's viewport.

Ok, that makes sense, thanks.

As for the flicker, I am also getting flicker with the entire window. I am using an undecorated stage and providing my own decorations. I am not sure if this is part of the problem or not. But I expect the app (if I go ahead with it) will be used 99% of the time as a maximized window any way.

Cheers,

I just reread the code, when resize there is at least one “blank” frame, due to cancel the current frame from jme (wrong size) + recreate jme 's framebuffer, javafx imagewriter at new size + wait for the frame to be created in jme thread + wait to the frame to be copied in the javafx thread.

@david.bernard.31 said: I just reread the code, when resize there is at least one "blank" frame, due to cancel the current frame from jme (wrong size) + recreate jme 's framebuffer, javafx imagewriter at new size + wait for the frame to be created in jme thread + wait to the frame to be copied in the javafx thread.

I made the stage background black via css (-fx-background-color: black;) and this makes it easier on the eye as the flickering was a white box replaced by the black of the jme scene. I assume that is related to the waiting you mention?

I push a “fix” that reduce ficklering a lot + some API change.

I have no clue if this is of interest but I just saw on the JOGL forums about a port of LWJGL-JavaFX integration to JOGL.
http://forum.jogamp.org/LWJGL-FX-fast-JavaFX-integration-port-to-JOGL-td4032802.html

@jmaasing said: I have no clue if this is of interest but I just saw on the JOGL forums about a port of LWJGL-JavaFX integration to JOGL. http://forum.jogamp.org/LWJGL-FX-fast-JavaFX-integration-port-to-JOGL-td4032802.html

Seems to be most trivial part of the integration - copying and embedding images one direction and another. No support for popups in fullscreen case, no support for event handling/redirection. Most of code seems to be focused on handling differences between Intel/AMD/Nvidia card APIs and doing basic opengl operations, which is fortunately abstracted away by jme3.

It works basically similar to the current system, but it’s missing the integration from my point of view.

Maybe we should send them a link to ours so they can improve it :slight_smile:

Anyway thanks for the find :wink:

annoucement: I share on github a WIP demo/skeleton project where I integrate jme3, javafx, dagger, … packaging.
There is no game, and lot of “todo”, the only “working” page are video/audio settings. But it may help other.

[video]jme3_skel 20140902 - YouTube

Feedbacks welcome.

3 Likes

My project is build with jme 3.1.0-SNAPSHOT where I enabled “gamma correction”. I have to change JME3-JFX to support it. The change used API not available into 3.0.x

As some dev use JME3-JFX with 3.0, I enclosed the change into a try {} catch and fallback to current cod. So both jme’s version should be supported at runtime, but the code can’t compile with 3.0.

So my question, how to manage the dual version into the project ?

  1. having 2 branches (master for 3.0 and jme_3.1 for 3.1 :wink: )
  2. switch jme to a 3.1.0-SNAPSHOT + inserting hack (like I did to support both version at runtime)
  3. others ?