• entries
557
1237
• views
422519

# Untitled

56 views

A bit of a mini update here, since I don't really have much to say. I'm having "issues" rendering a Quake BSP map properly. Here's how my index buffer filling code looks for just rendering all edges:
for(u32 i=0; i{   *pLock++ = pEdges.v0;   *pLock++ = pEdges.v1;}m_nNumPrimitives = m_header.lumps[BSPHeader::LUMP_Edges].nSize / sizeof(BSPEdge);

Pretty simple. Just go over eatch edge and add the index of the two vertices in it.

Here was my first attempt at rendering all the edges in the first BSP tree leaf (Index 0 is a special value, so index 1 is the first):
for(u32 nLeaf=1; nLeaf<2; ++nLeaf){	const BSPLeaf& leaf = pLeafs[nLeaf];	for(u32 nFace=0; nFace	{		const BSPFace& face = pFaces[pFaceLookup[leaf.lface_id + nFace]];		for(u32 nEdge=0; nEdge		{			const BSPEdge& edge = pEdges[face.ledge_id + nEdge];			*pLock++ = edge.v0;			*pLock++ = edge.v1;		}		m_nNumPrimitives += face.ledge_num;	}}

A bit more complicated. Each leaf has a list of faces (Via another lookup), and each face has a list of edges. Now, that works a little, but it looks "weird". There's not a full face there or anything.

Actually, I just noticed that they'll probably be edge loops, and I need to fill in the final edge - that might be it (But I'm not sure).

Finally, my attempt at rendering the first BSP node:
for(u32 nNode=0; nNode<1; ++nNode){	const BSPNode& node = pNodes[nNode];	for(u32 nFace=0; nFace	{		const BSPFace& face = pFaces[node.lface_id + nFace];		for(u32 nEdge=0; nEdge		{			const BSPEdge& edge = pEdges[face.ledge_id + nEdge];			*pLock++ = edge.v0;			*pLock++ = edge.v1;		}		m_nNumPrimitives += face.ledge_num;	}}

That doesn't need the extra lookup for faces, because the faces are in that order in the BSP file (And they need patched up for getting faces from leafs). That also gives strange results. It seems to draw the "Normal" skill teleporter, and also part of the slipgate for E1. Even if the edges are loops or whatever, there's no way those two objects should be in the same BSP node, surely?

Oh well, I'll play with it tonight.

EDIT:
Ok, so I'm an idiot. I needed to use the edge lookup after all. Also, I found a difference in the Unnoficial Quake Specs and the latest version - the edge lookup is 32-bit, not 16-bit as the specs claim.
So, I now have the following (The 75 is a magic number that represents (what appears to be) all of the surfaces in one "chunk" of the map):
for(u32 nLeaf=1; nLeaf<75; ++nLeaf){	const BSPLeaf& leaf = pLeafs[nLeaf];	for(u32 nFace=0; nFace	{		const BSPFace& face = pFaces[pFaceLookup[leaf.lface_id + nFace]];		for(u32 nEdge=0; nEdge		{			s32 nEdgeLookup = pEdgeLookup[face.ledge_id + nEdge];			if(nEdgeLookup > 0)			{				*pLock++ = pEdges[nEdgeLookup].v0;				*pLock++ = pEdges[nEdgeLookup].v1;			}			else			{				*pLock++ = pEdges[-nEdgeLookup].v1;				*pLock++ = pEdges[-nEdgeLookup].v0;			}		}		m_nNumPrimitives += face.ledge_num;	}}

Next up is making these faces into polygons, and hopefully applying a texture (Ukh).

There are no comments to display.