Areas
  • J3D FAQ
  • Tutorials
  • Utilities
  • Books
  • News
  • Other Sites
  • FAQ Topics
  • Introduction to Java 3D
  • Documentation
  • Speed issues
  • Running Java 3D
  • Object manipulation
  • Scene appearance
  • Java 3D and Swing
  • Image capturing
  • Stereo viewing
  • Input Devices
  • Textures
  • Web browsers
  • Video Hardware
  • VRML
  •   

    VRML

    1. What's the difference between Java 3D and VRML?

    2. Java 3D-based VRML Browser

    3. Accessing Nodes marked with DEF

    4. Mixing Java3D Nodes and VRML worlds

    Return to the main FAQ page for more questions and answers.

      

    1. What's the difference between Java 3D and VRML?

    Java3D is a low-level programming API for 3D graphics rendering. The code must be compiled to move it to executable form. VRML is a text based modelling language that is interpreted dynamically from the source files.

    Back to top

    2. Java 3D-based VRML Browser

    The VRML Consortium and Sun are working together to implement one. In September 1998 Sun released the source code for unrestricted use. A working group is now developing the code. The official beta 2 release and the working group can be found at

    http://www.vrml.org/WorkingGroups/vrml-java3d/

    Back to top

    3. Accessing Nodes marked with DEF

    If you are using the full Java3D based VRML browser, there is not much you can do about this as you must treat the browser as a black-box standard VRML browser. There is work that allows the integration of the External Authoring Interface into the standard browser in the later releases. You may access DEF names using the getNode() method as per the standard EAI definition.

    Further information on the EAI can be found at the EAI Working Group website at http://www.vrml.org/WorkingGroups/vrml-eai/

    If you only wish to load VRML geometry without the browser, a loader is also available. The getNamedObjects method of the Scene class can be used to extract DEF names from the file in accordance with the VRML scoping rules (no access to Inlined DEFs for example).

    Back to top

    4. Mixing Java3D Nodes and VRML worlds

    If you are using a loader to load the VRML then mixing Java3D and VRML generated nodes is certainly possible. There are many options about how you combine the objects together as the VRML nodes consist of standard javax.media.j3d.SceneGraphObjects allowing them to be placed anywhere within the scenegraph.

    Doug Gehringer (Doug.Gehringer@west.sun.com) from the VRML browser team recommends the following approach:

    The simplest way to do this is to have the VRML content and the new nodes be separate scene graphs. The VRML scene would be one BranchGraph attached to the locale and the new nodes would be other BranchGroups that get added to the locale. This works fine unless you want to make the new nodes be attached to the VRML scene graph.

    For example, if you have VRML scene with a chair in and you want the new node to be a model of a person sitting in the chair. You can make this case work by making the VRML file have an "attachment point" for the new node. The chair could have a Transform node in the right location with DEF name:

    Group { # this holds the chair and the person
        children [
            Shape {...} # this is the chair
            DEF Chair_seat Transform {
                # the new nodes will be children of this node
            }
        }
    }
    

    The VRML loader will make a TransformGroup for the "Chair_seat" Transform node and will store it in the DEF table. After loading the scene, you can get the mount point using the named object table:

      VrmlScene scene =  vrmlLoader.load(url);
      Hashtable defTable = scene.getNamedObjects();
      TransformGroup seat = (TransformGroup) defTable.get("Chair_seat");
    

    Set the capability bits on the chair's TransformGroup to allow children to be added after the scene is made live. Then attach the VRML scene to the locale. When the user hits the button, add the a BranchGroup containing the new nodes to the TransformGroup (remember that only BranchGroups can be added to a live scene graph).

    Back to top

      

    [ Copyright Info ] [ FAQ Home ] [ J3D.org Home ] [ Tutorials ] [ Utilities ] [ Books ] [ Contact Us ]