Domanda

I would like to try to make a web application out of my NetLogo3D simulation.

Since NetLogo3D 5.0.5 doesn't (yet) support making applets, I had the idea to use directly the API and output screenshots out of the simulation by using the "export-view" command.

Here is my code so far:

import org.nlogo.headless.HeadlessWorkspace;

public class main {
  public static void main(String[] argv) {
    System.setProperty("org.nlogo.is3d", "true");
    HeadlessWorkspace workspace = HeadlessWorkspace.newInstance() ;
    try {
      System.out.println("Working Directory = " + System.getProperty("user.dir"));
      workspace.open("MyProject.nlogo3d");
      workspace.command("setup");
      workspace.command("repeat 50 [ go ]") ;
      workspace.command("export-view \"screenshot.jpg\"") ;
      workspace.dispose();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }
}

The simulation is working nicely, agents are moving for 50 ticks then a screenshot is outputted.

The problem is that the screenshot does not capture all the elements: all patches are invisible (even the ones that are normally colored) and agents are draw in 2D shapes (even if they should have a specific 3D shape like "car").

Export-view works nicely from the NetLogo3D GUI, so I can't see why it should not using the API.

Is there something more I can do or is this command just not fully implemented in the Headless API yet?

È stato utile?

Soluzione

The capability you want simply doesn't exist in headless NetLogo 3D.

I don't think we ever even explored how difficult it might be to add. It appears to me from googling “headless JOGL” just now that it would be possible. I think it's extremely unlikely it will happen though, unless it comes in as an open-source contribution, or unless someone offers funding for it.

Perhaps you could solve it by running the NetLogo 3D GUI on a virtual X server. (Note that I don't actually know if Xfvb and JOGL play well together, but it seems plausible that they might.)

Or, you might consider generating your 3D visualizations using this instead: https://github.com/fstonedahl/RayTracing-Extension , in conjunction with POV-Ray.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top