X3D and Virtual Scene Graphs

x3d earth
Fig 1 – XJ3D Viewer showing an x3d earth model.

Virtual Worlds and Scene Graphs

Well I confess, I’m no gamer! I’ve never handled a Wii or blown away monsters on a PS3. It doesn’t hold my interest that much. Guitar Hero makes me feel slightly nauseous. (When will they introduce Symphony Conductor for the Wii?) I suppose I’m an anachronism of the old paperback book era. My kids groan, but I can still get excited about the E.E. Smith Lensman series. However, I’m a bit chagrined to admit that I was oblivious to X3D until this past week. It’s just that gaming and GIS have not overlapped in my world yet.

X3D has been around quite awhile. Some of the specs date back as far as 2003 and then there is the VRML97 ancestory so this is not new stuff. It reminds me a bit of the early SVG days, circa 2000. The novelty of event driven graphics in the browser was overpowering then, but it wasn’t until years later that Flash and Silverlight actually made xml graphics generally available to web app interfaces, almost ten years later. Now of course, SVG even has native support in most of the non microsoft browsers. I can imagine in the year 2018 that 3D graphics XML will be ubiquitous, but it will probably be some derivative of ChromeFlash, XNA, or WPF, while X3D may still languish in the outer reaches of civilization.

X3D has a similar feel in that it’s a powerful anticipating specification with beautiful XML scene graph capability, but only a few implementations far from the mainstream. I won’t say I’m a sucker for XML, but I really, really like to look at a file and understand what it says. Nothing beats a good old text editor for playing with an XML graphics file. Sorry, my text bias is showing again.

The Java3D API is a parallel enabling technology. The scene graph approach implemented in Java3D’s api enabled implementations of free X3D viewers. There are several viewers, but the one that actually worked on the geospatial component of X3D was Xj3D.

What is X3D?

Directly from the x3d site:

“X3D is a scalable and open software standard for defining and communicating real-time, interactive 3D content for visual effects and behavioral modeling. It can be used across hardware devices and in a broad range of applications including CAD, visual simulation, medical visualization, GIS, entertainment, educational, and multimedia presentations.”

“X3D provides both the XML-encoding and the Scene Authoring Interface (SAI) to enable both web and non-web applications to incorporate real-time 3D data, presentations and controls into non-3D content.”

and here is an example of what it looks like:
¬†¬†¬
¬†¬†¬†<?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>
¬†¬†¬†¬†¬†¬†¬†¬†¬†<component name=”Geospatial” level=”1″/>
      </head>
      <Scene>
         <Group>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<PointLight location=”10000000000 0 0″ radius=”100000000000000″/>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<PointLight location=”-10000000000 0 0″ radius=”100000000000000″/>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<PointLight location=”0 10000000000 0″ radius=”100000000000000″/>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<PointLight location=”0 -10000000000 0″ radius=”100000000000000″/>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<PointLight location=”0 0 10000000000″ radius=”100000000000000″/>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<PointLight location=”0 0 -10000000000″ radius=”100000000000000″/>
¬†¬†¬
            <GeoViewpoint
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†position=”39.755092 -104.988123 60000″
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†orientation=”1.0 0.0 0.0 -1.57″
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†description=”Denver”
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†headlight=”true”
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†fieldOfView=”1.57″
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†geoSystem=’”GDC”‘>
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†<GeoOrigin DEF=”ORIGIN”
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†geoCoords=”0.0 0.0 -6378137″
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†geoSystem=”GDC” />
            </GeoViewpoint>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<Inline url=”tiles/0/tile_0.x3d”/>
         </Group>
      </Scene>
   </X3D>

After the normal XML declaration follows the root element:
   <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”>

In this case using version 3.2 of the X3D spec and a profile, “Immersive”. Profiles are used to break the X3D spec into smaller implementation areas. Consequently, with less effort, an implementor can meet a profile of the X3D spec suitable to the need instead of the entire “Full” specification.

X3D Profiles
Fig 2 – X3D Profiles

Curiously, the X3D Full profile lists the geospatial component, but the Immersive profile seemed to implement the geospatial elements of interest in my particular case. Perhaps geospatial was later moved to the Full profile. Here is a list of the xml node elments found in the geospatial component:

  • GeoCoordinate
  • GeoElevationGrid
  • GeoLocation
  • GeoLOD
  • GeoMetadata
  • GeoOrigin
  • GeoPositionInterpolator
  • GeoProximitySensor
  • GeoTouchSensor
  • GeoTransform
  • GeoViewpoint

You can see a ‘GeoViewpoint’ element and a ‘GeoOrigin’ element in the small x3d listing above. The Immersive/Full profile is meant to imply a virtual world immersion experience. This means that a scene graph populates a world with context including lighting and a viewpoint that navigates through the virtual world space. Now this is of interest to a GIS developer in the sense that the virtual world space can mimic a real world space.

X3D Earth provides some nice examples of using X3D with earth data. Not all of the examples are in working order using the latest build of XJ3D Browser. These are older samples and may not reflect the current configuration of the X3D specification.

Another example of a virtual world space mimicing the actual world is Google’s Earth API. You can use a flying viewpoint to navigate through a model of the Rocky Mountains and get something like the experience of a bird or fighter jet. The mimicry is still coarse but the effect is recognizable. This is the horizon end point of mapping. The map abstraction eventually disappears into a one to one mathematical mapping with some subtle abstraction available as overlays and heads up displays.

