#### Archived

This topic is now archived and is closed to further replies.

# .MAP file format: bounding planes?

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

## Recommended Posts

I''m looking at the .MAP file spec, and it looks like brushes are defined by bounding planes (rather than explicit vertices). How can I get the actual vertices from those bounding planes, or am I doing something completely wrong? Superpig - saving pigs from untimely fates - sleeps in a ham-mock at www.thebinaryrefinery.cjb.net

##### Share on other sites
Straight from this flipcode article:
http://www.flipcode.com/tutorials/tut_levedit.shtml

#define MAX_BOUNDS 16384    //this is the abs(max point in data set)//Planes is an array of planes that define a convex area in space//which has been loaded from the map file//NumPlanes is the number of planes in the listCFace* FacesFromPlaneList(CPlane *Planes, int NumPlanes){    //you need at least 4 planes to make a solid    if(NumPlanes < 4)        return 0;    //allocate some memory for the new faces    CFace *NewFaces = new CFace[NumPlanes];    //need to make faces that lie on the planes of the solid that    //extend to the bounds of the data set.     for(int i = 0; i < NumPlanes; i++)    {        //the vertex count for each inital face will be 4        NewFaces.VertexCount = 4;        //check to see if the plane is x-axis oriented        if(abs(Planes[i].x) >= abs(Planes[i].y) && abs(Planes[i].x) >= abs(Planes[i].z))        {            //set the bounds of the polygon, using y and z axis            NewFaces[i].Vertex[0].Set(0, -MAX_BOUNDS, -MAX_BOUNDS);            NewFaces[i].Vertex[1].Set(0, -MAX_BOUNDS, MAX_BOUNDS);            NewFaces[i].Vertex[2].Set(0, MAX_BOUNDS, MAX_BOUNDS);            NewFaces[i].Vertex[3].Set(0, MAX_BOUNDS, -MAX_BOUNDS);            //calculate the x value of each vertex on the plane            for(int j = 0; j < 4; j++)            {                NewFaces[i].Vertex[j].x = Planes[i].d -                     Planes[i].z * NewFaces[i].Vertex[j].z -                    Planes[i].y * NewFaces[i].Vertex[j].y ) /                     Planes[i].x;            }        }        //check to see if the plane is y-axis oriented        else if(abs(Planes[i].y) >= abs(Planes[i].x) && abs(Planes[i].y) >= abs(Planes[i].z))        {            //set the bounds of the polygon using the x and z axis            NewFaces[i].Vertex[0].Set(-MAX_BOUNDS, 0, -MAX_BOUNDS);            NewFaces[i].Vertex[1].Set(-MAX_BOUNDS, 0, MAX_BOUNDS);            NewFaces[i].Vertex[2].Set(MAX_BOUNDS, 0, MAX_BOUNDS);            NewFaces[i].Vertex[3].Set(MAX_BOUNDS, 0, -MAX_BOUNDS);                         //calculate the y value of each vertex on the plane            for(int j = 0; j < 4; j++)            {                NewFaces[i].Vertex[j].y = ( Planes[i].d -                     Planes[i].z * NewFaces[i].Vertex[j].z -                    Planes[i].x * NewFaces[i].Vertex[j].x ) /                    Planes[i].y;            }        }        //plane must be z-axis oriented        else        {            //set the bounds of the polygon using the x and y axis            NewFaces[i].Vertex[0].Set(-MAX_BOUNDS, -MAX_BOUNDS, 0);            NewFaces[i].Vertex[1].Set(-MAX_BOUNDS, MAX_BOUNDS, 0);            NewFaces[i].Vertex[2].Set(MAX_BOUNDS, MAX_BOUNDS, 0);            NewFaces[i].Vertex[3].Set(MAX_BOUNDS, -MAX_BOUNDS, 0);            //calculate the z of each vertex on the plane            for(int j = 0; j < 4; j++)            {                NewFaces[i].Vertex[i].z = ( Planes[i].d -                     Planes[i].y * NewFaces[i].Vertex[j].y -                    Planes[i].x * NewFaces[i].Vertex[j].x ) /                    Planes[i].z;            }        }    }    //now for each face, we clip it against the planes of all the other faces    //since it is convex, after all the clipping the face will be the original    //as seen in the editor    //NOTE: Depending on how you calculated your plane equations, you may need    //to flip the plane before you clip the faces, since the wrong side of the     //face will be clipped. And you will end up with faces with no vertices.    for(i = 0; i < NumPlanes; i++)        for(int j = 0; j < NumPlanes; j++)             if(i != j)                 ClipFaceWithPlane(NewFaces[i], Planes[j]);    return NewFaces;}

##### Share on other sites
I had a look at making a .MAP loaded a wile ago. I got as far as being able to load some simple shapes almost correctly
Its a really hiddeious format IMHO, planes everywhere.

Steve
DirectX Programmer
Soon to be the new Bill Gates

##### Share on other sites
Eww. I think I''ll be looking at alternatives, then. Thanks anyway.

Hmm, the article on 3D MFC could prove useful...

Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 9
• 13
• 85
• 11
• 10
• ### Forum Statistics

• Total Topics
632969
• Total Posts
3009599
• ### Who's Online (See full list)

There are no registered users currently online

×