Quake (1996 game) bsp import script

Update: I just updated this addon to work with Blender 2.80. You can find the source and recent readme on the github page here: https://github.com/andyp123/blender_io_mesh_bsp

The latest release supports BSP2, importing of lights for eevee and cycles, camera setup based on info_player_start and info_intermission entities, much better material setup, supporting masked emission and transparency and also imports files MUCH faster.

I also made a companion add-on for importing Quake .map files, which can be found here.

v0.0.7 (Blender 2.79) : Download
v1.1 (Blender 2.80) : Download


Original Post (minus pasted readme):

I’m not sure how many people here will want to import level geometry and textures from a 17 year old game, even if it is pretty much the best game ever, but I thought I would upload it just because there might be someone, or it might be useful for someone who wants to write their own mesh importer for some other game etc.

The script takes any valid Quake 1 BSP file and loads each model as a separate mesh. Quake stored textures in each .bsp file, so the textures are also loaded as materials and applied to the meshes. There are a couple of simple import options to disable creation of materials, load only the main level geometry and also a scale parameter.

Pics:



I forgot to mention that if anyone actually wants to try this script, you can find level bsp files on this site: http://www.quaddicted.com/ in the maps section. The original levels are contained in Quake/ID1/pak0.pak and pak1.pak, and although extracting them is fairly trivial, I did not add any tool to do this in the importer. There are tools available to extract the files from .pak files for Windows, though I’m not sure if such a tool exists for Linux. There are lots of tools available here: https://www.quaddicted.com/files/tools/ (hint: try pakscape, pak explorer, qped2 etc.)

not sure what to do with it, but I think it’s great. Thanks a lot for your contribution! Quake1 was also my favourite fps game ever.

Man this is one of the coolest thing ive seen in Blender

I totally love it! I’ll “play” with it surely… just one question: it would not work with Quake 3 BSPs, doesn’t it?

Thanks!!

@Mr_Flamey: Nice!

Would you be able to fix Quake 3 map exporter by chance?

Sorry, it only works with Quake 1 bsps. I played, but was not a big fan of Quake 3 to be honest, since I really enjoyed the single player modes in the first two games, and played Quake 2 multiplayer, rocket arena and ctf way more than I played Q3. Despite many people complaining that Q2 was too slow, I enjoyed it a lot.

motorstep: Sorry, I just wanted to write a script that would import Quake bsps and don’t have any plans to expand it. I think there already is a Q3 map export script though, so have a look and see if it still exists and works.

Quake 3 .map exporter is bundled with Blender and works, but it doesn’t work correctly (order of brush faces is screwed up in the output, wrong strings are being written, etc.)

http://projects.blender.org/tracker/index.php?func=detail&aid=35099&group_id=9&atid=498

i notice it fails on Aerowalk/pkeg

I’m getting an error on importing ns maps:

