Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Virtual Reality Modeling Language (VRML)

VRML History

The Virtual Reality Modeling Language (VRML) is the language you use to display three-dimensional objects with a VRML viewer.

Since people started to publish their documents on the World Wide Web (WWW), there has been an effort to enhance the content of Web pages with advanced three-dimensional graphics and interaction with those graphics.

The term Virtual Reality Markup Language (VRML) was first used by Tim Berners-Lee at a European Web conference in 1994 when he talked about a need for a 3-D Web standard. Soon afterward, an active group of artists and engineers formed around a mailing list called www-vrml. They changed the name of the standard to Virtual Reality Modeling Language to emphasize the role of graphics. The result of their effort was to produce the VRML 1 specification. As a basis for this specification, they used a subset of the Inventor file format from Silicon Graphics.

The VRML 1 standard was implemented in several VRML browsers, but it allowed you to create only static virtual worlds. This limitation reduced the possibility of its widespread use. Quickly it became clear that the language needed a robust extension to add animation and interactivity, and bring life to a virtual world. The VRML 2 standard was developed, and in the year 1997 it was adopted as International Standard ISO/IEC 14772-1:1997. Since then it is referred to as VRML97.

VRML97 represents an open and flexible platform for creating interactive three-dimensional scenes (virtual worlds). As computers improve in computational power and graphic capability, and communication lines become faster, the use of 3-D graphics becomes more popular outside the traditional domain of art and games. There are now a number of VRML97-enabled browsers available on several platforms. Also, there are an increasing number of VRML authoring tools from which to choose. In addition, many traditional graphical software packages (CAD, visual art, and so on) offer VRML97 import/export features.

The Simulink® 3D Animation™ product uses VRML97 technology to deliver a unique, open 3-D visualization solution for MATLAB® users. It is a useful contribution to a wide use of VRML97 in the field of technical and scientific computation and interactive 3-D animation.

The VRML97 standard continues to be improved by the Web 3D Consortium. The newly released X3D (eXtensible 3D) standard is the successor to VRML97. X3D is an extensible standard that provides compatibility with existing VRML content and browsers. For more information, see http://www.web3d.org and http://www.web3d.org/x3d/specifications/vrml/ISO-IEC-14772-VRML97/.

VRML Support

The Virtual Reality Modeling Language (VRML) is an ISO standard that is open, text-based, and uses a WWW-oriented format. You use VRML to define a virtual world that you can display with a VRML viewer and connect to a Simulink model.

The Simulink 3D Animation software uses many of the advanced features defined in the current VRML97 specification. The term VRML, in this guide, always refers to VRML as defined in the VRML97 standard ISO/IEC 14772-1:1997, available from http://www.web3d.org/x3d/specifications/vrml/ISO-IEC-14772-VRML97/. This format includes a description of 3-D scenes, sounds, internal actions, and WWW anchors.

The software analyzes the structure of the virtual world, determines what signals are available, and makes them available from the MATLAB and Simulink environment.

Simulink 3D Animation software ensures that the changes made to a virtual world are reflected in the MATLAB and Simulink interfaces. If you change the viewpoint in your virtual world, this change occurs in the vrworld object properties in MATLAB and Simulink interfaces.

The software includes functions for retrieving and changing virtual world properties.

    Note:   Since some VRML worlds are automatically generated in VRML1.0, and the Simulink 3D Animation product does not support VRML1.0, you need to save these worlds in the current standard for VRML, VRML97.

    For PC platforms, you can convert VRML1.0 worlds to VRML97 worlds by opening the worlds in Ligos® V-Realm Builder and saving them. V-Realm Builder is shipped with the PC version of the software. Other commercially available software programs can also perform the VRML1.0 to VRML97 conversion.

VRML Compatibility

The Simulink 3D Animation product currently supports most features of VRML97, with the following limitations:

  • The Simulink 3D Animation server ignores the VRML Script node, but it passes the node to the VRML Viewer. This allows you to run VRML scripts on the viewer side. You cannot run them on the Simulink 3D Animation server.

  • The Simulink 3D Animation Viewer does not support the Sound node. (The Blaxxun Contact® viewer does.)

  • In keeping with the VRML97 specification, the Simulink 3D Animation Viewer ignores BMP files. As a result, VRML scene textures might not display properly in the Simulink 3D Animation Viewer. To properly display scene textures, replace all BMP texture files in a VRML scene with PNG, JPG, or GIF equivalents. Note that Blaxxun Contact supports BMP files in addition to the standard VRML texture file formats.

