XML format for 3D geometry
Jean-Marc Vanel
2000-03-12
Introduction
For our project of making botanical data available on Internet, we need
3D images. We need a compact, non proprietary, preferably XML, clean definition
for complex 3D geometries.
It seems that a representation both compact and flexible should be based
on mathematics. VRML's cones and cylinders are just special cases
of intersections of volumes defined by equations:
f(x,y,z)>=0
NURBS and Beziers patches are just special cases of surfaces defined
by 3 functions R2 ---> R3
(u,v) ---> (X(u,v),Y(u,v),Z(u,v))
MathML
A solution is to use the content part of MathML
(spec. of MathML) . I have reviewed
it: it has the desired capabilities, i.e. allows to define functions and
sets, it is XML. Certainly only a subset of MathML is needed: n-dimentional
geometry, n>3 is not relevant. On the other hand, some geometrical primitives
could be added :
-
convex hulls,
-
recursive constructs like fractals and L-systems,
-
transforms, deformations, parametrization, movement
See below for a sphere Example showing
how a preliminary definition for a parametrized sphere shape (that could
reside in a configuration file or on Internet) makes for a very compact
definition.
Also an advantage of mathematical representation is being able,
by formal differentiation, to compute exact normal and tangent plane for
light-ray reflection rendering.
VRML
I have followed the debates about VRML/X3D
(Virtual Reality Modeling Language) for weeks on x3d-contributors@web3d.org.
The point is about modular schemas versus monolythic Schemas. X3D is a
very "good" example of monolythic DTD. NOTHING is taken from the XML world
outside X3D.
VRML has existed for years, and has not met a huge success. The current
X3D specification seems merely a word-for-word translation of VRML97 in
old XML monolythic DTD style. It's more than time to have a modular state
of the art XML VR vocabulary, with all the facilities of XML Namespaces,
XML Schema, and possibly XSLT, SMIL, etc.
It's also more than time to search other partners for the 3D geometry
subset outside of the video circle, notably CAD and scientists involved
in numerical simulations, and biological descriptions. See below the wide
perspectives opened by this convergence.
Also there is a big opportuneness to have skilled computer scientists
from the numerical simulations domain join the design process. They are
shure, like I am, discouraged by the current design of VRML, and its too
narrow scope.
Design hints for VR
It seems that Virtual Reality (VR) involves several layers that can be
used and designed independently:
-
volumic objects definition (see above)
-
colors and textures on volumic objects
-
behavior of volumic objects among them (contact, glued or sliding, rotating,
interpenetrable, etc)
-
behavior of volumic objects with User Interface
-
a scene as composite Design Pattern of volumic objects
-
light sources
-
scenarios (time-dependant aspect )
-
sounds
Perspectives
This need for a compact, non proprietary, preferably XML, clean definition
for complex 3D geometries is common with other important domains:
-
Computer Aided Design (CAD)
-
Architecture
-
simulation in mechanics, physics, and biology
CAD is a very important field that has currently no XML non-proprietary
language. The current non-XML formats, IGES, STEP are not satisfactory
for a number of reasons. It seems that the proposed solution could bring
an interesting synergy able to speed up developments, together with a better
design. And also a common subset for CAD and Virtual Reality will bring
new possibilities to exchange data. Think of the advantages for the VR
people of being able to import directly shapes from manufacturing industry,
and use them in animations! A well-designed model and XML syntax for virtual
reality could also be used for cartoons and video games.
Issues
-
implementation
-
use primitives of Open GL
-
generate triangular facets on the fly; for this there are nice algorithms
from INRIA using Voronoï-Delanay
methods in 2D Riemann space (see images)
-
use XSLT to generate other math format, like Mathematica, Maple, Scilab,
etc
-
use an XSLT engine embeded in VR renderer to generate an evaluation tree
in memory for math expressions (see below an example
with C++ where declarations are generated)
-
performance issues for animation
-
specification of the subset of MathML for 3D geometry, say Geometry ML
-
how to validate an XML information with respect to Geometry ML: through
XML Schema validation, through Schematron
ANNEX 1: a sphere in MathML
Note: this is just a example to show the vast possibilities of MathML;
a final version of sphere would be different. We would use the characteristic
function associated to sets, and multiply functions for intersections,
and add functions for unions. Below is an XSLT
transform from a MathML 3D geometry file such as this
example to C++ declarations.
sphere.MathML.xml
ANNEX 2: an XSLT transform from a MathML geometry
to C++
The XSLT below transforms a MathML 3D geometry file such as the sphere
example above to C++ declarations.
Mathml2c.xslt
sphere.cpp generated C++
Geom3d.cpp additional declarations