G-VAR(1)

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

πŸ’… 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 -90 degrees 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 πŸ’«
  • -s scale β€” scales all output vertices by the given factor. the default is 0.001, which converts BRL-CAD's millimeter units to meters. metric system ate, ngl πŸ“
  • -o out_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 πŸ‘‘βœ¨


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