[ Pobierz całość w formacie PDF ]
.If you haven't convinced your Web site administrator to add the VRML MIME type to your Web server yet, you can set up a simple CGI script that starts out with the following line (in Perl).print “Content-type: x-world/x-vrml\n\n”;Or, for a Java server-side CGI:System.out.println(“Content-type: x-world/x-vrml”);System.out.println(“”);After that, you can have the code print-out the rest of your VRML world.As we saw above, a VRML world starts off with the following first line:#VRML V1.0 asciiAnything after a # in a line of a VRML script is considered a comment.For transmission purposes, comments can be stripped out of a VRML file before it is transmitted across a network.If you want anything like a copyright or other information to get to the viewer, you should use an INFO node.However, at the current time, none of the HTTP servers have been configured to strip the comments out, so you can be a bit sloppy in the near future!Each VRML world consists of one node.Typically, that one node will be a Separator node that includes a grouping of various nodes inside it.Nodes can represent shapes like cubes and cones, properties like colors and textures, or groupings.Nodes can also give World Wide Web references, such as hyperlinks or in-line worlds, similar to HREFs and in-line graphics in HTML (shouldn't we call them in-space worlds?).As an example, the Material node is a property node that lets you assign colors and transparency properties.For a detailed description of VRML nodes, refer to the VRML Specification at.A VRML-enabled HTML version of the Specification is at.Let's start by making a simple VRML home world from scratch by hand to illustrate how the language works.Figure 34.7 shows what it will look like in a VRML browser when we're done.FIGURE 34.7.A simple, hand-created VRML world.We start off with the VRML header and a Separator node to hold the nodes we soon will add.(See Listing 34.2.)lListing 34.2.A basic VRML file.l#VRML V1.0 asciiSeparator {}This is a valid VRML file.It will load into your VRML browser, but you won't see anything.Let's add a blue sphere.(See Listing 34.3.) We'll use a Material node to set the color to a blue, and then add a Sphere node with a radius of five meters.lListing 34.3.A blue sphere in VRML.l#VRML V1.0 asciiSeparator { # blue sphere Material { diffuseColor 0 0.7 } # sets the color to blue Sphere { radius 5 } # creates the sphere with radius 5 meters}Now that we have something showing up in the browser, let's add something with more visual depth to it.Find an image file on your computer or on the Web.Your VRML browser should support JPEG, GIF, and maybe BMP formats.Let's add a cube that uses the image as a texture.We'll locate it seven meters to the right (positive x axis) of the blue sphere by adding in a Translation node.(See Listing 34.4.)lListing 34.4.A blue sphere and a texture-mapped cube.l#VRML V1.0 asciiSeparator { # blue sphere Material { diffuseColor 0 0.7 } # sets the color to blue Sphere { radius 5 } # creates the sphere with radius 5 meters # textured cube Translation { translation 7 0 0 } # moves away from the sphere Texture2 { filename “image.jpg” } # sets the texture to image.jpg Cube { } # creates the cube}In Listing 34.4, image.jpg is the URL or filename of your image file.Now your home world is starting to get somewhere.As the final touch, let's add the VRML you created using Aereal Phonts.We do this using the WWWInline node and the URL for the VRML world you created with Aereal Phonts.We'll also use another Translation node to move from the center of the cube to the area above and between the sphere and cube.The world now becomes Listing 34.5.lListing 34.5.The blue sphere and texture-mapped cube plus the letters vr in VRML as a WWWInline.l#VRML V1.0 asciiSeparator { # blue sphere Material { diffuseColor 0 0.7 } # sets the color to blue Sphere { radius 5 } # creates the sphere with radius 5 meters # textured cube Translation { translation 7 0 0 } # moves away from the sphere Texture2 { filename “image.jpg” } # sets the texture to image.jpg Cube { } # creates the cube # WWWInline the Aereal Phonts world Translation { translation -3.5 6 0 } # move above the sphere & cube WWWInline { # render the following VRML world inside this world name “” }}Just replace the name URL in the WWWInline node with the URL of your Aereal Phonts world and your simple VRML home world is ready.As you can see in this example, WWWInline is a very powerful feature that taps into the power of the World Wide Web as a whole and differentiates VRML from non-Web attempts at VR.Authoring Tools and ConvertersThere are a variety of tools becoming available to ease VRML world development.Trying to create VRML worlds by hand in a text editor can take quite a while and give you a headache as you try to spatially imagine your world.There are two categories of tools: authoring tools and converters.Authoring tools are software packages that let you create worlds described in VRML.The HTML equivalent is software programs such as HoTMetaL and HTML Assistant.Hopefully, VRML authoring tools will let you develop and test your worlds in 3D.Most VRML authoring tools are still in very preliminary versions, though you can expect to see an explosion of these tools in the near future.Some that have been announced include Virtual Home Builder from Paragraph, Fountain from Caligari, EZ3D from Radiance, and Aereal Phonts from Aereal.For the latest authoring tool information, the best bet is to check the VRML repository Web sites.Converters let you create a world using CAD or 3D modeling software and then translate a file from the 3D file format into the VRML format.Converters exist, or are being developed, for formats like DXF, 3DS, OFF, and IV.There are also commercial converter programs such as Interchange from Syndesis that convert between several 3D file formats and support—or are planning to support—VRML.There's a problem with converters: they tend to generate huge, inefficient VRML files [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • trzylatki.xlx.pl