Tools to work with Quake game assets in R. Useful for messing with Quake and Quake II game textures. Can read, write, create and export bitmap images in WAL file format and related texture formats. Includes tools to extract WAD and PAK files. Can read Quake and Quake II models in MDL and MD2 formats and allows for exporting to standard mesh formats.
The WAL file format is an old format for storing indexed bitmap images, used as textures in idtech1 and idtech2 games. A single WAL file contains four mipmaps of the same image. WAL format files are indexed but do not contain the palette needed to reconstruct the image. You can use your own palette, or use the Q1 or Q2 palettes that come with this package.
Note that whe WAL textures are stored inside Quake pak file archives (baseq2/pak0.pak
), so you will not see any WAL files in your Quake 2 directory unless you extracted them for mapping or modding. For Quake I, textures in a very similar format that is also supported are stored directly in the BSP level files (which are inside Id1/PAK0.PAK
), or in WAD files.
Managing WAL images:
Related Formats and Features:
I recommend to install the stable wal version from CRAN. In your R session:
install.packages("wal");
To install the development version (no complaints or bug reports, please):
install.packages("devtools");
devtools::install_github('dfsp-spirit/wal')
wal_file = "~/path/to/q2_pak0_extracted/textures/e1u2/basic1_7.wal";
wal = wal::read.wal(wal_file);
plot(wal); # S3 plot method for 'wal' instances, uses preview palette. Alternatively:
wal::plotwal.mipmap(wal, mip_level = 1L, apply_palette = wal::pal_q2()); # Plot with full control.
wal::wal.export.to.jpeg(wal, "~/mytex.jpg", palette = wal::pal_q1(), quality = 0.95);
wal::wal.export.to.png(wal, "~/mytex.png"); # palette defaults to pal_q2().
jpeg_file = "~/mytextures/bricks_256x256.jpg";
wal = img.to.wal(jpeg::readJPEG(jpeg_file));
wal::writeWAL("~/myfile.wal", wal);
For more information, read the detailed vignette that comes with the package. Examples for working with models and archives can be found in the unit tests.
Documentation on the WAL format seems sparse. I did not find any official spec so I used the Quake 2 source code to learn about the format. Relevant files are:
R_LoadWal
miptex_s
struct in qfiles.h and at the image_s
struct in r_local.hAdd the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.