This is where the online mapping world eventually merges with the gaming world. Only for mapping, the imaginary part of the world is de-emphasized in favor of an immersive real world experience as an aid to navigating in external physical space. Thinking about these kinds of worlds and their overlaps has proven fascinating, as shown by the popularity of the Matrix movie series. Are we the Ghost in the Machine or the other way around? But that is best left to philosophy types.

Let’s move on to a couple of other useful X3D scene elements. GeoLOD geospatial Level Of Detail element is an interesting element for use in geospatial worlds. By recursively referencing deeper levels of x3d GeoTerrain tiles you have an affect similar to DeepEarth tile pyramids, but with the addition of 3D Terrain:

<?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>
¬†¬†¬†¬†¬†¬†<component name=”Geospatial” level=”1″/>
      </head>
      <Scene>
         <GeoLOD
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†center=”-61.875 -168.75 0.0 ”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†range=’2507443.095376239′
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†geoSystem=”GDC”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†child1Url=’../6/tile_0000100.x3d’
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†child2Url=’../6/tile_0000101.x3d’
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†child3Url=’../6/tile_0000102.x3d’
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†child4Url=’../6/tile_0000103.x3d’
         >
¬†¬†¬†¬†¬†¬†¬†¬†¬†<GeoOrigin DEF=”ORIGIN”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†geoCoords=”0.0 0.0 -6378137.0 ”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†geoSystem=”GDC” />
¬†¬†¬†¬†¬†¬†¬†¬†¬†<Group containerField=’rootNode’>
            <Shape>
               <Appearance>
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<Material diffuseColor=”0.3 0.4 0.3 “/>
                  <ImageTexture
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†url=”../../images/5/img_000010.png”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†repeatS=”false”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†repeatT=”false”/>
               </Appearance>
                     <GeoElevationGrid
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†ccw=’true’
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†colorPerVertex=’false’
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†creaseAngle=’0′
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†geoGridOrigin =”-67.5 -180.0 0.0 ”
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†yScale =’1.0′
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†geoSystem=’”GDC”‘
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†normalPerVertex=’false’
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†solid=’true’
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†xDimension=’37′
¬∑¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†xSpacing=’0.625′
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†zDimension=’37′
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†zSpacing=’0.3125′
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†height=”
                        -1618 -3574 -3728 -3707 -3814 -3663 -3455 -3089
                         -3258 -3457 -3522 -3661 -3519 -3757 -3412 -3379
                         -3674 -3610 -3503 -3679 -3521 -3537 -3397 -3790
                         -3795 -3891 -3883 -3864
                                             .
                                             .
                         -5086 -5138 -5089 -5229 -4965 -5021 -5064 -5099
                         -5062 -4952 -4955 -4810 -4635 -4686 -4599 -4408
                         -4470 -5407 -4482 -4600 -4486 -3942 -4202 -4100
                         -4306 -4293 -4010 -4091
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†“>
¬†¬†¬†¬†¬†¬† ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†<GeoOrigin USE=”ORIGIN” />
                  </GeoElevationGrid>
               </Shape>
            </Group>
         </GeoLOD>
   </Scene>
</X3D>

In the x3d snippet above you can see the GeoLOD that references down to level 6 of the terrain tile hierarchy. This is a recursive reference as each tile lower in the pyramid references the four tiles of the next level that make up the current tile, basically a quad tree approach found in most tile setups. The element attributes include a center, range, geosystem, and the ChildURL references. Inside the GeoLOD is a <Group> <Shape> element containing the current tile’s Appearance Material with a reference to the draping tile image and a GeoElevationGrid element with an array of elevations relative to the GeoOrigin.

For this to work there are two pyramids, one containing the draping images and one with the x3d GeoTerrainGrids. The GeoTerrainGrid is the same as x3d ElevationGrid except it introduces the concept of a geospatial reference system. This is all very clever and useful, but it requires the Xj3D Browser viewer to play with it. In order to author this kind of world scene you also need tools to tile both the underlying terrain models as well as the overlaid imagery.

x3d earth
Fig 3 – x3d earth model tile pyramid

Over in Microsoft I took a quick look at XNA Game Studio, which is the current development tool for XBox games. The XNA serializer supports a type of XML <XnaContent>, but there doesn’t seem to be much information about the XML XnaContent schema. I wasn’t able to find an X3D importer for XNA. Too bad, since an XNA importer would be another way to experiment with Terrain grids.

Summary:

As far as the future, it is easy to see that the WPF <MeshGeometry3D> can be used to perform the duties of a an ElevationGrid element. This means, at least in WPF, the basic building blocks are available to display and manipulate a scene in 3D. What is lacking is the concept of LOD, Level of Detail. After first seeing the DeepZoom MultiScaleImage element in action, I fell in love with the very natural navigation through its 2D space.

It is not much of a stretch to see this being extended to a “MultiScaleMeshGeometry3D” element. Again WPF appears to be a look at the future of Silverlight, so it is not impossible to imagine this type of capability in browsers by 2018. In the non-Microsoft world X3D will play a role once implementations make their way into Chrome, FireFox, and Opera. In some form or other, XML scene graphs will be in the future of GIS, and yes, we will all be pro gamers!

Comments are closed.