Hi Rick,
Yes, I am using VrmlLoader, sorry about that. And yes load(
"Models/"+filename) works if I
"hardwire it", however the relative path ("Models/") is not available from the
FileDialog, I guess it is possible
extract the relative path from the absolute path returned from
FileDialog.getDirectory() by comparing it to the
working directory path, but VrmlLoader or more likely it's superclass is not
functioning as advertised. I did
note that when "basepath" is set via VrmlLoader.setBasePath(), that path is
APPENDED to the working directory
in looking for textures when parsing theVRML file, this gives a bogus path name
like:
D:\blah-blah\D:\blah-blah\Models\texture.jpg
All would be simpler if the loader would except an absolute pathname, or
FileDialog returned the
relative path.
-Gary
Rick Goldberg <[EMAIL PROTECTED]> on 01/28/99 02:41:47 PM
To: Gary Moss/arl@arl, [EMAIL PROTECTED], [EMAIL PROTECTED]
cc:
Subject: Re: [java3d] Loading files via the vrml-java3d VRML97 loader
Gary,
I take it you mean "com.sun.j3d.loaders.vrml97.VrmlLoader.load()" and not
"com.sun.j3d.loaders.vrml97.load()". If this is the case, did you try
load("Models/"+fileName);
?
Rick
>Hello,
>
> I guess this question crosses both forums. I am using the vrml-java3d
>Working Group's loader and am having trouble with
> com.sun.j3d.loaders.vrml97.load(String pathname). It
>works fine if I give it a relative path name to the file. However, I am
using
>the
>java.awt.FileDialog to grab files from a subdirectory called "Models".
>I use Filedialog.getFile() which returns the file itself, without the
"Models/"
>in
>front of it. I pass this to load() which tries to be helpful and prepends
the
>path
>name of my working directory (up to but not including "Models/"). So, I get:
>
> D:\blah-blah-blah\file.wrl
>
>instead of
>
> D:\blah-blah-blah\Models\file.wrl
>
> I tried setting basepath by calling
> com.sun.j3d.loaders.Loader.setBasePath() with the
>name of the directory (including "Models/") returned from
>FileDialog.getDirectory(), but the load() method appears
>to ignore it even though getBasePath() reflects the
>desired basepath! If I give it the absolute path to the
>file, it insists on prepending the basepath anyway. The
>source code supplied with the VRML97 loader
>(stamped "VrmlLoader.java 1.13 98/11/05 20:33:08")
>appears to apply basepath correctly...
>
>
> private void LoadFile( String basepath, String geomfile )
> {
> try
> {
> // Load a geometry file.
> VrmlLoader modelLoader = new VrmlLoader();
> System.out.println( "Basepath="
> + modelLoader.getBasePath() ); // prints "Basepath=null"
> System.out.println( "Loading \"" + basepath
> + geomfile + " ..." ); // looks correct
> modelLoader.setBasePath( basepath );
> System.out.println( "Basepath="
> + modelLoader.getBasePath() ); // looks correct
> Scene scene = modelLoader.load( geomfile ); // uses wrong basepath
> System.out.println( "File loaded." );
> if( scene != null )
> {
> BranchGroup sceneGroup = scene.getSceneGroup();
> modelTransformGroup.addChild( sceneGroup );
> }
> }
> catch( FileNotFoundException e )
> {
> System.out.println( geomfile + ": " + e.getMessage() );
> }
>
>
> I am using VRML97 BETA2 "REV C" on NT 4.0 SP4 w/
>jdk1.2 and j3d1.1.
>
>Wa hoppin? Thanks,
>-Gary
>
>
>=====================================================================
>To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
>Java 3D Home Page: http://java.sun.com/products/java-media/3D/
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/