Skip to main content
gamedev.net
🔒 Locked

BSP Version 30 Rendering

Started by Wavesonics Jun 5, 2006 at 12:00 AM 6 replies 1.1k views
Original Post
Wavesonics
Wavesonics
Hi, I've been working on this 3D engine of mine for a while now, and my current concern is properly rendering the geometry from a version 30 BSP file. So far I've loaded the entire file in, and rendered the level by going through each face and rendering all the edges it wants via the surfEdge array indexing into the edge array. The geometry renders in whole, but there is a TON of overlapping geometry. over lapping geometry So obviously I'm doing something wrong. But there is EXTREEMLY little documentation on the version 30 BSP format, all I have to go on is this file I found and what ever I can gleen from the HL SDK. (Half-Life uses version 30 BSPs) Does anyone have any knowledge on this? Are the vertices suppose to be rendered as triangle fans? That’s the only way I get solid full geometry. There doesn't seem to be one clear way to access the vertices, this is how I'm currently rendering, (-> means the previous one has an index into the next one's array) Nodes -> Faces -> surfEdges -> Edges -> Vertices Each Edge has 2 vertices, thus describing 1 edge of a polygon, all fine and dandy except that’s not how OpenGL renders polygons! Maybe it doesn't use triangles at all? Any insight into this would be great.
xstreme2000
xstreme2000
This may well be totally irelevent but I thought I'd mention it anyway. I don't know whether you're using OGL or DX to display your level but if it's DX then as far as I remember about BSP file the triangle winding orders is "backwards". That is it's the same direction OpenGL uses by default but backwards for DirectX, it's been very long time since I'd done any 3D programming so I can't remember if it's clockwise or counter-clockwise, but I'm sure you'd be able to work that one out.

Like I say, probably irrelevent but potentially could make all the difference ;-)

EDIT: I've just noticed you're using OGL, ignore me!
phil_s
phil_s
Quote:
Original post by Wavesonics
Does anyone have any knowledge on this? Are the vertices suppose to be rendered as triangle fans? That’s the only way I get solid full geometry.

There doesn't seem to be one clear way to access the vertices, this is how I'm currently rendering, (-> means the previous one has an index into the next one's array)
Nodes -> Faces -> surfEdges -> Edges -> Vertices
Each Edge has 2 vertices, thus describing 1 edge of a polygon, all fine and dandy except that’s not how OpenGL renders polygons!

Maybe it doesn't use triangles at all? Any insight into this would be great.


Half-Life BSPs don't use triangles - faces are actually polygons with a variable number of vertices each. I've always accessed the vertices by going through the nodes > leafs > marksurfaces > faces > surfedges > edges > vertices. It's convoluted, but it works. If you just want to render the entire level, then you can run through the entire array of faces > surfedges > edges > vertices.
Wavesonics
Wavesonics
Awesome thanks for everyone replying!

So this is how I understand it, please correct me if I'm wrong.

Each node contains indices to some faces and either a child node or a child leaf.

So you use the bounding boxes to see if the camera is in the node or not and continue traversing down the tree rendering the faces that each node points to finally ending up in a leaf that will point to the rest of the faces that complete the geometry?

Also the bounding boxes them selves are defined by 6 ints. 3 min, 3 max, i'm guessing this gives you 2 vertices in 3 space. A min vert and a max vert. And from that you can draw an imaginary box and check if the camera is inside it?

Again thanks for all the help!
Wavesonics
Wavesonics
I just tried the method you posted for rendering the whole level and I still get the over lapping problem as seen in the above screen shot. Right now I'm just loading everything into one displaylist with the following code:

// DebuggingglShadeModel(GL_SMOOTH); // temp, remove thisbool switcher = true; // temp, remove this        glNewList(1, GL_COMPILE);        // Loop through each face        for(int i=0; i<numFaces; ++i)        {            glBegin(GL_POLYGON);            // Loop through each edge in this face            for(int x=0; x<faces.numEdges; ++x)            {// Temp thingyif(switcher) // temp, remove this    glColor3f(1.0, 1.0, 1.0); // temp, remove thiselse // temp, remove this    glColor3f(0.0, 0.0, 0.0); // temp, remove thisswitcher = !switcher; // temp, remove this                __int32 edgeIndex = surfedges[faces.firstEdge+x]; // This gives the index into the edge lump                                // If the index is negative it means the edge goes in the other direction                if(edgeIndex > 0)                {                    glVertex3f(vertices[edges[edgeIndex].v[0]].coordinate.x, vertices[edges[edgeIndex].v[0]].coordinate.y, vertices[edges[edgeIndex].v[0]].coordinate.z);                    glVertex3f(vertices[edges[edgeIndex].v[1]].coordinate.x, vertices[edges[edgeIndex].v[1]].coordinate.y, vertices[edges[edgeIndex].v[1]].coordinate.z);                }                else                {                    edgeIndex *= -1;                    glVertex3f(vertices[edges[edgeIndex].v[1]].coordinate.x, vertices[edges[edgeIndex].v[1]].coordinate.y, vertices[edges[edgeIndex].v[1]].coordinate.z);                    glVertex3f(vertices[edges[edgeIndex].v[0]].coordinate.x, vertices[edges[edgeIndex].v[0]].coordinate.y, vertices[edges[edgeIndex].v[0]].coordinate.z);                }            }            glEnd();        }        // End definition        glEndList();
swiftcoder
swiftcoder
I don't know the bsp format, but if you are getting loads of overlapping geometry, have you checked if each node has a transform?
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.