Half-Life BSP Loader

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
saderbiscut
Posts: 4
Joined: Wed Jul 18, 2012 4:06 pm

Half-Life BSP Loader

Post by saderbiscut »

https://github.com/saderbiscut/BSPv30-Irrlicht

Awhile back I started working on a Half-Life BSP loader for Irrlicht. I haven't done much to it in a couple of months as I've been busy elsewhere, so I figured I'd share it. It works, but not very well, it needs alot of cleanup, this and that, but it might be useful to anyone who is interested.

You can get a sense of where it's at from the readme:
-It doesn't read any kind of entity data yet, this is a prerequisite for a couple of the following issues:

-It only loads textures stored inside the BSP and not in refrenced WAD files. WAD Data is stored in the world entity, and I think irrlicht has support for WAD files now, I just haven't gotten around to implementing it.
-I forget if it either loads everything as one model or just loads the entire world model, but either way, there isn't a mechanism for seperating entity models which makes them somewhat useless.
-It dosen't handle special texture effects or transparent textures.

-This project either has terrible/no memory management, I'm pretty sure it's a giant memory leak when it comes to how it stores textures. It dosen't clean up after itself and probably dosen't even allocate memory correctly in the first place.

-It has pretty awful performance in large maps. The default occulsion culling causes issues, so I have it turned off. It also dosen't implement VIS Nodes as I hadn't figure out a good way to do those with irrlicht. The answer to the aformentioned performance problems is probably here.

-It doesn't have lighting or lightmaps. I would like lightmaps very much but I am so far confused as to both how BSPv30 implements them but also how they would work with Irrlicht's lighting as I basically have no idea how the latter works.
Hope this is useful to someone!
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Half-Life BSP Loader

Post by christianclavet »

Wow! Thanks!

Lightmaps should be in the BSP, as for the entities, it would be hard to get as it's not stored in the BSP file, but in the game assets. For the performance issue, you could convert the loaded level as an octree.

I don't have time to check this now, is the code on GITHUB stay there long?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Half-Life BSP Loader

Post by serengeor »

christianclavet wrote:as for the entities, it would be hard to get as it's not stored in the BSP file, but in the game assets
Huh? As far as half-life 1 goes they should be stored in .bsp most of the times. Though there were tools that could place that data outside .bsp.
Working on game: Marrbles (Currently stopped).
saderbiscut
Posts: 4
Joined: Wed Jul 18, 2012 4:06 pm

Re: Half-Life BSP Loader

Post by saderbiscut »

I don't have any plans of taking the github repo down.

The entities are stored in the BSP, but they're saved as plaintext on the top of the file or something like that. It should be really trivial to parse them, I just didn't get around to it. The entity definitions or whatever you want to call them aren't in the BSP (ie, the BSP has a "func_door" with various properties, but what a func_door is or how you handle these properties is up to the engine and/or things outside the BSP files)

As for the light-map data, I'm not quite sure how it's formatted. Yes, it's in the BSP. I think the light-map lump is a giant array of colored pixels (3 bytes, RGB 256 colors.) Faces have offsets into this light-map and they use this to create a lightmap texture 1/16th the size of the face texture.

Or something like that. I am confused about how I would implement lightmaps in irrlicht so I didn't make too much progress in that area.

e: I think it worked with the octree node, but I don't think it fixed the performance problems, but maybe it broke it when I turned off culling? I am unsure.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Half-Life BSP Loader

Post by christianclavet »

Sorry, Mistaken with HL2... Most the assets I worked with were stored outside the BSP. Interesting to know HL1 BSP had most of the stuff inside the BSP...
Post Reply