This collection of batch scripts and commands is used to preprocess and convert Quake 2 maps, including converting .bsp
and .md2
files, normalizing vertices, and compiling hinted maps on both Windows and macOS platforms.
The provided code consists of a series of batch scripts and commands designed to preprocess and convert Quake 2 maps, including Windows and macOS versions. These scripts handle tasks such as converting .bsp
and .md2
files, normalizing vertices, and compiling hinted maps, all essential steps in preparing Quake 2 maps for use.
Z:\Downloads\netradiant-custom-win64\netradiant-custom-20190705\mbspc.exe -bsp2map Z:\.quake2\baseq2\pak0.pak\maps\base1.bsp
for /r %%v in (*.bsp) do (
cd "%%~dpv"
"Z:\planet_quake_data\tools\mbspc.exe" -bsp2map "%%~nv.bsp")
for /r %%v in (*.md2) do "Z:\planet_quake_data\tools\qwalk\modelconv.exe" -i "%%v" "%%~dpv%%~nv.md3"
/Applications/GtkRadiant.app/Contents/Resources/install/q3map2 -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq3 -convert -format map ~/planet_quake_data/quake3-baseq3/pak0.pk3dir/maps/q3tourney6.bsp
for i in $(find "$(pwd -P)" -iname '*.bsp'); \
do if [ ! -f "${i%.*}.map" ]; \
then pushd $(dirname "$i"); \
/Users/briancullinan/netradiant-custom/tools/mbspc/build/macosx/mbspc -bsp2map $(basename "$i"); \
popd; \
fi; \
done;
# normalize brushes verteces using q3map2
for i in $(find "$(pwd -P)" -iname '*.bsp'); \
do if [ ! -f "${i%.*}_converted.map" ]; \
then pushd $(dirname "$i"); \
/Applications/NetRadiant.app/Contents/MacOS/install/q3map2.bin -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -convert -format map -readmap $(basename "${i%.*}.map")
popd; \
fi; \
done;
# run the entire process for a single map
i="/Users/briancullinan/planet_quake_data/quake2-baseq2/pak0.pk3dir/maps/base2.map"; \
pushd $(dirname "$i"); \
/Users/briancullinan/planet_quake_data/tools/mbspc/build/macosx/mbspc -bsp2map $(basename "${i%.*}.bsp"); \
/Applications/NetRadiant.app/Contents/MacOS/install/q3map2.bin -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -convert -format map -readmap $(basename "${i%.*}.map");
# convert acting on nicely formated verteces
pushd /Users/briancullinan/jupyter_ops/; \
npm run import "convert quake 2 map" -- "['${i%.*}_converted.map']"; \
npm run import "split map hints" -- "['${i%.*}_converted.map']";
# compile hinted maps
/Applications/GtkRadiant.app/Contents/Resources/install/q3map2 -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${i%.*}-a.map"; \
/Applications/GtkRadiant.app/Contents/Resources/install/q3map2 -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${i%.*}-b.map"; \
/Applications/GtkRadiant.app/Contents/Resources/install/q3map2 -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${i%.*}-c.map";
/Applications/NetRadiant.app/Contents/MacOS/install/q3map2.bin -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${i%.*}_converted.map"
popd
popd
bash
#!/bin/bash
# Define the path to the mbspc and q3map2 executables
MBSPC_EXECUTABLE="Z:\planet_quake_data\tools\mbspc.exe"
Q3MAP2_EXECUTABLE_MAC="Applications/NetRadiant.app/Contents/MacOS/install/q3map2.bin"
Q3MAP2_EXECUTABLE_LINUX="/usr/local/bin/q3map2"
Q3MAP2_EXECUTABLE_WINDOWS="Applications/GtkRadiant.app/Contents/Resources/install/q3map2"
# Define the path to the input and output directories
INPUT_DIR="Z:\.quake2\baseq2\pak0.pak\maps"
OUTPUT_DIR="Z:\.quake2\baseq2\pak0.pak\maps"
# Convert BSP files to MAP files
convert_bsp_to_map() {
local bsp_file=$1
local output_file=${bsp_file%.bsp}.map
if [! -f "$output_file" ]; then
"${MBSPC_EXECUTABLE}" -bsp2map "$bsp_file"
fi
}
# Normalize brushes vertices using q3map2
normalize_brushes() {
local bsp_file=$1
local output_file=${bsp_file%.bsp}_converted.map
if [! -f "$output_file" ]; then
"${Q3MAP2_EXECUTABLE_MAC}" -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -convert -format map -readmap "${output_file%.map}"
fi
}
# Compile hinted maps
compile_hinted_maps() {
local map_file=$1
"${Q3MAP2_EXECUTABLE_MAC}" -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${map_file}-a.map"
"${Q3MAP2_EXECUTABLE_MAC}" -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${map_file}-b.map"
"${Q3MAP2_EXECUTABLE_MAC}" -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${map_file}-c.map"
}
# Main script
for bsp_file in $(find "$INPUT_DIR" -iname '*.bsp'); do
convert_bsp_to_map "$bsp_file"
normalize_brushes "$bsp_file"
done
# Run the entire process for a single map
map_file="/Users/briancullinan/planet_quake_data/quake2-baseq2/pak0.pk3dir/maps/base2.map"
convert_bsp_to_map "${map_file%.map}.bsp"
normalize_brushes "${map_file%.map}.bsp"
compile_hinted_maps "${map_file%.map}"
Code Breakdown
The provided code is a collection of batch scripts and commands used to preprocess and convert Quake 2 maps. It appears to be written for both Windows and macOS platforms.
mbspc.exe
to convert .bsp
files:
for /r %%v in (*.bsp) do (
cd "%%~dpv"
"Z:\planet_quake_data\tools\mbspc.exe" -bsp2map "%%~nv.bsp")
This loop iterates over all `.bsp` files in the current directory and its subdirectories.
2. The second command uses `modelconv.exe` to convert `.md2` files:
```bash
for /r %%v in (*.md2) do "Z:\planet_quake_data\tools\qwalk\modelconv.exe" -i "%%v" "%%~dpv%%~nv.md3"
This loop iterates over all .md2
files in the current directory and its subdirectories.
q3map2
to convert .bsp
files:
/Applications/GtkRadiant.app/Contents/Resources/install/q3map2 -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -convert -format map ~/planet_quake_data/quake3-baseq3/pak0.pk3dir/maps/q3tourney6.bsp
This command converts a single `.bsp` file.
4. The fourth and fifth commands use `q3map2` to convert `.bsp` files and normalize their vertices:
```bash
for i in $(find "$(pwd -P)" -iname '*.bsp'); \
do if [! -f "${i%.*}.map" ]; \
then pushd $(dirname "$i"); \
/Users/briancullinan/netradiant-custom/tools/mbspc/build/macosx/mbspc -bsp2map $(basename "$i"); \
popd; \
fi; \
done;
# normalize brushes verteces using q3map2
for i in $(find "$(pwd -P)" -iname '*.bsp'); \
do if [! -f "${i%.*}_converted.map" ]; \
then pushd $(dirname "$i"); \
/Applications/NetRadiant.app/Contents/MacOS/install/q3map2.bin -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -convert -format map -readmap $(basename "${i%.*}.map")
popd; \
fi; \
done;
These loops iterate over all .bsp
files in the current directory and its subdirectories, convert them, and then normalize their vertices.
The remaining commands are for macOS and appear to be performing similar operations to the Windows commands:
mbspc
to convert .bsp
files:
i="/Users/briancullinan/planet_quake_data/quake2-baseq2/pak0.pk3dir/maps/base2.map";
pushd $(dirname "$i");
/Users/briancullinan/planet_quake_data/tools/mbspc/build/macosx/mbspc -bsp2map $(basename "${i%.*}.bsp"); \
This command converts a single `.bsp` file.
2. The second command uses `q3map2` to convert `.bsp` files:
```bash
/Applications/GtkRadiant.app/Contents/MacOS/install/q3map2.bin -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -convert -format map -readmap $(basename "${i%.*}.map");
This command converts a single .bsp
file.
npm
to import and process the converted map:
pushd /Users/briancullinan/jupyter_ops/;
npm run import "convert quake 2 map" -- "['${i%.}_converted.map']";
npm run import "split map hints" -- "['${i%.}_converted.map']";
This command imports and processes the converted map.
4. The final command uses `q3map2` to compile hinted maps:
```bash
/Applications/GtkRadiant.app/Contents/Resources/install/q3map2 -game quake3 -fs_basepath /Applications/ioquake3/ -fs_game baseq2 -meta _keeplights "${i%.*}-a.map";
This command compiles a hinted map.