VRML -> X3D
Introducing
X3D
X3D XML Syntax Overview (3)
X3D XML Examples
Some more examples of the XML encoding and how the .x3d file is composed.
X3D Appearance and Material Schema
<xsd:element name="Appearance">
<xsd:all>
<xsd:element ref="ImageTexture"/>
<xsd:element ref="Material"/>
<xsd:element ref="MovieTexture"/>
<xsd:element ref="PixelTexture"/>
<xsd:element ref="TextureTransform"/>
</xsd:all>
</xsd:element>
<xsd:element name="Material">
<xsd:attribute name="ambientIntensity" type="SFFloat" default="0.2" />
<xsd:attribute name="diffuseColor" type="SFColor" default="0.8 0.8 0.8" />
<xsd:attribute name="emissiveColor" type="SFColor" default="0 0 0" />
<xsd:attribute name="shininess" type="SFFloat" default="0.2" />
<xsd:attribute name="specularColor" type="SFColor" default="0 0 0" />
<xsd:attribute name="transparency" type="SFFloat" default="0" />
</xsd:element>
X3D XML Appearance, Material.
If both a Material (in Appearance)and a Color node
(as a GeometricPropertyNode) are specified for a geometric Shape,
the ColorNode shall replace the diffuseColor component of the Material.
Results
<Shape>
<Appearance>
<Material/>
</Appearance>
<Box/>
</Shape>
<Material ambientIntensity='SFFloat' diffuseColor='Color'
emissiveColor='SFColor' shininess='SFFloat'
specularColor='SFColor' transparency='SFFloat' />
<Material ambientIntensity='0.2' diffuseColor='0.8 0.8 0.8'
emissiveColor='0 0 0' shininess='0.2'
specularColor='0 0 0' transparency='0' />
<Transform translation='6.1 0.6 -3.0'>
<Shape>
<Appearance>
<Material/>
</Appearance>
<Box/>
</Shape>
</Transform>
Shape, Default Material, and Transform.
Encoding Choices
Current: SF/MFfield is name='value' pair:
<Transform center='0.5 0 -0.7'
translation='6.1 0.6 -3.0'
rotation='0.6 0 1 0.157'
scale='2 3 5'
scaleOrientation='0.5 0 1 -1'
rotation='0 0 1 0' >
... ChildNodes ...
</Transform>
Simplified:
<Transform translation='6.1 0.6 -3.0'
... moreattrs ... >
... ChildNodes ...
</Transform>
Empty elements and simple attributes:
<Transform>
<translation x='6.1' y='0.6' z='-3.0' />
<... moreattrs ... />
... ChildNodes ...
</Transform>
All simple attributes:
<Transform translationX='6.1'
translationY='0.6'
translationZ='-3.0'
... moreattrs ... >
... ChildNodes ...
</Transform>
All elements with cdata content:
<Transform>
<translation> 6.1 0.6 -3.0 </translation>
<... moreattrs ... > ... </... moreattrs ...>
... ChildNodes ...
</Transform>
Elements with elements with content:
<Transform>
<translation>
<x> 6.1 </x>
<y> 0.6 </y>
<z> -3.0 </z>
</translation>
<... moreattrs ... >
...
</... moreattrs ...>
... ChildNodes ...
</Transform>
Variable Types:
FieldTypes Value
SF/MF SingleField/MultipleField
Initialized = SF = 0 or NULL
MF = EmptyList
or, default value defined by Node
SF/MFBool true|false
SF/MFColor r g b (fp)
SFColorRGBA/MFColorRGBA r g b alpha (fp)
SFDouble/MFDouble single dpfp
SF/MFFloat single fp
SF/MFImage 2D pixel image
SF/MFInt32 int
SF/MFNode Node
SF/MFRotation x y z angle (fp)
SF/MFString "quoted string"/"str","str"
SF/MFTime dpfp 01011970,00:00:00GMT
SF/MFVec2d x y | s t (dpfp)
SF/MFVec2f x y | s t (fp)
SF/MFVec3d x y z (dpfp)
SF/MFVec3f x y z (fp)
* Int = 32 bit signed integer
* fp = standard precision floating point
minimum 6 decimal digits of precision,
exponents range = [-12,12] for
both positive and negative numbers
* dp = high-precision (double) floating point
minimum 14 decimal digits of precision,
exponents = [-12,12] for
both positive and negative numbers
Selected XML encoding uses max XML Schema Capabilities.
And extends the box then asks for more..
A Main Contribution:
Enabling Schema Validation of VRML variable types.
The translation, rotation, scale, scaleOrientation and center fields define a geometric 3D transformation consisting of (in order):
- a (possibly) non-uniform scale about an arbitrary point
- a rotation about an arbitrary point and axis
- a translation
The Diagram(s)
Object
|
+---- Abstract Interfaces ------ Instantiable Nodes
FieldNames
NodeNames
Base
|
BaseNode
|
+- AppNode --------------------- Appearance
| AppChildNode
|
|
+- AppChildNode -+- MatlNode --- Material
| ambientIntensity='Float'
| diffuseColor='Color'
| emissiveColor='Color'
| shininess='Float'
| specularColor='Color'
| transparency='Float'
|
|
+- TxtrNode -+- ImageTexture
| | url="urlStrings"
| +- MovieTexture
| +- PixelTexture
|
+- TextureTranNode - TextureTransform
center="Vector2Float"
rotation="Float"
scale="Vector2Float"
translation="Vector2Float"
The diagram shows the language structure and content of nodes and fields.
1. abstract nodes are never instantiated.
2. empty abstract nodes may indicate weakness of the
hierarchy.
3. no abstract nodes may indicate weakness and lack of
intended extensibility in the hierarchy.
4. you wish to identify unique attributes and methods
in the concrete node.
5. you wish to identify common and inherited attributes
and methods as close to the hierarchy root as practical.
6. abstract nodes can produce concrete or abstract nodes.
7. concrete nodes never derive from concrete nodes.
8. identify opportunities for multiple inheritance as
close to the hierarchy root as possible.
<Appearance>
<ImageTexture url="someStringsUrl" />
<TextureTransform
center="0 0"
rotation="0"
scale="1 1"
translation="0 0" />
</Appearance>
The diagram is a way to show unique attributes and methods
of a concrete node as well as how it inherits common attributes
and methods from abstract nodes that construct the path from
the root to the concrete.
My basepage for Diagrams
Example Viewpoint
Viewpoint : X3DBindableNode {
SFBool [in] set_bind
SFVec3f [in,out] centerOfRotation 0 0 0 (-∞,∞)
SFFloat [in,out] fieldOfView 0.785 (0,∞)
SFBool [in,out] jump TRUE;
SFRotation [in,out] orientation 0 0 1 0 (-∞,∞)|[-1,1]
SFVec3f [in,out] position 0 0 10 (-∞,∞)
SFString [] description ""
SFTime [out] bindTime;
SFBool [out] isBound;
}
Viewpoint set_bind = True if first Viewpoint, else False
<Viewpoint
description='"String"'
examine='Vector3Float'
fieldOfView='Float'
jump='Boolean'
orientation='Rotation'
position='Vector3Float' />
<Viewpoint description='"Left View"'
orientation='0 1 0 -1.57' position='-15 0 0' />
<NavigationInfo type='"EXAMINE" "WALK" "FLY" "ANY"'/>
TimeSensor : X3DSensorNode, X3DTimeDependentNode {
SFTime [in,out] cycleInterval 1 (0,∞)
SFBool [in,out] enabled TRUE
SFBool [in,out] loop FALSE
SFTime [in,out] pauseTime 0 (-∞,∞)
SFTime [in,out] resumeTime 0 (-∞,∞)
SFTime [in,out] startTime 0 (-∞,∞)
SFTime [in,out] stopTime 0 (-∞,∞)
SFTime [out] cycleTime
SFTime [out] elapsedTime
SFFloat [out] fraction_changed [0,1]
SFBool [out] isActive
SFBool [out] isPaused
SFTime [out] time
}
<TimeSensor DEF='Timer01'
cycleInterval='5' enabled='True' loop='True' />
From that you can write the XML coding for Viewpoint and TimeSensor.
The "cycle" of a TimeSensor node lasts for cycleInterval seconds. The value of cycleInterval shall be greater than zero. A TimeSensor node can be set up to be active at read time by specifying loop TRUE (not the default) and stopTime less than or equal to startTime (satisfied by the default values).
Lighting Characteristics:
Some Properties:
location='Vector3Float'
Where the light is located, x,y,z.
ambientIntensity='Float'
Ambient illumination results from the scattering and reflection of light originally emitted directly by light sources.
color='Color'
What colour is the light? RGB 0 to 1
intensity='Float'
How bright is it? 0 to 1
direction='Vector3Float'
Where is it aimed? The direction vector of the illumination emanating from the light source in the local coordinate system.
attenuation='Vector3Float'
PointLight illumination falls off with distance as specified by three attenuation coefficients.
radius'Float'
beamWidth='Float'
cutOffAngle='Float'
Poinlight, Spotlight: Specifies the radial extent of the solid angle and the maximum distance from location that may be illuminated by the light source.
Examples:
<PointLight DEF='the-light'
intensity='0.6' location='0 0 10' radius='50'/>
<DirectionalLight DEF='Sun1' on='true'/>
<SpotLight beamWidth='1.57'
cutOffAngle='0.785'
on='false'/>
PointLight and SpotLight illuminate all objects in the world that fall
within their volume of lighting influence regardless of location within
the transformation hierarchy.
PointLight defines this volume of influence as a sphere centred at the light
(defined by a radius) and attenuation with distance.
SpotLight defines the volume of influence as a solid angle defined by a
radius and a cutoff angle.
DirectionalLight nodes illuminate only the objects descended from the
light's parent grouping node, including any descendent children of the
parent grouping nodes.
Some Others
<Transform translation='6.1 0.6 -3.0'>
<Shape>
<Appearance>
<Material/>
<ImageTexture url='vts.jpg' />
</Appearance>
<Box/>
</Shape>
</Transform>
<TouchSensor DEF='the-touch' />
<Background DEF='grays'
groundColor='0 0 0'
skyColor='0.41176 0.41176 0.41176 1 1 1' />
<Shape>
<Appearance>
<Material/>
</Appearance>
<Text string='"The X3DVRML Test Suite"'/>
</Shape>
<IndexedFaceSet coordIndex=' 0 4 3 -1 <!-- face A, right -->
1 4 0 -1 <!-- face B, back -->
2 4 1 -1 <!-- face C, left -->
3 4 2 -1 <!-- face D, front -->
0 3 2 1' > <!-- face E, bottom -->
<Coordinate point=' 3 0 -3, -3 0 -3, -3 0 3, 3 0 3, 0 6 0' />
</IndexedFaceSet>
DEF-USE in X3D:
X3DVRML X3DXML
DEF UserName NodeName { <NodeName DEF='ID' ...>
... ...
} </NodeName>
... ...
NodeName USE UserName <NodeName USE='IDREF' />
<IndexFaceSet DEF='MyIFS' ... >
...
</IndexedFaceSet>
...
<IndexedFaceSet USE='MyIFS' />
Example Transform, TouchSensor, Background, Indexed Face Set.
Luckily, the VRML97 crew left us the DEF, so we use that for the
XML ID and IDREF is X3DXML DEF and USE.
Example Animation
<Transform . . . >
<Shape>
<IndexedFaceSet coordIndex='... -1 ... >
<Coordinate DEF='Moved' point=' x y z, ... /> t0Geometry
</IndexedFaceSet>
</Shape>
</Transform>
<CoordinateInterpolator DEF='Mover'
key 't0 t1 t2 ' list time interval keys, 0 to 1
keyValue ' x y z, ... ' /> one geometry for each key time
<TimeSensor DEF='Timer' cycleInterval='5' loop='true' />
<ROUTE Timer TO Mover.key />
<ROUTE Mover.keyValue TO Moved.point />
<IndexedFaceSet coordIndex='0 1 3 2 -1 4 5 7 6 -1 6 7 1 0 -1
2 3 5 4 -1 6 0 2 4 -1 1 7 5 3 -1'>
<Coordinate DEF='Moved' point='-2 1 1 -2 -1 1 2 1 1 2 -1 1
2 1 -1 2 -1 -1 -2 1 -1
-2 -1 -1'/>
</IndexedFaceSet>
<CoordinateInterpolator DEF='Mover'
key='0 0.17 0.34 0.51 0.68 0.86 1'
keyValue='-1 1 1 -1 -1 1 1 1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1
-1 -1 -1 -2 1 1 -2 -1 1 2 1 1 2 -1 1 2 1 -1 2 -1
-1 -2 1 -1 -2 -1 -1 1 1 1 -1 -1 1 1 1 1 1 -1 1 1
1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 2 -1 -1 2 1 1
2 1 -1 2 1 1 2 1 -1 -2 -1 1 -2 -1 -1 -2 -1 1 1 1
-1 1 1 1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1
-1 2 1 -1 2 1 1 2 1 1 -2 1 1 2 -1 1 -2 -1 1 2 -1
-1 -2 -1 -1 1 1 -1 1 1 1 1 1 1 -1 1 1 1 -1 1 1 -1
-1 1 -1 -1 -1 -1' />
<TimeSensor DEF='Timer' cycleInterval='5' loop='true'/>
<ROUTE fromNode='Timer' fromField='fraction_changed'
toNode='Mover' toField='set_fraction'/>
<ROUTE fromNode='Mover' fromField='value_changed'
toNode='Moved' toField='point'/>
This shows a simple animation using Timer and CoordinateInterpolator.
Nodes contain fields and events.
Messages may be sent between nodes along routes.
X3D XML Simple File
X3DXML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "http://www.web3D.org/2003/X3DXMLSchema.xsd">
<X3D lang="en" xmlns="http://www.web3d.org/2003/x3d"
version="1.0" profile="Interchange">
<head>
<component name="GeoVRML:1" />
<component name="Geom:3" />
<component name="Nurbs" level="Trimmed" />
<meta name="description" content="My X3D Example" />
</head>
<Scene>
<!-- Scene graph nodes here -->
</Scene>
</X3D>
X3DVRML:
#X3D V3.0 utf8
PROFILE Interchange
COMPONENT Geom:3
COMPONENT GeoVRML:1
For an XML document including the x3d namespace,
read by an X3D Browser, we think a typical file
can look like this.
The root element is X3D, and its children are head and Scene.
Whether this is defined by using XML document type and a dtd or schema, or by XML Namespaces and a schema will depend upon the application.
This also shows the X3DVRML encoding for the Profile and Component statements.
Browser Conformance for profiles/component:
1) Supports using native, internal implementations of the required nodes,
2) Has an internal mechanism for locating internally cached sets of
nodes (for example an installer that places the nodes as either
internal browser-specific code or as PROTOs is provided),
3) A Web3d mandated URN is resolved to locate, fetch and load PROTO
definitions from a Web3D repository. This resolution mechanism is to be
performed independently of the user's world and should present the nodes
as first class nodes, not as protos.
Note: This mechanism will not work for components that can't be implemented via PROTO's, like a change to the event model... but we are hoping those are few and far between.
web3d x3d syntax
Welcome to a discussion of the XMLization and DOMification of VRML.