g-obj [-h|-?] [-m] [-v] [-i] [-u] [-x rt_debug] [-X nmg_debug]
[-a abs_tol] [-r rel_tol] [-n norm_tol] [-D dist_tol]
[-P ncpu] [-e error_file] [-o output.obj] database.g object(s)
G-OBJ(1)
NAME
g-obj - convert BRL-CAD geometry to a Wavefront OBJ file
On this page
SYNOPSIS
DESCRIPTION
g-obj converts the specified object(s) from a BRL-CAD database.g file to the Wavefront OBJ format. Each region is tessellated into an NMG, evaluated, and triangulated, so the resulting OBJ contains only triangular faces.
OBJ output is written to output.obj when the -o option is supplied; otherwise it is written to standard output. Coordinates are emitted in millimeters by default, or in inches with -i.
When writing to a named OBJ file, g-obj also writes a companion .mtl material file with the same base name. The material file preserves effective BRL-CAD colors (colors set on geometry, inherited from combinations, or supplied by region color-id mappings). If OBJ output goes to standard output no companion .mtl file can be created, and BRL-CAD colors are therefore not exported.
See g-stl(1) and g-ply(1) for related polygonal exporters.
OPTIONS
- -h, -?
-
Print a usage summary and exit.
- -i
-
Write output coordinates in inches instead of the default millimeters.
- -m
-
Emit
usemtlstatements. When a companion .mtl file is written, the generated material names preserve the BRL-CAD GIFT material id, LOS, and aircode, with a color suffix appended when needed to distinguish different RGB assignments. - -u
-
Write vertex normals (
vn) and reference them from the face records. - -v
-
Verbose output, reporting progress for each region processed.
- -a abs_tol
-
Set the absolute tessellation tolerance, the maximum allowable distance (in millimeters) between a tessellated face and the true surface. Setting this clears the relative tolerance.
- -r rel_tol
-
Set the relative tessellation tolerance as a fraction of the bounding box size. The default is 0.01.
- -n norm_tol
-
Set the surface-normal tessellation tolerance, the maximum allowable angle (in degrees) between adjacent face normals. Setting this clears the relative tolerance.
- -D dist_tol
-
Set the calculational distance tolerance, in millimeters. Vertices closer together than this distance are treated as the same vertex.
- -P ncpu
-
Request use of ncpu processors during processing.
- -e error_file
-
Write diagnostics to error_file. By default diagnostics go to standard error.
- -o output.obj
-
Write OBJ output to output.obj, and a companion .mtl file with the same base name.
- -x rt_debug
-
Set the librt debug flags to the given hexadecimal value.
- -X nmg_debug
-
Set the libnmg debug flags to the given hexadecimal value.
EXAMPLES
g-obj -o havoc.obj havoc.g havoc
Tessellate the havoc region from havoc.g and write havoc.obj along with a companion havoc.mtl that captures the model’s BRL-CAD colors.
g-obj -m -u -a 0.5 -o tank.obj tank.g turret hull
Convert the turret and hull objects with a 0.5 mm absolute
tessellation tolerance, emitting vertex normals and usemtl statements
whose names encode GIFT material, LOS, and aircode values.
g-obj -i sample.g sample_object > sample.obj
Write the geometry in inches to standard output, redirected into sample.obj. Because no named OBJ file is opened, no companion .mtl file is produced and colors are not exported.
SEE ALSO
brlcad(1), g-stl(1), g-ply(1), obj-g(1), mged(1)
AUTHOR
BRL-CAD Team
COPYRIGHT
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