X3D file structure: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
Line 4: Line 4:


== Introduction ==
== Introduction ==
This is a short summary explaining the file structure of a [[X3D]] model.


[[X3D]] is a modular standard and therefore the X3D file structure is defined through several [http://www.web3d.org/x3d/specifications ISO Specifications].
[[X3D]] is a modular standard and therefore the X3D file structure is defined through several [http://www.web3d.org/x3d/specifications ISO Specifications].
Line 15: Line 17:
== The X3D file structure ==
== The X3D file structure ==


[[X3D]] scene files have a common file structure:
A X3D scene is defined by the contents of a [[URL]] (i.e. either an X3D file or some generator). This resource then can include additional elements.
 
X3D scene files have a common file structure:


* File header (XML, ClassicVRML, Compressed Binary)
* File header (XML, ClassicVRML, Compressed Binary)
Line 60: Line 64:
           <Appearance>
           <Appearance>
             <Material diffuseColor='0 0.5 1'/>
             <Material diffuseColor='0 0.5 1'/>
             <ImageTexture url='"earth-topo.png" "earth-topo.jpg" "earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"'/>
             <ImageTexture url='"earth-topo.png" "earth-topo.jpg" "earth-topo-small.gif"  
    "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png"
    "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg"
    "http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"'/>
           </Appearance>
           </Appearance>
         </Shape>
         </Shape>
Line 101: Line 108:
* version 3.1  
* version 3.1  
* version 3.2 (Version 3.2.2 was published in April 2005 and should be supported by most browsers)
* version 3.2 (Version 3.2.2 was published in April 2005 and should be supported by most browsers)
To us, it is totally unclear where versions are defined and where one can find central information about support profiles and versions by various clients and other tools - [[User:Daniel K. Schneider|Daniel K. Schneider]] 13:19, 5 October 2010 (CEST).
To us, it is totally unclear where versions are defined and where one can find central information about support profiles and versions by various clients and other tools - [[User:Daniel K. Schneider|Daniel K. Schneider]] 13:25, 5 October 2010 (CEST).


See below for more information about profiles and components
See below for more information about profiles and components
Line 173: Line 180:
  PROFILE Immersive
  PROFILE Immersive


Additional components with respect to the ones includes in the declared profile can be included in the had section as in the following [http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01-TechnicalOverview/_pages/page01.html Header Profile Component Meta Example] (retrieved 13:19, 5 October 2010 (CEST)). The component tags raise the support level from Immersive profile to include other components included in the X3D 3.0 Full profile.
Additional components with respect to the ones includes in the declared profile can be included in the had section as in the following [http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01-TechnicalOverview/_pages/page01.html Header Profile Component Meta Example] (retrieved 13:25, 5 October 2010 (CEST)). The component tags raise the support level from Immersive profile to include other components included in the X3D 3.0 Full profile.


<source lang="xml">
<source lang="xml">
Line 273: Line 280:
; X3D Examples
; X3D Examples


* [http://x3dgraphics.com/examples/X3dForWebAuthors/index.html  
* [http://x3dgraphics.com/examples/X3dForWebAuthors/index.html X3D for Web Authors Examples Archive]. This archive also can used as a kind of manual.
X3D for Web Authors Examples Archive]. This archive also can used as a kind of manual.


== Credits and Copyright modificiation ==
== Credits and Copyright modificiation ==

Revision as of 13:25, 5 October 2010

Draft

This article or section is currently under construction

In principle, someone is working on it and there should be a better version in a not so distant future.
If you want to modify this page, please discuss it with the person working on it (see the "history")

Introduction

This is a short summary explaining the file structure of a X3D model.

X3D is a modular standard and therefore the X3D file structure is defined through several ISO Specifications.

Combined, these specifications are then available in terms of three types of schemas: DTD, XML Schema (XSD) and

  • x3d-3.2.dtd. Can ensure proper parent-child element relations and attribute naming
  • x3d-3.2.xsd. In addition, can ensure proper type-checking of most attribute values.
  • X3D Schematron. For additional validation that can't be handled by XSD.

The X3D file structure

A X3D scene is defined by the contents of a URL (i.e. either an X3D file or some generator). This resource then can include additional elements.

X3D scene files have a common file structure:

  • File header (XML, ClassicVRML, Compressed Binary)
  • Start of the X3D root node including version and profile attributes
  • A head section with Component and Meta statements (both optional)
  • X3D scene graph and its child nodes
  • End of the X3D root node

We shall shortly describe these elements below. But before, let's have a look at the code of a simple exemple scene, inserted XML comments identify the elements:

<?xml version="1.0" encoding="UTF-8"?>

<!-- -------------------- X3D header and X3D root node with profile declaration -->
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
                     "http://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile='Immersive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>

<!-- -------------------- head section with included meta data -->
  <head>
    <meta content='HelloWorld.x3d' name='title'/>
    <meta content='Simple X3D example' name='description'/>
    <meta content='30 October 2000' name='created'/>
    <meta content='7 August 2010' name='modified'/>
    <meta content='Don Brutzman' name='creator'/>
    <meta content='http://www.web3D.org' name='reference'/>
    <meta content='http://x3dGraphics.com' name='reference'/>
    <meta content='http://www.web3d.org/x3d/content/examples/HelloWorld.x3d' name='identifier'/>
    <meta content='http://www.web3d.org/x3d/content/examples/HelloWorldTall.png' name='image'/>
    <meta content='http://www.web3d.org/x3d/content/examples/license.html' name='license'/>
    <meta content='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit' name='generator'/>
  </head>

<!-- -------------------- the X3D scene node with X3D nodes -->
  <Scene>
    <!-- Example scene to illustrate X3D nodes and fields (XML elements and attributes) -->
    <Group>
      <Viewpoint centerOfRotation='0 -1 0' description='Hello world!' position='0 -1 7'/>
      <Transform rotation='0 1 0 3'>
        <Shape>
          <Sphere/>
          <Appearance>
            <Material diffuseColor='0 0.5 1'/>
            <ImageTexture url='"earth-topo.png" "earth-topo.jpg" "earth-topo-small.gif" 
	    "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png"
	    "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg"
	    "http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"'/>
          </Appearance>
        </Shape>
      </Transform>
      <Transform translation='0 -2 0'>
        <Shape>
          <Text string='"Hello" "world!"'>
            <FontStyle justify='"MIDDLE" "MIDDLE"'/>
          </Text>
          <Appearance>
            <Material diffuseColor='0.1 0.5 1'/>
          </Appearance>
        </Shape>
      </Transform>
    </Group>
  </Scene>

<!-- -------------------- footer, closing X3D toot element -->
</X3D>

X3D file header and filename extensions

Since X3D has grown out of VRML it has both an XML and a VRML syntax. In addition, both formats can be delivered in compressed format.

The Header for X3D / XML needs an XML declartion and an optional DTD. The XML Schema (XSD) is declared in the root node which must include a version and a profile attribute.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
                     "http://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile='Immersive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>

As of october, there exist several final X3D versions:

  • version 3.0
  • version 3.1
  • version 3.2 (Version 3.2.2 was published in April 2005 and should be supported by most browsers)

To us, it is totally unclear where versions are defined and where one can find central information about support profiles and versions by various clients and other tools - Daniel K. Schneider 13:25, 5 October 2010 (CEST).

See below for more information about profiles and components

The following file extensions should be used for X3D contents:

X3D Encoding File Extension MIME Type
Classic VRML .x3dv model/x3d+vrml
XML .x3d model/x3d+xml
Binary .x3db model/x3d+binary

E.g. if you have an Apache server you could add the following lines to a *.conf file:

AddType model/x3d+xml .x3d
AddType model/x3d+vrml .x3dv
AddType model/x3d+binary .x3db
AddEncoding gzip .x3dvz
AddEncoding gzip .x3dbz

Profiles, components

X3D has a modular architecture that defines 4 to 6 baseline profiles (depending on the version) which are are predefined collections of components. Profiles are defined with XML attributes in the X3D root node or as VRML statements on top.

In addition, within the head section, authors can specify more precisely what components are needed. Components are predefined collections of nodes and match chapters in the specification. Each profile can be augmented by adding other components

Both the mandatory profile definition and the optional components statements tells the X3D browser what level of support is needed for run-time operation.

The 3.2 specification includes six profiles:

  • Core is just the core (probably not useful for authors)
  • Interchange is the basic profile for communicating between applications. It supports geometry, texturing, basic lighting, and animation
  • CADInterchange adds support for CADGeometry component nodes to Interchange Profile.
  • Interactive enables basic interaction with a 3D environment by adding various sensor nodes for user navigation and interaction (e.g., PlanseSensor, TouchSensor, etc.), enhanced timing, and additional lighting (Spotlight, PointLight).
  • Immersive enables full 3D graphics and interaction, including audio support, collision, fog, and scripting. Corresponds to the power of VRML 97 plus minor additions.
  • MPEG4Interactive
  • Full includes all defined nodes including NURBS, H-Anim (animated interactive Avatars) and GeoSpatial components.
X3D Baseline Profiles: Source: What is X3D?, retrieved 11:53, 26 August 2010 (UTC)

Examples of X3D profile declarations

<X3D profile='Immersive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
</X3D>
<X3D profile='Interactive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
</X3D>

Examples of X3D ClassicVRML profile declarations

PROFILE Immersive

Additional components with respect to the ones includes in the declared profile can be included in the had section as in the following Header Profile Component Meta Example (retrieved 13:25, 5 October 2010 (CEST)). The component tags raise the support level from Immersive profile to include other components included in the X3D 3.0 Full profile.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "http://www.web3d.org/specifications/x3d-3.1.dtd">

<X3D profile='Immersive' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>
<head>
<component level='1' name='DIS'/>
<component level='1' name='Geospatial'/>
<component level='1' name='H-Anim'/>
<component level='3' name='NURBS'/> 
<!-- .... content deleted -->
</head>
</X3D>

Meta statements

Meta statements provide information about the X3D scene as a whole

Information is provided as name-value pairs, for example

 <meta name='created' value='1 January 2008'/>

This approach is thus very general and a wide variety of metadata can be represented. The X3D approach matches same approach used by HTML for regular hypertext web pages.

The X3D scene graph

Each X3D file only can include one X3D scene according to XML principles. In other words there must be a single root element.

At the content level, the same principle as for HTML applies. There can be only a single scene in the same way that in HTML there is only one body

A very minimalistic valid X3D file would look like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
  "http://www.web3d.org/specifications/x3d-3.2.dtd">
 <X3D profile='Immersive' version='3.2'
      xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
      xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
 <head>
 </head>
 <Scene>
    <!-- Scene graph with a single red ball -->
    <Shape>
      <Sphere radius='2.0'/>
      <Appearance>
         <Material diffuseColor='1.0 0.0 0.0'/>
      </Appearance>
    </Shape>
 </Scene>
</X3D>

X3D ClassicVRML syntax

In our tutorials we shall not explain VRML syntax. See the VRML Primer and Tutorial we made over 10 years ago. We just point out that X3D/ClassicVRML is different from VRML1997, i.e. the ClassicVRML profile looks like VRML and uses the same syntax, but there are some changes between the last VRML standard (ISO/IEC 14772-1) and the new X3D-based ISO/IEC 19776-2. In particular, the scripting interface has been totally overhauled.

It is also important to understand the most X3D clients can render VRML 1997 (and the other way round if the VRML client is recent).

#X3D V3.2 utf8

PROFILE Immersive

META "title" "HelloWorld.x3d"
META "description" "Simple X3D example"
META "created" "30 October 2000"
META "modified" "7 August 2010"
META "creator" "Don Brutzman"
META "reference" "http://www.web3D.org"
META "reference" "http://x3dGraphics.com"
META "identifier" "http://www.web3d.org/x3d/content/examples/HelloWorld.x3d"
META "image" "http://www.web3d.org/x3d/content/examples/HelloWorldTall.png"
META "license" "http://www.web3d.org/x3d/content/examples/license.html"
META "generator" "X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit"

NavigationInfo { type [ "EXAMINE" "ANY" ] } ###  Default X3D NavigationInfo

# Example scene to illustrate a single X3D node in VRMLClassic syntax
Shape {
       geometry Sphere {  }
       appearance Appearance {
           material Material {
           diffuseColor 0 0.5 1
           }
       }
}

Links

Specification and Schema documentation
X3D Examples

Credits and Copyright modificiation