Contributors

VRMLworks

comp.lang.vrml FAQ Answers
4. Building your own worlds

  1. Should I build my VRML world in VRML 1.0 or VRML 97?

    Absolutely. You should definitely build a VRML world. Build lots of them.

    Oh. You wanted to know which of the two to build your world in. A page at the VRMLworks covers the factors that might influence your choice. There is pretty general agreement on comp.lang.vrml that you should not build a new VRML 1.0 world with Live3D extensions, since some VRML 97 browsers don't support them, and most of the new worlds I see out there are built in VRML 97.

  2. What development environment do I need to program in VRML?

    VRML isn't a programming language, it's a scene description language. You can build VRML worlds with nothing more than a plain text editor. The answer to another FAQ goes into more detail.

    But many people don't want to use a text editor and get into the syntax of VRML. And nowadays, at least at the beginning, they don't need to. The answer to another FAQ goes into more detail.

  3. I'm not a programmer. Can I build VRML worlds?

    Yes you can. The answer to another FAQ can give you some good starting places.

  4. What's a good VRML compiler?

    There isn't one. VRML is plain text, and a VRML browser reads that text in and builds a scene according to the instructions it finds in your text file(s).

  5. Are there any programs that will let you look at VRML source code?

    Any plain text editor will let you see VRML source code. If the code appears to be binary, see the answer to another FAQ.

    Some VRML modelers save files in Unix format, which is tough to read in some Windows text editors. Here's a quick way to convert the file that takes advantage of the fact that most Internet Service Providers (ISP) have Unix systems:

    1. Copy the file to your own disk.
    2. Using any FTP program, transfer the file to your directory on your ISP in binary mode.
    3. Change the transfer mode to ASCII and transfer it back to your own computer.

    You can also use Vorlon from Trapezium to save worlds (thanks to Joh Johannsen for this answer):

    vorlon http://www.whereever.com/file.wrl -fetch

    will fetch the URL and

    vorlon file.wrl -import

    will create an ungzipped version of the file and name it "imported".

  6. Is there any way to prevent people from looking at your VRML source code?

    VRML is delivered over the Internet just like HTML, and it has the same security provisions against reading source code that HTML has, which is to say, not much.

    One way to deter casual pilferers who are not very adept is to generate the VRML code dynamically from a CGI script (see the answer to the following FAQ). It may also be possible using Browser.createVrmlFromURL() to load in a file which then disappears, but such tricks can often interfere with people visiting your world over unreliable connections or through firewalls.

    When all is said and done, the real answer is no.

  7. Can you generate VRML dynamically from a CGI script?

    Most Web servers run on Unix systems, and this answer depends on some Unix capabilities. Do readers have similar solutions for NT and other systems?

    The following is a shell script that flies a missile against a bogie that's tooling along on a fixed course. The user enters azimuth and elevation from a form and calls the CGI script. If you don't know how to call a CGI script from a form, there's an introduction to the topic at NCSA.

         #!/bin/sh
         fly_the_missile $WWW_azimuth $WWW_elevation > missile$$.tmp
         turn_it_into_vrml <missile$$.tmp >missile$$.wrl
         echo "Content-type: model/vrml"
         echo "Pragma: no-cache"
         echo
         cat missile$$.wrl
    

    Let's break it down. The first line identifies it as a Bourne shell. In the second line, there's a program called fly_the_missile. It gets its two arguments, $WWW_azimuth and $WWW_elevation, from Un-CGI. You can get Un-CGI from Sunsite. If you're not using Un-CGI, you'll have to use another method to get the azimuth and elevation data from the input stream; this is handled in the CGI tutorial at NCSA.

    Providing the code for fly_the_missile is beyond the scope of the FAQ, but it can be assumed that it outputs a bunch of X, Y and Z values for the missile and the bogie, and perhaps a final line that says whether or not the missile hit the bogie or flamed out.

    The results of the missile flight go into a file that we name missile$$.tmp. The Bourne shell will expand the "$$" into the current PID. That makes sure that two people calling this script at the same time won't run into each other.

    Now we call turn_it_into_vrml. Again, the contents of that program are beyond the scope of the FAQ, but it outputs valid VRML 1.0 or 2.0 code. Note that once again we send the output to a unique file. Doing it stepwise like this takes very little extra time, and is a great help when you're debugging.

    Next, we output the all-important identifier Content-type: model/vrml and a Pragma: no-cache which is a little less important: it makes absolutely sure that when the user runs this a second time, he won't get back the old results.

    Finally, we output the contents of our temporary file holding the VRML code, and we're done, except for the cleanup: you'll need a cron job to kill off your temporary files, or you can replace the temporary files with pipes, or you can delete the temporary files in the same shell script -- but be careful: some varieties of Unix use threading and you can end up deleting the file before you deliver it.

  8. What VRML modeler is best?

    The one you're using is best and everybody already agrees with you. Discussions of what's best are generally less productive than discussions of specific features of browsers that are easy to use or hard to use. Besides, the people who develop those modelers sometimes lurk on the list, and they may take your idea and use it in the next revision.

    The VRML Repository has a list of modelers that can help you get started. Because world building is such a creative process, you'll need to do some research and some trial and error to find the tool that best fits the way you work.

  9. What's the best book on VRML?

    The ones you like best are the best, and everybody already agrees with you. It's far better to talk on the newsgroup about specific things you like and dislike about specific books. It helps if you describe yourself a little (e.g., "I don't remember 3D geometry from high school" or "I'm a C programmer").

    The VRML Repository has a list of books, and the VRMLworks has some criteria for selecting a VRML book and reviews of current books. The reviews are, of course, purely personal opinion.

  10. Can I use models from [program X] in my VRML worlds?

    If program X is a 3D CAD, modeling, or animation tool, chances are that it already exports VRML, and increasingly those programs are exporting VRML 97. For the few that don't, see the answer to the next FAQ.

  11. How do I convert [file type X] to VRML?

    The VRMLworks has a list of converters that can create VRML from lots of file formats. People who read the newsgroup may know of others, so please ask, and if I see the answer, I'll add it to the list.

  12. My [CAD/Animation] package only exports VRML 1.0. How can I use the models from that package?

    Convert the VRML 1 file to VRML 2. See the list of converters at the VRMLworks for where to get a VRML 1 to 2 converter. Note that a very popular free mesh reduction tool Lodestar only works with VRML 1, so you may want to reduce the size of your VRML 1 file before you convert it to VRML 2.

  13. Where can I get models and textures?

    The VRMLworks has a list of models and textures and a model search engine. Make sure you credit your sources, and only take models and textures from public repositories or with the permission of the authors.

  14. Are there any free tutorials on VRML?

    The VRMLworks has a list of tutorials. Short answer: there's gobs. There's no excuse for not learning VRML.

  15. How do I gzip/gunzip a VRML file? Will PKZip work?

    Use the free program gzip. Some of the regular zip programs like WinZip will unzip files, but will only create PKZip format files, which most VRML browsers will not handle properly.

    Because of a bug in some web browsers, it's best to follow the following steps:

    1. Gzip your world. This will turn your file foo.wrl into a file named foo.wrl.gz.
    2. Rename your world to foo.wrl.

    When you want to edit the file again:

    1. Rename your file to foo.wrl.gz
    2. Use gunzip to turn it back into foo.wrl, which will be a text file you can edit.

    A free program for Win9x/NT/2k at the VRMLworks called Win-GZ takes care of both of these operations at once. Put it on your right-mouse menu for VRML files, and you can do it all with two clicks.

  16. Is there a VRML syntax checker?

    There are two excellent VRML syntax checkers: Vorlon from Trapezium and Viper from the National Institute of Standards and Technology (NIST). Both of those syntax checkers do some other useful things as well, so be sure to read the documentation.

    Fully half the questions on comp.lang.vrml would never be asked if people used these syntax checkers.

  17. What's VRMLScript?

    VRMLScript is a historical artifact. Brendan Eich of Netscape Communications Inc. created an object-oriented scripting language called JavaScript that was sort of loosely based on Java. Because it ran in Netscape Navigator's security sandbox, it was ideal for VRML scripting, where security is properly a concern (you are requiring the visitors to your world to run an untrusted application on their machines, after all). But JavaScript had a problem: Netscape owned the language and it wasn't a standard.

    So Chris Marrin and Jim Kent at Silicon Graphics developed VRMLScript, a clean-room implementation of a subset of JavaScript for use with VRML browsers. SGI's Cosmo Player and several other VRML browsers adopted it for scripting.

    VRMLScript was overtaken by events. In 1997 the European Computer Manufacturers Association (ECMA) published the ECMAScript specification which made what Netscape calls "core JavaScript" a standard.

    The people in charge of the VRML spec quickly revised the spec to refer to ECMAScript, which by the way saved them the problem of having to develop the VRMLScript spec to a level where it could be standardized.

    If your browser doesn't support "vrmlscript:" in the url field of a Script node, you can simply substitute "javascript:" and it should work, with one exception: VRMLScript allowed you to continue strings from line to line. ECMAScript doesn't. So if you have:

        Browser.createVrmlFromString('Group { children [
          Shape { appearance
          Appearance {
          material Material { diffuseColor 1 0 0 } }
          Geometry { Sphere } } ] }');
    

    You should replace it with:

        Browser.createVrmlFromString('Group { children [ ' +
          'Shape { appearance ' +
          'Appearance { ' +
          'material Material { diffuseColor 1 0 0 } } ' +
          'Geometry { Sphere } } ] }');


    Note the additional space before the single quote at the end of the line. That prevents the concatenation of the second and third lines from generating "appearanceAppearance".

    Right now there are still some browsers that support only VRMLScript. If you want people with those browsers to be able to visit your world you should have two strings in the url field of your Script node:

        Script {
          ...
    	  url ["javascript:
          ...
          ",
          "vrmlscript:
          "]
        }

    Except for continued strings like we just mentioned and features that are supported in ECMAScript but not in VRMLScript (which don't come up that often in actual practice) you should be able to use identical code for each script.

  18. Which is better, Java or JavaScript/ECMAScript?

    I know of no metrics that say that Java executes faster than ECMAScript, but I believe it does. I would be delighted to replace that sentence with a statement based on validated measurement.

    The plan has always been that ECMAScript is for lightweight applications and Java is for heavy lifting.

    Both languages will probably be required for VRML browsers in the near future. In the meantime, if you want your world to be visible by the largest possible number of visitors you should write your scripts like this:

        Script {
          ...
          url [ "foo.class",
          "javascript:
          ...
          ",
          "vrmlscript:
          ...
          "]
        }

    Remember that the first string in the url field will be tried first, so a different order may be best for you.

    Note too that you can do things in Java that you can't do in ECMAScript and that you can do things in ECMAScript that you can't do in VRMLScript (though the latter case doesn't generally come up). Until the VRML community makes Java and ECMAScript required, you may need to have, for example, a Java script that does something spectacular and an ECMAScript script that does something less spectacular.

  19. Do you know anything about building shared multi-user VRML worlds?

    Nope. But fortunately, lots of other people do. Let's group them by technology.

    If that list doesn't answer your question, you may want an introduction to the topic of shared multi-user worlds like the section on cyberspace at the VRMLworks.


[line]

Did I leave something out on one of these questions that you need to know? Let me know.

-- Bob Crispen
-- Friday, March 10, 2000