JavaFx and processing 3 P3D

Hello all,
I am working on a javafx project in which I want to use P3D to display several 3D objects.
I succeeded to make the example given by micycle here running but it is 2D and uses FX2D.

So I have two questions:

  • Is there a way to use P3D inside a javafx GUI like micycle did for FX2D ?
  • Is there a way to launch a Processing 3 process which does the 3D display and exchanges data with the javafx App ?


Regarding your first question, there’s no easy solution since each mode uses a different backend render and there’s little-to-no interoperability between the two (FX2D draws into javafx.scene.canvas.GraphicsContext; P3D uses JOGL).

With your second question, I understand it to mean using a JavaFX application (not necessarily a Processing sketch) to launch a P3D sketch. This is fully possible. In fact it’s possible to use a FX2D sketch to launch a P3D sketch.

Thank you for your answer.

About the second point, if I launch the P3D sketch (let’s call it the display) from either a JavaFX application or a FX2D sketch (let’s call it the mainApp), would I be able to share data from the dispaly to the mainApp and vis versa ?

My case is the following:
I have an accelerometer on the “hand” of a robotic arm.
The data from the accelerometer are sent to my laptop. A javaFX application (mainApp) get them.
I do some treatments on the data and I get an Array of Data (an object which contains several information).
I would like to send this Array Data to display in real time the moving arm with a P3D sktech. I have already done some 3D inverse kinectic on a sketch with P3D. Using the calculation of the 3D inverse kinectic sketch, I need it to send the coordinates of each parts of the arm to the mainApp.

I will try by writing and reading files, but it will be probably too heavy to have a proper display.

Create a class for each app.

Launch one from the other (i.e. the 3D sketch from the JavaFX main app).

P3DSketch sketch2

public void setup() {
	sketch2 = new P3DSketch();
	PApplet.runSketch(new String[] {}, sketch2);

Then you can set/refer to variables of the class.

sketch2.arrayData = .....

It works when I am using only Processing.
But when I use my javafx app, since the core.jar of processing is different for the integration inside javafx, it crashes.
Any idea of how I could workaround this ?

Did you try restarting?

On my desktop app PoShowTube I did get this working but not from inside the JavaFX window, I ended up with 2 windows. One for the JavaFX controls and one for the normal processing window, not ideal but it works for me. If you look on the user guide on PoShowTube website you get the idea of what I ended up with.

In hindsight, if I started again from scratch I think I probably would have dived into OpenGL directly which is obviously far more difficult to master but probably better suited to one window with lots of controls.