Hello Rick,

At 13:49 28.07.00 -0700, you wrote:
>In the said vrml/x3d package there is
>  com.sun.j3d.loaders.vrml97.impl.Background
>object that does the vrml-j3d translatiom.

Thanks again for setting me straight on the xj3d stuff. It's not included
in the Java3D
bundle from Sun, nor can it be found on the Sun Web Site (or can it?) I
downloaded
it from http://www.web3d.org/TaskGroups/x3d/sun/cvs.html and took it for a
spin.
It managed to solve my problem of producing a gradiented sky (and ground)
without
needing to hand-craft the Geometry for it. For the benefit of other
desparate souls
in search of a sky with gradients, and to invite comments or suggestions,
I'm going
to post my background maker here.

Like the rest of Sun's Java offering, xj3d is a gift horse and I don't want
to complain
too loudly. But I have two problems with it I'd like to mention:

(1) My VRML is tiny, so I load it from a String using a StringReader. The
VrmlLoader
seems to prefer real files, because it throws a "MalformedURLException: No
protocol"
when I instantiate it with a StringReader. One workaround is to
'setURL("file://.")', but
it is a bit bothersome.

(2) If I use VrmlLoader in my program, then it throws an
EXCEPTION_ACCESS_VIOLATION.
I've seen this with some of the example programs; maybe it's a function of
how complex
the scene is?

Anyway, here's the code:

===========
   private Background makeBackground() {
     String bgString =
       "#VRML V2.0 utf8\n" +
         "Background {" +
                 "skyColor [ 0.0 0.2 0.7,  0.0 0.5 1.0,  1.0 1.0 1.0 ]" +
                 "skyAngle [ 1.309, 1.571 ]" +
                 "groundColor [ 0.1 0.1 0.0,  0.4 0.25 0.2,  0.6 0.6 0.6 ]" +
                 "groundAngle [ 1.309, 1.571 ]" +
         "}";

     Background bg = null;
     VrmlLoader ldr = new VrmlLoader(VrmlLoader.LOAD_BACKGROUND_NODES);
     Scene s;
     Background[] bgn;
     try {
       ldr.setBaseUrl(new java.net.URL("file://.")); // avoid
MalformedUrlException
       s = ldr.load(new StringReader(bgString));
       bgn = s.getBackgroundNodes();
       if ((bgn != null) && (bgn.length > 0)) {
         bg = (Background) bgn[0].cloneNode(false);
       }
     }
     catch (IOException e) {
       e.printStackTrace();
     }
     finally {
       ldr = null;
       s = null;
       bgn = null;
     }
     return bg;
   }
===========

Re's,

-Carl-

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