Skip to documentation
DocumentationAll documentsEnglish

G-VAR(1)

NAME

g-var - convert BRL-CAD BOT geometry to an OpenGL vertex array mesh

On this page

SYNOPSIS

g-var [-v] [-y] [-f] [-s _scale_] [-o _out_file_] _database.g_ _object_

DESCRIPTION

g-var walks the named object in a BRL-CAD database.g file, collects every Bag of Triangles (bot(5)) primitive beneath it, and writes them to a compact binary vertex array format suitable for loading into an OpenGL renderer. Non-solid leaves and solids that are not BOTs are skipped with a warning.

The output begins with a header recording byte order, format version, the model title, and total mesh, vertex, and face counts, followed by per-mesh records of vertices, normals, and face indices. Vertex normals are read from the BOT when present and otherwise computed by averaging adjacent face normals. Output is written to out_file, or to standard output when no output file is given; on standard output the stream is set to binary mode.

OPTIONS

-v

Verbose mode. Report progress, mesh counts, and whether normals were found or computed on standard error.

-y

Rotate output -90 degrees about the X axis, converting from BRL-CAD’s Z-up (XYZ) coordinate system to a Y-up (XZY) system as used by many OpenGL scenes.

-f

Flip face normals. Reverses the vertex winding order of each face and the direction of the corresponding computed normals.

-s scale

Scale all output vertices by the given factor. The default is 0.001, which converts BRL-CAD’s millimeter units to meters.

-o out_file

Write the binary mesh to out_file instead of standard output.

-h, -?

Print a usage message and exit.

EXAMPLES

Example 1. Export a Y-up mesh for an OpenGL viewer
g-var -y -o havoc.mesh havoc.g havoc

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.

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, this uses mged(1) and its facetize command to convert other primitives into a single BOT, then exports that BOT at unit scale (no millimeter-to-meter conversion).

SEE ALSO

brlcad(1), mged(1), facetize(n), g-obj(1), g-stl(1), bot(5)

AUTHOR

Prasad Silva

This software is Copyright (c) 2002-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