Christian Schnabl wrote:

The biggest problem is, that i don't know how to use the load(java.io.Reader) in the 
right way. do i have to pass it as a bitstream or object or whatever? nothing worked 
so far or maybe i am to dump. if you could give a short example, that would be really 
great ;-)
thanks,
chris

Here is a snippet from the examples/LoaderDemo.java  in Xj3D.  It uses
the URL method of load.  If you wish to use a Reader then create
something like a FileReader( FileReader fr = new
FileReader("myfile.wrl");) and past that into the load() method.

    /**
     * Load the given file into the scene.
     *
     * @param filename The name of the file or the URL to load
     */
    private void loadFile(String file) {

int flag = VRML97Loader.LOAD_ALL;

        if(staticLoad)
            flag &= ~VRML97Loader.LOAD_BEHAVIOR_NODES;

VRML97Loader loader = new VRML97Loader(flag);

        // if the file is a directory, ignore it
        File f = new File(file);
        if(f.exists() && !f.isFile()) {
            System.out.println("Can't load directories specified");
            System.exit(1);
        }

        URL url = null;
        Scene scene = null;

        try {
            url = new URL(file);
        } catch (MalformedURLException badUrl) {
            // if the location is not a URL, this is what you get
        }

        try {
            if(url != null)
                scene = loader.load(url);
            else
                scene = loader.load(file);
        } catch(Exception e) {
            System.out.println("Exception loading URL:" + e);
            e.printStackTrace();
            System.exit(0);
        }

urlLabel.setText("File " + file);

        if (scene != null) {
            // get the scene group
            sceneGroup = scene.getSceneGroup();
            sceneGroup.setCapability(BranchGroup.ALLOW_DETACH);
            sceneGroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
            sceneGroup.compile();

            // add the scene group  to the scene
            examineGroup.addChild(sceneGroup);

            // now that the scene group is "live" we can inquire the bounds
            setViewpoint();
            setupLighting(scene);
        }
    }


-- Alan Hudson President: Yumetech, Inc. http://www.yumetech.com/ Web3D Open Source Chair http://www.web3d.org/TaskGroups/source/

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to