G-OBJ(1)

πŸ“¦
version 7.44.0 Β· 2 versions
, in nixpkgs unstable

πŸ’… G-OBJ(1) β€” bestie's guide to the BRL-CAD OBJ exporter ✨

okay so real talk, this is a page from the BRL-CAD manual set, and it's all about g-obj, the little icon that takes your gorgeous BRL-CAD geometry and drops it into Wavefront OBJ format. no cap, it's a whole vibe.


✨ NAME ✨

g-obj β€” convert BRL-CAD geometry to a Wavefront OBJ file πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

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)

like, that's the whole shape of the thing, bestie. flags first, then your database.g, then whichever object(s) you're obsessed with πŸ’–


🌸 DESCRIPTION 🌸

g-obj converts the specified object(s) from a BRL-CAD database.g file over to the Wavefront OBJ format. literally its whole job, and it ate πŸ’…

so here's the tea on how it works: each region gets tessellated into an NMG, evaluated, and triangulated β€” which means the resulting OBJ contains only triangular faces. no quads, no n-gons, no chaos. just triangles, periodt πŸ”Ί

OBJ output goes to output.obj when you pass the -o option. if you don't? it goes to standard output instead. and the coordinates are emitted in millimeters by default, or in inches with -i.

🫢 little heads-up that's actually kind of important: when you're writing to a named OBJ file, g-obj also writes a companion .mtl material file with the same base name. that material file preserves effective BRL-CAD colors β€” and by "effective" we mean colors set on geometry, colors inherited from combinations, or colors supplied by region color-id mappings. all of it, slay 🌈

but if the OBJ output goes to standard output, then no companion .mtl file can be created β€” and therefore BRL-CAD colors are not exported. 😭 that's just how it is, bestie.

also go look at g-stl(1) and g-ply(1) for related polygonal exporters, they're the sibling energy πŸ‘‘


πŸ”₯ OPTIONS πŸ”₯

okay this is the part where we go through literally every single flag, so buckle up πŸŽ€

  • -h, -? β€” print a usage summary and exit. the "wait, how does this work again" button πŸ™ˆ
  • -i β€” write output coordinates in inches instead of the default millimeters.
  • -m β€” emit usemtl statements. and 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. iconic behavior honestly πŸ‘‘
  • -u β€” write vertex normals (vn) and reference them from the face records.
  • -v β€” verbose output, reporting progress for each region processed. perfect for when you need to see it working ✨
  • -a abs_tol β€” set the absolute tessellation tolerance: the maximum allowable distance (in millimeters) between a tessellated face and the true surface. note that 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 too, just so you know.
  • -D dist_tol β€” set the calculational distance tolerance, in millimeters. vertices closer together than this distance are treated as the same vertex. two-for-one deal fr fr.
  • -P ncpu β€” request use of ncpu processors during processing. multiprocessor main character energy πŸ”₯
  • -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. the one that unlocks colors πŸ’–
  • -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 🌟

πŸ’œ Example 1. Export a region to OBJ with materials

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. chef's kiss πŸŽ€

πŸ’œ Example 2. Export with vertex normals and material codes

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. look at her go πŸ”₯

πŸ’œ Example 3. Pipe OBJ output in inches to standard output

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. sad but true 😭


πŸ¦‹ SEE ALSO πŸ¦‹

brlcad(1), g-stl(1), g-ply(1), obj-g(1), mged(1)

(the whole friend group, honestly πŸ’…)


🧚 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

found something cursed? tell the devs, don't suffer in silence bestie 🫢

and that's the whole page! brought to you by BRL-CAD (the G-OBJ(1) manual, no less), with the copyright window running 1989-2026 β€” so like, she's been serving since before most of us were born πŸ‘‘πŸ’–

πŸ“¦ where this page comes from