See the 'drilling rig' example by Beau Brown in the case studies section as an example
of using the XGL import converter to move from SolidWorks to 3DS MAX.
Overview
This import converter reads in ASCII XGL formatted files as well as their ZGL compressed equivalents. Triangular mesh
data (with vertex normals and vertex uv texture coordinates), basic material
properties, embedded texture images and object hierarchy are imported from
the XML-style XGL file.
XGL is an ideal file format to export data from various supported 3D programs
(see below, primarily CAD packages) to an XGL viewing program, be it on a
local machine or across the Internet. XGL is also an ideal file format to
move data from these CAD packages into Okino's NuGraf Rendering System
software for viewing, visual editing and photo-realistic rendering.
The XGL file format is designed to represent 3D information for the purpose
of visualization. It attempts to capture all of the 3D information that can
be rendered by SGI's OpenGL rendering library. XGL uses XML 1.0 syntax, so it
is easy to write and be parsed. XGL is quickly becoming the ideal format for
transmitting 3D data over the Internet and enabling applications with complex
functionality, such as collaboration, configuration, and data association.
The XGL file format is defined and maintained by the XGL Consortium.
Products that Export XGL/ZGL Files
One of the key benefits of the XGL file format is the number of vendors who
export XGL files, primarily CAD software products.
Released product with XGL Export (at the time of writing):
The primary method to view XGL files is with the free XGL file viewer
distributed by RealityWave (www.realitywave.com).
RealityWave also provides XGL streaming capabily across the Internet using their VizStream WebKit.
Okino's NuGraf Rendering System is ideal for creating, importing, editing, and photo-realistic rendering of XGL objects. Both, NuGraf and PolyTrans, are fully capable of importing and exporting XGL files.
Limitations of the XGL File Format
XGL is an adequate, but not ideal 3D file format to translate scene data from
one program to another. It seems to have been written under the general
assumption that the exported data will be sent to a viewing program, and to a
lesser degree to another 3D program. As such, it is not a perfect file format
to move complete scene data from one program to another. The following lists
some of the limitations of the XGL file format when used as a mechanism to
move scene data between 3D software packages:
XGL file format is not the most ideal for converting 3D scenes with object
hierarchy. The main problem is that the "transform" tag does not allow for
non-uniform scaling or off-axis scaling to be defined for an objects
transformation node. This problem can be overcome by transferring the mesh
data in absolute world space coordinates (the transformation matrix is
embedded directly with the mesh vertices), but that does not allow for the
transfer of any pivoting information.
All mesh data must be turned into triangles.
Vertex color and UV tangent attributes for mesh vertices is not provided.
No naming of objects or null hierarchy nodes is possible.
All texture maps must be embedded within the XGL file. Texture filename
references are not provided.
Transformations with off-axis scaling or non-uniform scaling are not
accomodated.
Only directional light sources are provided. Point and spot lights are not.
Otherwise, XGL is an adequate file format for moving general purposes
triangular-based mesh data between 3D programs, or a 3D program and a
destination viewing program, with associated color and texture attributes,
some lighting and hierarchy.
WEB Site References
The XGL file format specification is contained on the WEB site
www.xglspec.org.
These options control how the imported geometry and material data is
processed before it is sent to the NuGraf/PolyTrans internal database.
Compute averaged normals
If this checkbox is enabled then new vertex normals will be computed for a
polygon if it does not have any vertex normals already. The
Import Vertex Normals checkbox must
also be enabled. The smoothing criterion is based on the angle between
abutting polygons; common smoothed vertex normals will be computed if the
angle between their geometric surfaces normals is less than the angle
specified on the dialog box (which defaults to 45 degrees). Note that the
vertices will be welded together prior to the smoothing algorithm being
executed.
Ignore Geometry Back-face Culling Flags
The XGL file format allows back face culling to be enabled on a per-polygon
basis. Culling allows polygon faces, which are pointing towards the camera or
away from the camera, to be remove implicitly from a scene during the
rendering process. This importer turns these per-polygon flags into a more
general per-object culling mode. If this checkbox is enabled then the culling
option from the XGL file is ignored.
Flip Model so that Y Axis is Up
If this checkbox is enabled then the model will be reoriented so that the Up
axis of the model will be aligned with the positive Y axis (which is used by
the converter) instead of the positive Z axis as used by some XGL files (such
as XGL files exported from the Solid Edge CAD modeling program).
Report Statistics About the XGL File Contents
If this checkbox is check-marked then parsing statistics will be displayed in
the message window after the XGL file has been imported.
Hierarchy Optimizer # 1, Hierarchy Optimizer # 2
These options provide methods to remove redundant hierarchy nodes from the
imported XGL file. Optimzier # 1 removes runs of empty folders, as well as
folders with no children. Optimizer # 2 is simpler, deleting empty folders
which only have 1 geometry object in them.
Shading Coefficient Modifcations
See below for a longer explanation of these combo boxes. In general, these
combo boxes allow the key material attributes to be tweaked during import.
This might be necessary, for example, if the imported objects appear too
ambient, or too luminous.
Geometry Automatic Rescaling Method
This combo box provides access to a useful mechanism which automatically
rescales the imported mesh geometry to a size best needed by other 3D
software packages. For example, a Solid Edge test file imported into this
converter had a size of only 0.05 units across (probably due to the implicit
modeling units used within the Solid Edge program); this model was much too
small (in extents) for other 3D programs to manipulate properly. To overcome
these scaling issues, this combo box can be used to automatically resize any
imported model data to a useful size, such as scaled to easily fit inside a
box of 2x2x2 raw working units (which is the default). The various options
are described as follows:
Do Not Resize the Scene
No resizing is done to the imported data.
Resize to 1x1x1 units
Resize to 2x2x2 units
The model data is automatically scaled up in size, or scaled down in size so
that its worldspace extents fits inside a 1x1x1 or 2x2x2 sized unit cube. The
latter is the default.
Resize to User Defined Absolute Size
The model data is automatically scaled up in size, or scaled down in size so
that its worldspace extents fit inside a cube whose size is user defined by
the type-in value shown on the dialog box. For example, if you enter the
value 20 then the imported data will be resized so that its maximum extent in
one or more dimensions is 20 units.
Scale Larger by User Defined Factor
Scale Smaller by User Defined Factor
These options allow the imported model data to be scaled larger or scaled
smaller by an absolute number. For example, if you select the larger option
and enter 10 into the type-in box, then the imported model will be scaled 10
times larger during the import process.
Selective Loading
These options allow specific portions of the XGL file to be imported.
Vertex Normals
If checkmarked, vertex normals will be imported for each object. XGL files
contain vertex normals which are used to make the imported object appear
smooth when shaded.
Lights
If checkmarked, directional lights will be imported with an associated color.
Ambient Light
If checkmarked, the ambient light source color will be imported and used to
replace the color of the current ambient light source.
Vertex Texture Coordinates
If checkmarked, vertex uv texture coordinates will be imported for each
object. These texture coordinates (if provided) are necessary in order for 2d
bitmap textures to be applied to objects.
Object Hierarchy
If checkmarked, the object hierarchy will be recreated from the embbed XML
tags of the XGL file.
Background Color
If checkmarked, the background color will be imported from the XGL file.
Extract Embedded Texture Images
Since XGL files are designed for transmitting 3D data to a viewing program,
all texture maps are embedded directly within the XGL file (no texture file
references are possible). This converter extracts these embedded images and
stores them on disk as TIFF files to the directory specified by the Save
Embedded Texture Images to this Directory option described below.
Display texture on-screen during loading
If this checkbox is enabled then the extracted bitmap images will be
displayed in a window while the file is being loaded.
Confirm overwrites when saving out texture images
If this checkbox is enabled then the program will first confirm whether a
texture file (which is being extracted from the XGL file and saved to disk)
should be overwritten. If the user does not want the file, which already
exists on disk, to be overwritten then the converter will skip it. If this
checkbox is not enabled then any potential file overwrites will not be
confirmed.
Save Embedded Texture Images to this Directory
These radio buttons define the directory where the extracted TIFF images will
be saved to disk.
Directory where this program was executed from
The extracted TIFF images will be saved in the directory where this program
began execution (which is usually the same as where this program is located
on disk). This is not a preferrable option since this directory will
eventually become cluttered with TIFF images extracted from XGL files.
Directory where XGL input files are located
The extracted TIFF images will be saved in the same directory where the XGL
input file was read from. This is the default but in general you should store
the TIFF files in a common textures directory.
Specific (+Browse button)
The extracted TIFF images will be saved in the directory indicated by the
type-in edit box. If no directory is shown, or you want to change the current
output directory, then the Browse button can be pressed to select the desired
destination directory.
Shading Parameter Modification Combo Boxes
These combo boxes provide hands-on control over how imported material shading parameters should be modified so that the imported model can be rendered nicely in a photo-realistic rendering program. All too often the imported model appears "too ambient" or "too diffuse" resulting in rendered images that are washed out or with no gradual shading effects visible. The two combo boxes and the single numeric type-in box provide you good control over the ambient, diffuse, specular, luminous and reflection shading coefficients imported into PolyTrans/NuGraf, as well as the opacity of the material, its index of refraction (IOR) and Phong shininess value.
The first drop-down combo box selects which of these shading parameters you want to modify. Each shading coefficient has its own operation which can be selected (the second combo box) and an optional numeric type-in value (the third data entry text input). The following describes the various shading parameters that can be controlled:
Ambient Coefficient: This controls the amount of color reflected from an object based on the ambient light in a scene. A good default value is 0.1 through to 0.3 and ideally ranges from 0.0 to 1.0. Some programs have an ambient shading coefficient parameter (NuGraf/PolyTrans, Electric Image, etc) while others do not (3D Studio). If an export file format does not support an ambient shading coefficient then this value will be multiplied into the ambient shading color itself.
Diffuse Coefficient: This controls the amount of color reflected from an object based on the direct light shining on it. A good default value is 0.4 and ideally ranges from 0.0 to 1.0. Some programs have a diffuse shading coefficient parameter (NuGraf/PolyTrans, Electric Image, etc) while others do not (3D Studio). If an export file format does not support a diffuse shading coefficient then this value will be multiplied into the diffuse shading color itself.
Specular Coefficient: This controls the intensity of the highlight color on an object. A good default value is 0.7 and ideally ranges from 0.0 to 5.0. If an export file format does not support a specular shading coefficient then this value will be multiplied into the specular shading color itself.
Luminous Coefficient: This controls how much color is added directly to an object, irrespective of any light which shines on it (the higher the value, the more the object will appear to glow). In general you should keep this value at 0. If an export file format does not support a luminous shading coefficient then this value will be multiplied into the luminous shading color itself.
Opacity: This is the inverse of transparency. 0.0 will make the object fully transparent, while at 1.0 the object will be fully opaque.
Phong Shininess: This controls the width of the specular highlight seen on an object. An ideal range is 6 (very wide) to 300 (very narrow). The default is 32.
For each material shading parameter, several actions can be performed on it during the import process:
Do Not Import: The shading parameter is not imported at all. No value is imported nor sent to PolyTrans/NuGraf. Thus, the default material shading parameter value (as set inside PolyTrans/NuGraf) will be used instead.
Import Unchanged: The shading parameter is imported as is, with no change.
Set and Use Default: The shading parameter is set to some good default value (as determined by the import converter). This default value will be shown in the type-in box.
Set to Specific Value: The imported shading parameter will be overridden with the user specified value of the numeric type-in box.
Import and Crop by: The shading parameter is imported and will remain unchanged if it is less than the numeric type-in value shown on the dialog box. If it is greater, then the imported value will be clamped to be no greater than the numeric type-in value. This is a good operation, for example, if you do not wish for the ambient shading coefficient to be greater than 0.3.
Import and Scale by: The shading parameter is imported and multiplied by the numeric type-in value shown on the dialog box
Normalize Color and Coefficient: This option only applies for the ambient, diffuse, specular and luminous shading coefficients and their respective RGB colors. This option is a hybrid approach which tries to automatically guess at a proper shading coefficient value given the raw (and corresponding) color imported from the file. As mentioned, the shading coefficient is needed to create nice looking (nicely shaded) images in a photo-realistic rendering program. If this option is chosen, then the specific shading coefficient will be derived directly from the relative intensity of the imported color which corresponds to this shading coefficient (diffuse color for diffuse shading coefficient etc.). For example, if the imported diffuse color is (0.4, 0, 0), which is 40% of full-bright red, then the diffuse shading coefficient will be set to 0.4 and the diffuse color will be modified to be (1, 0, 0). When the new color (1,0,0) and the new shading coefficient (0.4) are multiplied together, it results in the original color imported from the file (0.4, 0, 0). In general you may wish to use the Set and Use Default option to get good rendered results.