Read new prefs: C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.67\co
nfig\userpref.blend
found bundled python: C:\Program Files\Blender Foundation\Blender\2.67\python
– IMPORTING BSP –
Source file: D:\Program Files (x86)\Steam\SteamApps\common\Half-Life
s\maps\co_
core.bsp
bsp contains 113 models. (faces = 8194, edges = 19911, verts = 11202)
– LOADING TEXTURES –
[0] ‘door_yellgrey02’ (128x128 16384bytes)
[1] ‘flr_grey02 ents’ (128x128 16384bytes)
[2] ‘fx_damage07 g…’ (128x256 32768bytes)
[3] ‘fx_elevator2 …’ (256x128 32768bytes)
[4] ‘fx_lgt_panel02’ (128x32 4096bytes)
[5] ‘light_panel02 s’ (128x32 4096bytes)
[6] ‘misc_damage01 s’ (64x64 4096bytes)
[7] ‘misc_damage07 s’ (128x256 32768bytes)
[8] ‘misc_doortrack’ (32x128 4096bytes)
[9] ‘misc_pipes03 ts’ (128x128 16384bytes)
[10] ‘misc_pipes05 ts’ (128x128 16384bytes)
[11] ‘wall_grey08 nts’ (128x128 16384bytes)
[12] ‘wall_panel01 ts’ (256x256 65536bytes)
[13] ‘wall_panel05 …’ (256x256 65536bytes)
[14] ‘wall_panel08 ts’ (256x256 65536bytes)
[15] ‘wall_panel11 ts’ (256x256 65536bytes)
[16] ‘wall_panel14 ts’ (256x256 65536bytes)
[17] ‘{floor_panel02’ (128x128 16384bytes)
[18] ‘!r25_stagnant’ (128x128 16384bytes)
[19] ‘+0nos_ind ant’ (16x16 256bytes)
[20] ‘+1nos_ind tor r’ (16x16 256bytes)
[21] ‘+2nos_ind tor r’ (16x16 256bytes)
[22] ‘+3nos_ind tor r’ (16x16 256bytes)
[23] ‘+4nos_ind tor r’ (16x16 256bytes)
[24] ‘+5nos_ind tor r’ (16x16 256bytes)
[25] ‘+6nos_ind tor r’ (16x16 256bytes)
[26] ‘+7nos_ind tor r’ (16x16 256bytes)
[27] ‘hint walllights’ (16x16 256bytes)
[28] ‘joinaliens-b ts’ (256x64 16384bytes)
[29] ‘nos_pipe2 nel 2’ (48x16 768bytes)
[30] ‘observe-b 11’ (256x64 16384bytes)
[31] ‘r25_monitorbox2’ (128x64 8192bytes)
[32] ‘skip lights3 2’ (16x16 256bytes)
[33] ‘wall_lab2 e3’ (256x256 65536bytes)
[34] ‘black 26 a 03’ (32x32 1024bytes)
[35] ‘clip ebar 2’ (16x16 256bytes)
[36] ‘origin l h r’ (16x16 256bytes)
[37] ‘sky litedawn’ (16x16 256bytes)
[38] ‘{blue d e’ (16x16 256bytes)
[39] ‘{fence lr 1 e’ (256x192 49152bytes)
[40] ‘+0~nos_wklt’ (64x48 3072bytes)
Traceback (most recent call last):
File “C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_mesh_
bsp_init_.py”, line 75, in execute
bsp_importer.import_bsp(context, self.filepath, options)
File “C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_mesh_
bsp\bsp_importer.py”, line 263, in import_bsp
texture_data = load_textures(context, filepath)
File “C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_mesh_
bsp\bsp_importer.py”, line 125, in load_textures
miptex_name = miptex.name.decode(‘ascii’).rstrip(’\0’)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0x8d in position 12: ordinal
not in range(128)

location: <unknown location>:-1

location: <unknown location>:-1

And on a different map:

Read new prefs: C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.67\co
nfig\userpref.blend
found bundled python: C:\Program Files\Blender Foundation\Blender\2.67\python
– IMPORTING BSP –
Source file: D:\Program Files (x86)\Steam\SteamApps\common\Half-Life
s\maps\co_
faceoff.bsp
bsp contains 99 models. (faces = 6087, edges = 14594, verts = 8376)
– LOADING TEXTURES –
[0] ‘miptext_name1’ (16x16 256bytes)
[1] ‘miptext_name2’ (16x16 256bytes)
[2] ‘miptext_name3’ (64x64 4096bytes)
Traceback (most recent call last):
File “C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_mesh_
bsp_init_.py”, line 75, in execute
bsp_importer.import_bsp(context, self.filepath, options)
File “C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_mesh_
bsp\bsp_importer.py”, line 265, in import_bsp
texture_data = load_textures(context, filepath)
File “C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons\io_mesh_
bsp\bsp_importer.py”, line 132, in load_textures
pixels_pal = struct.unpack(’<%dB’ % miptex_size, file.read(miptex_size))
struct.error: unpack requires a bytes object of length 4096

location: <unknown location>:-1

location: <unknown location>:-1

If I replace line 125 with a different name format, it works.

BTW, this plugin came just in time. TY!

PyroGXPilot: Wow, thanks for spotting that; I didn’t exactly test it very thoroughly to be honest. I knew that because the texture names contained special characters that can’t be used in windows filenames I couldn’t save the textures out, but the generally work in the blend file. I will have a look at that bug and see if I can fix it.

Mahalin: Are you trying to import half-life bsps? I think that would require a different importer since although the bsp format used by Half-life is similar to Quake, I doubt they are the same. However, if you managed to get a half-life bsp loading just by changing one line of code, I’d love to see a pic of the level you loaded. If it works I can add half-life maps as an officially supported option I guess.

Still, I’ll check out Aerowalk and Powder Keg.

Ok, the bug is fixed. Turned out is was simply caused by texture names not being 0 padded (only 0 terminated) in bsps compiled with older compilers and all the maps I was testing were recent.

New version here:
http://www.quaketastic.com/upload/files/misc/blender-quake_bsp_importer-v0.0.4.zip

Aerowalk: http://i.imgur.com/CQ1iRgQ.jpg
Powder Keg: http://i.imgur.com/230kPmm.jpg
Death by the Dozen: http://i.imgur.com/SYzciYz.jpg

I have made some additions to Mr_Flamey’s cool importer script as v0.0.5. Blender 2.68a must have changed bmesh enough so that a change was needed in the way UV coords are mapped. Version 0.0.5 adds options to use cycles shader nodes and an option to create lights based on the entities list.

Here is a cycles rendered map with water (glass shader)


Here is a blender internal rendered map with lights


Thanks for that importer and the update delivering that nostalgia from the past

Wow, great work! It’s unreal how close the renders look to Quake screenshots. I’d love to see how stuff looks with ambient occlusion and no textures, but most Quake maps look pretty crap, so I doubt it would be so great. Originally I made it with the intention of adding details to some Quake maps I made and doing a couple of nice renders, but I got distracted by other things :slight_smile:

Does this script also import the character models (the monsters and such)?

I brought in a BSP map, added a remesh modifier in block mode and followed that with a bevel.

Attachments


Has anyone tried the add-on with Blender 2.75+ ?

Did try. Script needs 2 lines more and it just works.
http://www.pasteall.org/pic/show.php?id=92335

… and this marvel…Too bad, looks like it’s not a single player mod.