Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / How to read Quake MAP file format Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Lennox

August 04, 1999, 03:05 PM

Does anyone have any information on how to read a quake map file, straight from worldcraft or whatever? The information would be greatly appreciated.

 
Justin Wilder

August 05, 1999, 04:12 AM

I have code from a Quake I vector-based map viewer I made a while back (I assume you're talking about Quake I, and not II or III -- if this is not the case, I guess you can just disregard this reply). It consists of one application to read and simplify the .bsp format (mostly just eliminates the textures), and another program to view the output. If you want the code, just email me and I'll send it to you...

Justin.

Lennox wrote:
>>Does anyone have any information on how to read a quake map file, straight from worldcraft or whatever? The information would be greatly appreciated.

 
Lennox

August 05, 1999, 09:11 AM

Sorry, I need the code to read a map file directly. But reading a bsp is just as handy, so if you want please e-mail to me.

 
Justin Wilder

August 05, 1999, 07:22 PM

Quake maps contain a BSP tree for the entire level. The BSP tree has nodes for every polygon in the level (minus those used for dynamic objects, like doors). BSP trees also have the added benefit of allowing efficient visibility tests, correct polygon ordering, and easy collision detection with the world. As far as I can tell, interpreting the BSP tree of a Quake map is pretty much all there is to understanding a Quake map file. But maybe we're talking about different things here.
What file format are you trying to read? If it's the .pak file, then what you're actually trying to read is not a "map", it is a collection of files packed into a single, non-compressed file format. Reading these are quite simple, but I do not have the format specifications on me. Try downloading qped, which will give you a nice directory layout for an Quake I or II pak file, if all you want to do is view the contents of a pak file. If you want to actually read and modify a pak file yourself, there are numerous resources out there for learning how, you just need to search for "pak". If it's not the .pak file you're trying to read, then it must be the .bsp file, since these files are what actually defines Quake maps. The source I emailed to you actually reads the .bsp files, not .pak files.
If this is still not what you wanted, please clarify.

Justin

Lennox wrote:
>>Sorry, I need the code to read a map file directly. But reading a bsp is just as handy, so if you want please e-mail to me.

 
Luke

August 06, 1999, 01:22 PM



Justin Wilder wrote:
>> Quake maps contain a BSP tree for the entire level.

Yes they do, but I think that what Lennox is looking for is the .MAP intermediate file format that describes the world geometry before qbsp gets run on it, not the information in the .BSP

I don't have the specs in front of now (as I am not home) but I will later and I will post again with more info on the .MAP file, how to read it and recreate the faces.

-Luke



 
Vincent Harvey

August 07, 1999, 12:00 AM

The quake developer pages has the specs on the format here.

However, the thing is that the map format uses brushes, which arent really polygons. They define
planes with 3 points, that intersect to form convex solids. I don't have an idea on how to convert
that to polygons. Go to the id ftp site, and look through the sources they have, mainly in qbsp
which must convert the ...., now that I think of it, that is what happends. It converts the map
into a bsp tree. This handles clipping the planes into polygons, i think.

Lennox wrote:
>>Does anyone have any information on how to read a quake map file, straight from worldcraft or whatever? The information would be greatly appreciated.

 
Lennox

August 07, 1999, 08:46 AM

Thanks alot, that is what I am looking for. I would also like to read the bsp files also. I prefer to read the files however in their original format, but if anyone has any info on how to read in or convert bsp files into polygonal worlds, please do post. Sorry Justin, I didn't get any e-mail from you.

Luke wrote:
>>
>>
>>Justin Wilder wrote:
>>>> Quake maps contain a BSP tree for the entire level.
>>
>>Yes they do, but I think that what Lennox is looking for is the .MAP intermediate file format that describes the world geometry before qbsp gets run on it, not the information in the .BSP
>>
>>I don't have the specs in front of now (as I am not home) but I will later and I will post again with more info on the .MAP file, how to read it and recreate the faces.
>>
>>-Luke
>>
>>
>>

 
Luke

August 09, 1999, 05:23 PM

Ok, the quake .MAP file:

I'll describe the way to rebuild the polygons from it. To get the actual format check out this site: The Quake MAP File Specs. If you want the BSP file specs I can email them to you. Just let me know.

Ok, now onto the good stuff.

The basic format of the MAP file is a set of planes that define a convex solid. The Plane definitions are setup like so (assuming standard quake 1 MAP)
{
( x1 y1 z1 ) ( x2 y2 z2 ) ( x3 y3 z3 ) tex_name x_off y_off x_rot x_scale y_scale
( x1 y1 z1 ) ( x2 y2 z2 ) ( x3 y3 z3 ) tex_name x_off y_off x_rot x_scale y_scale
( x1 y1 z1 ) ( x2 y2 z2 ) ( x3 y3 z3 ) tex_name x_off y_off x_rot x_scale y_scale
( x1 y1 z1 ) ( x2 y2 z2 ) ( x3 y3 z3 ) tex_name x_off y_off x_rot x_scale y_scale
( x1 y1 z1 ) ( x2 y2 z2 ) ( x3 y3 z3 ) tex_name x_off y_off x_rot x_scale y_scale
( x1 y1 z1 ) ( x2 y2 z2 ) ( x3 y3 z3 ) tex_name x_off y_off x_rot x_scale y_scale
}

Each line represents a plane. ( x1 y1 z1 ) ( x2 y2 z2 ) ( x3 y3 z3 ) are 3 non-colinear points that are used to rebuild the plane equation into the form Ax+By+Cz-D=0. Next is the texture that is used on that plane, then the x and y offset of the texture, the rotation of the texture, and then the x and y scale of the texture.

When reading the file, to convert each line into a plane equation. If you need info on how to build the plane equation from 3 points, check out the post I did about frustum creation in the 3D Theory Forum of July 27. Its under the thread 'newbie...clip a point'

Once that is done, you need to build a REALLY large polygon on that plane that is extended to the farthest possible bounds of the data set. Then do some thing like this:

face_t *face; //this is your list of very large faces on the planes
plane_t *plane; //this is your list of planes that you built from the MAP

for(i=0; i < num_planes; i++)
{
for(j=0; j < num_planes; j++)
{
if(j != i)
clip_face_with_plane(face,plane[j]) } } For the clip_face_with_plane just check out any doc on the sutherland-hodgeman clipping algorithm. There is one here on flipcode under the portal engine series. When doing this, you have to make sure that when you clip your faces to the plane you clip on the correct side of the plane. Otherwise all faces will end up having 0 vertices. When you are done you will have the original solid that was built in whatever editor you use. Any questions, just lemme know. Happy Coding -Luke

 
Lennox

August 11, 1999, 04:36 PM

Thx alot for all the info. I get everything, except how to recreate the large polygon. Can you explain how to make the large polygon to be split by all the other planes?

 
Luke

August 16, 1999, 11:06 PM



Lennox wrote:
>>Thx alot for all the info. I get everything, except how to recreate the large polygon. Can you explain how to make the large polygon to be split by all the other planes?

Sorry for the long delay....

Anyway what you want to do is first, using the plane the face will lie on, find out if the plane is more toward the x, y, or z axial plane. You can do this by finding the greatest value of the vector in the plane equation. Ax+By+Cz-D
If A is biggest plane is more toward (or on) the x-axis
If B is biggest plane is more toward y-axis
If C is biggest plane is more toward z-axis

you also need to decide on some boundries for you level. So just for example we will make the boundries (-1024, -1024, -1024) to (1024, 1024, 1024). This way you ensure your faces are big enough

We are going to make a square face, that lies on the plane

If the plane that the face is on is more toward the z axis, use the boundries on x and y for coords of a point on the large face. so you have points
(-1024, -1024, z1)
(-1024, 1024, z2)
(1024, 1024, z3)
(1024, -1024, z4)

What you need to do is calculate the z values. You can do this by plugin in the known values of x and y into the plane equation and solving for z.

If the plane that the face is on is more toward the y axis, use the boundries on x and z for the coords. Then solve for y.

If the plane that the face is on is more towrd the x axis, use the boundries on y and z for the coords, then solve for x

Once you have the four points, you can make your face, then go ahead and clip as needed.

Luke

 
This thread contains 10 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.