سؤال

I'm not sure that such plug-ins exist.. But my program displays the data that are easily convertible to VRML or X3D file, so it would be very convenient if I could display rendered by these files figures directly in the window of the program. Anyone can suggest any plugin for Java or any solution to automate this?

هل كانت مفيدة؟

المحلول

If your program generates or reads 3D mesh data (triangles) and is able to create a String object containing a well defined X3D document representing these 3D objects then the Java 3D(TM) API and the XModelImporter API might provide a solution for you.

XModelImporter provides Java 3D importers for "Extensible 3D (X3D)" files. In this case the 'com.interactivemesh.j3d.interchange.ext3d.XModelReader' seems to be the appropriate importer, alternatively 'com.interactivemesh.j3d.interchange.ext3d.XModelLoader'.

The XModelReader imports X3D files by accepting different sources like 'java.io.File' and 'java.net.URL' for external data, but also 'java.io.Reader' which should be applicable for internal stored data, too.

Following not tested scenario might work:

  • write the X3D document into a StringBuilder object
  • create the corresponding String object (StringBuilder.toString)
  • create a java.io.StringReader instance with this X3D string
  • create a XModelReader instance and import the X3D data by calling XModelReader.read(java.io.Reader reader)
  • calling XModelReader.getImport() returns an array of 'javax.media.j3d.Node' which can be rendered with Java 3D

Java 3D https://java3d.java.net/binary-builds.html

XModelReader http://www.java.net/node/706300

I'm not aware of any "currently supported" ready to go VRML or X3D players for Swing or JavaFX. Instead of converting meshes to and back from VRML or X3D you might consider choosing one of the 3D APIs for the Java platform and convert your data directly into the related format.

August

نصائح أخرى

Xj3D is maybe the simplest solution. See http://www.xj3d.org/tutorials/xj3d_application.html or, better, http://www.xj3d.org/tutorials/general_sai.html. At the firs sight Xj3D appears rather difficult to use, but it is not. If you need more help I could send you a little NetBeans project. Ask for more help on this forum and I will try to help you.

A revised and maintained version of the Xj3D library can be found at:

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top