Jump to content
  • Advertisement
Sign in to follow this  
TheCh0senGamer

Quake 3 BSP parse entities

This topic is 2867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am going to be using Quake 3 BSP files in my newest game. I need to extract the entity data, where they are, their parameters, etc. Is there any way to do this, or is it only possible to get the entity data from the .map file?

Specifically, I need to know where the lights are placed and how bright they are. I know that my BSP compiler generates lightmaps for the world geometry, but in the game, I need to place a dynamic light wherever there is one so that everything else in the game will be illuminated.

Share this post


Link to post
Share on other sites
Advertisement
I was tempted to make a LMGTFY link, but I'm in a rather good mood at the moment so I'll refrain :)

If you take a look at the Quake 3 BSP format "specification" (an unofficial one can be found here), it describes a lump that contains all the entity data in a gigantic string. It doesn't say what format entities are stored in, however if you save out that string to a text file it shouldn't be very difficult to reverse engineer the formats for the entities you're interested in (like light positions).

Share this post


Link to post
Share on other sites
I could be wrong about this, but I don't recall explicit light information (e.g. properties of individual lights) being part of the Q3 BSP specification. Rather, there are lightmaps (of course), and also a 'light grid' that contains information about the lighting in the level, and is used to light dynamic objects such as players and items.

Again, I could be wrong about this, but it should be easy enough to determine; just check out the entity string for a level and see if you see anything related to lighting...

Share this post


Link to post
Share on other sites
Yeah, I've been digging through my BSP's in a hex editor, and there is nothing light-related in the entity string. Looks like I'm going to have to parse the .map file. I'm actually mostly fine with this. I know several Quake 3 engine ports (DarkPlaces, for example) that parse the .map file to retrieve dynamic light data, as well as using the lightmaps included in the .bsp file. The only big problem is getting my game engine to cooperate :P

In fact, by now, I've whipped up a crude Python script that will extract the light data from a .map file and output it in text format to a new file, which I then pack with the .bsp file. This is to make for less ugly C++ fstreams and whatnot. Plus, it saves memory.

But thanks for the help anyway, I appreciate it :)

Share this post


Link to post
Share on other sites
@OP

If you have the pk3 containing the bsp's, you may want to see if the 'levelshots' folder is included. If my memory serves me correctly, the true lightmap was stored in tga format in that folder.

I'm at work so I can't verify this right now, but I'll edit later with more info.


-Feen

Share this post


Link to post
Share on other sites
Quote:
If you have the pk3 containing the bsp's, you may want to see if the 'levelshots' folder is included. If my memory serves me correctly, the true lightmap was stored in tga format in that folder.
Are you sure about that? I'm pretty sure that the lightmaps are stored in a 'chunk' in the BSP file itself.

In any case, I'm not sure how that would help the OP, since it's the original light parameters (position, etc.) that he's after.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Quote:
If you have the pk3 containing the bsp's, you may want to see if the 'levelshots' folder is included. If my memory serves me correctly, the true lightmap was stored in tga format in that folder.
Are you sure about that? I'm pretty sure that the lightmaps are stored in a 'chunk' in the BSP file itself.

In any case, I'm not sure how that would help the OP, since it's the original light parameters (position, etc.) that he's after.


I think you're right. The spec that Zipster linked me to says that there is a chunk in the BSP file that contains the lightmaps, and I did indeed verify this by being able to use them in my game.

Share this post


Link to post
Share on other sites
You are correct, lightmaps are stored in 'lump' 17 of the bsp file. Just had a chance to check this out.

However, (depending on the compile parameters) the lightmaps are also exported during the compile process. Including these images in the pk3 seems to override the lightmap stored in the bsp and generally produces more detailed lighting results in game. As for why... I'm not sure. I was never able to find any concrete information on the matter when I was looking into it.

None of this matters though as the OP has already found a solution to the problem. Just thought I would share.








Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!