A file parser library for Terragen TER terrain files.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
.gitattributes
LICENSE
README.md
documentation.lisp
package.lisp
terrable.asd
terrable.lisp

README.md

About Terrable

Terrable implements a parser for the Terragen terrain file format (.TER). You can find a format reference here.

How To

To parse a file, you can pass a file, vector, or fast-io buffer to read-terrain.

(terrable:read-terrain #p"~/heightmap.ter")

If everything goes well, you should have a fresh terrain instance with width, height, scale, curve-radius, curve-mode, height-base, height-scale, and data slots all filled out for you. The data is parsed as a static-vector, meaning it is directly passable to C libraries like OpenGL for further processing.

(gl:tex-image-2d :texture-2d 0 :R16I (terrable:width *) (terrable:height *) 0 :RED-INTEGER :SHORT
                 (static-vectors:static-vector-pointer (terrable:data *)))

And that's it. Note that finalizers are used to automatically deallocate the data array when the terrain instance is garbage collected. If you want to manually free the terrain data instantly, you can use free-terrain.

(terrable:free-terrain **)

Finally, if you would like to generate terrain files, you can simply call write-terrain on a complete Terrain object. It'll write out all known chunks to the file, even if they might be superfluous.