Using Java 3D scene tree in a headless environment?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using Java 3D scene tree in a headless environment?

Manu
Hi,

In the current version, Java 3D classes can't be used in a headless environment. If that sounds logical at first, there are some cases where I find this limitation too restrictive. The need of a graphics card is required only to show the scene tree in a Canvas3D instance, isn't it?
But what about managing the scene tree in memory without showing at screen? In the case of Sweet Home 3D for example, all 3D objects managed by the application are Java 3D scene graph objects, whether they are read with loaders or created directly from computed geometries. When I pass these Java 3D objects to save them at OBJ format (with OBJWriter class) or render them with SunFlow engine (with PhotoRenderer class), there's no need of JOGL. But at this moment, I simply can't run the program in a headless environment because VirtualUniverse class checks at initialization time if the program runs in an headless environment, and VirtualUniverse class is referenced by all ...Retained classes associated to scene graph objects.
Couldn't the loading of libraries made by VirtualUniverse initializer be done somewhere else? Or are there some limitations I just forgot?

Thanks for your help.
Emmanuel Puybaret
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Java 3D scene tree in a headless environment?

hharrison
It boils down to Java3d relying on AWT for some of its lifetime...which doesn't work so well in a headless environment.

Getting rid of the AWT dependency would have a lot of benefits, which at this point is writing a replacement for Canvas3D
that is not an AWT object.  I could see Java3D working without the AWT dependency, but it would take quite a bit of work.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Java 3D scene tree in a headless environment?

mmcrosb
In reply to this post by Manu
did you tried to work with BranchGroup or Locale, alone, as rootgroup?
without universe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Java 3D scene tree in a headless environment?

gouessej
Administrator
At the end, you still need a canvas, it doesn't solve this problem.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Java 3D scene tree in a headless environment?

Manu
I found a solution for this issue : when you set "j3d.rend" System property to "noop", the 3D pipeline is handled by the javax.media.j3d.NoopPipeline class which is implemented to do nothing. Just what I needed, except... on a headless computer where a test in javax.media.j3d.VirtualUniverse class was added to avoid some bad error messages when you try to do some real 3D in an headless environment.
To circumvent this issue, you just have to replace the following lines in VirtualUniverse.java:
if (java.awt.GraphicsEnvironment.isHeadless()) {
  throw new java.awt.HeadlessException();
}
by:
if (!"noop".equals(System.getProperty("j3d.rend")) 
    && java.awt.GraphicsEnvironment.isHeadless()) {
  throw new java.awt.HeadlessException();
}
Emmanuel Puybaret
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Java 3D scene tree in a headless environment?

gouessej
Administrator
Hi

Thank you Emmanuel! Would you like to make a pull request against my branch?
Julien Gouesse | Personal blog | Website
Loading...