G-VAR(1)
π g-var β the BRL-CAD to OpenGL glow-up π
okay so bestie, you've got a BRL-CAD database full of geometry and an OpenGL renderer that wants a nice tidy vertex array meshβ¦ and this little icon right here, g-var, is the matchmaker β¨ (manual section 1, in case you're keeping track π)
β¨ NAME β¨
g-var β converts BRL-CAD BOT geometry into an OpenGL vertex array mesh. literally its whole personality π¦
πΈ SYNOPSIS πΈ
g-var [-v] [-y] [-f] [-s scale] [-o out_file] database.g object
that's it. that's the whole vibe check π
π DESCRIPTION π
so g-var takes a little stroll through the object you named inside your BRL-CAD database.g file, scoops up every Bag of Triangles primitive β that's bot(5), iykyk β hanging out underneath it, and writes them all out into a compact binary vertex array format that's ready to load straight into an OpenGL renderer. slay π
not every leaf gets an invite to the party tho: non-solid leaves and solids that aren't BOTs get skipped, with a warning so you're not left wondering where your geometry went π
the output kicks off with a header that records the byte order, the format version, the model title, and the total mesh, vertex, and face counts β very organized, very main character energy β after that come the per-mesh records: vertices, normals, and face indices. and the normals? vertex normals get read straight from the BOT when they're present, and otherwise they get computed by averaging the adjacent face normals. either way, covered π«Ά
output goes to out_file, or to standard output if you didn't give an output file β and when it's going to standard output, the stream gets set to binary mode. important detail, no cap π₯
π OPTIONS π
-vβ verbose mode, bestie. it reports progress, mesh counts, and whether normals were found or computed, all on standard error. it's giving "tell me everything" π-yβ rotates the output-90degrees about the X axis, converting from BRL-CAD's Z-up (XYZ) coordinate system to a Y-up (XZY) system, which is what lots of OpenGL scenes are living in π-fβ flips the face normals. reverses the vertex winding order of each face and the direction of the corresponding computed normals. flip it, reverse it, periodt π«-sscale β scales all output vertices by the given factor. the default is0.001, which converts BRL-CAD's millimeter units to meters. metric system ate, ngl π-oout_file β writes the binary mesh to out_file instead of standard output. file girlies rise π-h,-?β prints a usage message and exits. the polite escape hatch π§
π¦ EXAMPLES π¦
β¨ Example 1. Export a Y-up mesh for an OpenGL viewer β¨
g-var -y -o havoc.mesh havoc.g havoc
this one collects all BOT primitives under the havoc combination in havoc.g, rotates them into a Y-up coordinate frame, and writes the result to havoc.mesh, ready for loading by an OpenGL application. chef's kiss π
β¨ Example 2. Tessellate non-BOT geometry first, then export β¨
mged -c moss.g "facetize -o moss.bot all.g; q"
g-var -s 1.0 -o moss.mesh moss.g moss.bot
because g-var only exports BOT primitives (it's picky, we respect it π
), this uses mged(1) and its facetize command to convert other primitives into a single BOT, then exports that BOT at unit scale β so no millimeter-to-meter conversion here, -s 1.0 said "keep it as is" π
π SEE ALSO π
brlcad(1), mged(1), facetize(n), g-obj(1), g-stl(1), bot(5)
go read those too, they're the friend group πΈ
π AUTHOR π
Prasad Silva β the genius behind the vibe πβ¨
π COPYRIGHT π
This software is Copyright (c) 2002-2026 by the United States Government as represented by U.S. Army Research Laboratory. (yes, the whole range, 2002 through 2026, we love a long-term commitment π«Ά)
π BUG REPORTS π
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org β tell them everything, they want to hear it, fr fr ππ§
okay bye bestie!! this page is from the BRL-CAD collection, and yes β it's G-VAR(1) all the way down π
β¨π go export something gorgeous π¦π
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms