BS Contact 6.1 supports X3D - XML parsing.
X3D defines an XML Encoding for VRML97 as well as a new revision of the standard.
Contact supports the X3D XML Encoding of VRML Scenes. Also the nodes from Contact included into X3D and all other extensions nodes are supported.
No new additional X3D nodes (Beside H-Anim/NURBS and Contact style MultiTexturing) are supported.
A new Contact COM Method load allows flexible parsing of XML or VRML Syntax from an in-memory representation.
In case you have installed Contact version 6.100 please upgrade to version 6.101 for some important X3D implementation fixes.
Contact uses the Microsoft MSXML Parser, which comes in different flavours.
Microsoft Internet® Explorer XML Integration
Instead of Contact loading and parsing the X3D XML File, an DOM XML Tree can be created using Internet Explorer 6 and JScript/VBScript Scripting. The MSXML DOM Tree is then passed to Contact via the load method:
Fragment example:
The following script lines are loading an XML File in Internet Explorer:
// create XML DOM Parser
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
// load document
xmlDoc.load(url);
Next the loaded DOM Tree is passed to Contact :
// tell contact to load the World from XML-DOM contact.load(xmlDoc);
It is possible to use XSLT
first to transform the loaded XML Document. In the following example an XSL
Transform is applied to convert X3D to VRML97.
The resulting string is then passed to Contact :
url = "HelloWorld.x3d"; xslUrl = "X3dToVrml97.xsl"; var xmlDoc=loadXML(url); var xslDoc=loadXML(xslUrl); // apply transform var result= xmlDoc.transformNode(xslDoc); // tell contact to load from resulting string (VRML/XML) contact.load(result);
In each case Contact is embedded on the HTML Page as
<OBJECT CLASSID="CLSID:4B6E3013-6E45-11D0-9309-0020AFE05CC8"
ID=contact WIDTH=100% HEIGHT=50%>
<PARAM NAME="SRC" VALUE="">
</OBJECT>
The next example loads an X3D
file in a text-editor and a 3D view.
The text can be edited and reloaded via the "Refresh from Input button".
New url's can be loaded via the input field.
CML Chemical Markup Language example
This example uses the data and stylesheet from VirtuWorlds
- Nicholas F. Polys
The data is loaded as CML XML and translated to X3D, and then displayed in 3D
& as XML editable text.
These examples are just scratching the surface of the capabilities.
Some ideas are:
- Keep the XML DOM and apply client side modifications or subset selection (XPath) on the XML DOM
The results can quickly be showed again via above described methods.
Single attribute changes can be done directly on the Contact scene graph using
the setNodeEventIn(nodeName,fieldName,fieldValue) function.
- Use a custom XML Schema and data to on the fly generate X3D/VRML representations on the client.
- For repeated XSL Transforms consider to use an XSLTemplate object.
For more capabilities of the DOM API refer to the MSXML Documentation
boolean load(VARIANT src)
For X3D XML Content src may be of of type
For VRML Content src may be of type
XML Content may also be loaded via createVrmlFromString :
var cone = '<Shape><Cone bottomRadius="3.5" height="1.5"/><Appearance><Material diffuseColor=".9 .3 .6"/></Appearance></Shape>'; // load via createVrmlFromString & replaceWorld var scene=contact.createVrmlFromString(cone); var ret = scene != null; if (ret) contact.replaceWorld(scene);
X3D Implementation notes
Contact does register for the x3d/x3dz file extension and model/x3d-xml mime type. One can also use the object tag to embed Contact in a webpage and can pass an file/url with the x3d extension.
Gziped x3d /x3dz files are transparently supported.
Hello World - x3d unzipped XML
Hello World - x3dz gzipped XML
The x3d mimetypes need to be configured on a webserver, otherwise files with the X3D extensions show up as text. Once mimetypes are changed, make shure to clean the cache of the Webbrowser, because already downloaded URL's are stored with the old mimetype.
The use of the DTD adds default values to all fields of all nodes. This may be a slowdown for large files, because all the default values need to be processed and the XML is validated against the schema/DTD.
VRML and X3D-XML encoding is supported also in createVrmlFromString and Inline.
For Nodes with multiple SFNode MFNode fields its is recommended to properly add the containerField attribute to child nodes.
For translated examples please refer to the automated translation datasets
of the X3D Taskgroup. Most examples are using an hardcoded /www.web3d.org path
on the local harddisk for the DTD, so they can not be validated and not parsed.
The files need to be fixed to refer to the proper DTD location :
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" http://www.web3d.org/specifications/x3d-3.0.dtd">
At the X3D Site (mostly with wrong DTD, so they will not work unless local
www.web3d.org folder exists):
VRML
2.0 Sourcebook - Examples
Universal
Media Materials - Examples
X3D -Taskgroups Examples
NIST
Conformance examples
Adapted example scene:
NPS KelpForest Scene from Naval
Postgraduate School
Many Inlines, Scripts some EXTERNPROTOS, please ignore the parser warnings for
now.
All EXTERNPROTO/Inline references have been changed from wrl to X3D files, the
DTD references have been fixed.
NancyDiving an H-Anim structure.
HAnimJoint HAnimSegment HAnimSite HAnimDisplacer HAnimHumanoid nodes are supported, but they are written back to file without the HAnim prefix.
Some fields are are renamed in X3D, e.g. level & choice in LOD & Switch http://www.web3d.org/technicalinfo/specifications/ISO_IEC_19776/Part02/EncodingOfNodes.html#LOD
Then bboxCenter bboxSize fields have been added to LOD, Switch and Shape nodes. Other VRML97 nodes have new fields added like centerOfRotation to the Viewpoint node. The MultiTexture nodes has been changed a bit in structure from the Contact proposal and implementation.
Known problems
In case of problems its recommended to update the MSXML parser.
References
msdn.microsoft.com
- XML
msdn.microsoft.com
- MSXML API
msdn
download - installing MSXML3 SP2
msdn
info - Installing MSXML3, SP1 via CAB installer
MSXML javascript Sniffer - what MSXML version is installed ?