For a complete list of VRML97 nodes, refer to the VRML97 specification.

VRML Coordinate System

The VRML coordinate system is different from the MATLAB and Aerospace Blockset™ coordinate systems. VRML uses the world coordinate system in which the y-axis points upward and the z-axis places objects nearer or farther from the front of the screen. It is important to realize this fact in situations involving the interaction of these different coordinate systems. SimMechanics™ uses the same coordinate system as VRML.

Rotation angles — In VRML, rotation angles are defined using the right-hand rule. Imagine your right hand holding an axis while your thumb points in the direction of the axis toward its positive end. Your four remaining fingers point in a counterclockwise direction. This counterclockwise direction is the positive rotation angle of an object moving around that axis.

Child objects — In the hierarchical structure of a VRML file, the position and orientation of child objects are specified relative to the parent object. The parent object has its local coordinate space defined by its own position and orientation. Moving the parent object also moves the child objects relative to the parent object.

Measurement units — All lengths and distances are measured in meters, and all angles are measured in radians.

VRML File Format

You need not have any substantial knowledge of the VRML format to use the VRML authoring tools to create virtual worlds. However, it is useful to have a basic knowledge of VRML scene description. This helps you create virtual worlds more effectively, and gives you a good understanding of how the virtual world elements can be controlled using Simulink 3D Animation software.

This section introduces VRML. For more information, see the VRML97 Reference. This reference is available online at http://www.web3d.org. Many specialized VRML books can help you understand VRML concepts and create your own virtual worlds. For more information about the VRML, refer to an appropriate third-party VRML book.

In VRML, a 3-D scene is described by a hierarchical tree structure of objects (nodes). Every node in the tree represents some functionality of the scene. There are 54 different types of nodes. Some of them are shape nodes (representing real 3-D objects), and some of them are grouping nodes used for holding child nodes. Here are some examples:

  • Box node — Represents a box in a scene.

  • Transform node — Defines position, scale, scale orientation, rotation, translation, and children of its subtree (grouping node).

  • Material node — Corresponds to material in a scene.

  • DirectionalLight node — Represents lighting in a scene.

  • Fog node — Allows you to modify the environment optical properties.

  • ProximitySensor node — Brings interactivity to VRML97. This node generates events when the user enters, exits, and moves within the defined region in space.

Each node contains a list of fields that hold values defining parameters for its function.

Nodes can be placed in the top level of a tree or as children of other nodes in the tree hierarchy. When you change a value in the field of a certain node, all nodes in its subtree are affected. This feature allows you to define relative positions inside complicated compound objects.

You can mark every node with a specific name by using the keyword DEF in the VRML scene code. For example, the statement DEF MyNodeName Box sets the name for this box node to MyNodeName. You can access the fields of only those nodes that you name in a virtual world

In the following example of a simple VRML file, two graphical objects are modeled in a 3-D scene: A floor is represented by a flat box with a red ball above it. The VRML file is a readable text file that you can write in any text editor.

#VRML V2.0 utf8
# This is a comment line
WorldInfo {
  title "Bouncing Ball" 
}
Viewpoint {
  position 0 5 30
  description		"Side View"
}
DEF Floor Box {
  size 6 0.2 6
}
DEF Ball Transform {
  translation		 0 10 0
  children Shape {
    appearance Appearance {
      material Material {
        diffuseColor 1 0 0
      }
    }
    geometry Sphere {
    }
  }
}

The first line is the VRML header line. Every VRML file must start with this header line. It indicates that this is a VRML 2 file and that the text objects in the file are encoded according to the UTF8 standard. You use the number sign (#) to comment VRML worlds. Everything on a line after the # sign is ignored by a VRML viewer, with the exception of the first header line.

Most of the box properties are left at their default values – distance from the center of the coordinate system, material, color, and so on. Only the name Floor and the dimensions are assigned to the box. To be able to control the position and other properties of the ball, it is defined as a child node of a Transform type node. Here, the default unit sphere is assigned a red color and a position 10 m above the floor. In addition, the virtual world title is used by VRML viewers to distinguish between virtual worlds. A suitable initial viewpoint is defined in the virtual world VRML file.

When displayed in a VRML viewer, the floor and red ball look like this:

Was this topic helpful?