13.4. Writing a VRML/X3D file

Figure 13.3. VRML action classes


These two actions, SoToVRMLAction SoToVRMLAction SoToVRMLAction and SoToVRML2Action SoToVRML2Action SoToVRML2Action , are applied in the same manner as any other action. They convert an Open Inventor scene graph to a VRML 1.0 format or VRML97 (X3D) format scene graph respectively.

Many options can be set. For instance, to keep unknown nodes, use the keepUnknownNodes() method. If shared geometry nodes in the input scene graph should be shared in the new scene graph, use the reuseGeometryNode() method. All these options must be set before applying the action.

As with other actions, the apply() method must be called on an Inventor scene graph.

The SoWriteAction SoWriteAction SoWriteAction action must be used to generate the VRML 1.0 (or 2.0) file. You must remember to specify the correct header string with the method SoOutput::setHeaderString() . You must also specify that the file is an ASCII file (the only storage mode available in VRML) with the method SoOutput::setBinary(FALSE) . The header strings should be:

#VRML V1.0 ascii

for VRML 1.0, and

#VRML V2.0 utf8

for VRML 2.0