Ben Moxon wrote:

Afternoon all,

I'm wondering if anyone can shed any light on why I can't load a really simple .wrl file in using a VRML97Loader. I'm not really very up on VRML and it's relationship with Java3D, so I am quite possibly being entirely lame here, but the code I have is like this:


VRML97Loader l = new VRML97Loader( VRML97Loader.LOAD_ALL);


            try
            {
                FileReader f = new FileReader(fileName);

                    Scene s = l.load(f);
                BranchGroup b = s.getSceneGroup();
                Shape3D v = (Shape3D) b.getChild(0);
                this.setGeometry(v.getGeometry());
            }
            catch (FileNotFoundException e) {

// and so on.

The problem I get is that when I try to load it I get a nullPointerException from the l.load(f) method that looks a bit like this:

java.lang.NullPointerException
        at org.web3d.j3d.loaders.BaseLoader.load(BaseLoader.java:196)

Can anyone who has dealt with this before let me know what I'm doing wrong?

If I hand it the filename directly I get this:

org.ietf.uri.UnsupportedServiceException: file is not supported
        at org.ietf.uri.URL.getResource(URL.java:472)
        at org.web3d.vrml.sav.InputSource.getCharacterStream(InputSource.java:158)

Any suggestions?

-ben

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".
Its dieing on a getBaseUrl() call.  We need to know the baseUrl path for
a Reader.  So before calling load you can call setBaseUrl on the loader
and it should work.  Or you can use the following code snippet that
doesn't use a Reader.

        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);
        }

--
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