Skip to documentation
DocumentationAll documentsEnglish

G-X3D(1)

NAME

g-x3d - convert BRL-CAD geometry to an X3D faceted model

On this page

SYNOPSIS

g-x3d [-v] [-d _calc_dist_tol_] [-a _abs_tess_tol_] [-r _rel_tess_tol_] [-n _norm_tess_tol_] [-u _units_] [-P _ncpu_] [-x _librt_debug_] [-X _nmg_debug_] [-o _out.x3d_] _model.g_ _object(s)_

DESCRIPTION

g-x3d evaluates the Boolean operations defined by the named regions in a BRL-CAD database (.g) file, tessellates the resulting geometry into NMG faceted form, and writes it as an X3D (Extensible 3D) scene. Each non-light-source region is emitted as a separate X3D Shape with an IndexedFaceSet, and region colors (or default per-thousand region-id colors) are written as X3D Material nodes. The output is written to the file named with -o, or to standard output otherwise.

g-x3d is a modified version of g-vrml(1) and shares its shader and material handling; use it when an XML-based X3D scene is preferred over classic VRML.

OPTIONS

-v

Enable verbose output, reporting region conversion progress on standard error.

-d calc_dist_tol

Calculational distance tolerance, in millimeters, used to distinguish neighboring vertices. The default is 0.0005.

-a abs_tess_tol

Absolute tessellation tolerance, in millimeters (the maximum chord error permitted between an approximating facet and the true surface). Setting this disables the relative tolerance.

-r rel_tess_tol

Relative tessellation tolerance, expressed as a fraction of the bounding box of each solid. The default is 0.01.

-n norm_tess_tol

Surface normal tessellation tolerance, in degrees (the maximum angle between adjacent facet normals). Setting this disables the relative tolerance.

-u units

Units for coordinates in the resulting X3D file. The default is mm. Any units name understood by BRL-CAD (e.g. mm, cm, m, in, ft) is accepted.

-P ncpu

Number of processors to use during tessellation. The default is 1.

-x librt_debug

Set the librt debug flags to the given hexadecimal value. See raytrace.h for the bit definitions.

-X nmg_debug

Set the NMG debug flags to the given hexadecimal value. See nmg.h for the bit definitions.

-o out.x3d

Write the X3D output to the named file instead of standard output.

-h, -?

Print a usage message and exit.

EXAMPLES

Example 1. Convert selected regions to an X3D file
g-x3d -o havoc.x3d -u m -r 0.005 havoc.g havoc

Tessellates the region tree rooted at object havoc in havoc.g using a relative tolerance of 0.005, scales the output to meters, and writes the resulting X3D scene to havoc.x3d for viewing in a web browser or X3D viewer.

Example 2. Stream output through a pipeline
g-x3d -P 4 sample.g comp1 comp2 > parts.x3d

Converts two named objects using four processors and redirects the X3D scene to parts.x3d. Because output defaults to standard output, g-x3d can be chained with other tools in a pipeline.

SEE ALSO

brlcad(1), g-vrml(1), mged(1)

AUTHOR

BRL-CAD Team

This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.

BUG REPORTS

Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org