Jump to content
  • Advertisement
Sign in to follow this  
sergeiv

Quake3 BSP viewer

This topic is 4084 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

Recently I became interested in exploring Quake3 engine source code. As the result I decided to write some kind of BSP-file viewer. Have anyone been working with it? I understood general BSP format but when it came to implementation I ended up with some problems. One of them is BSP-tree itself. Every BSP node has a bounding box and so do it's child nodes and leaves. I suppose that parent's bounding box should include every child bounding box too. But in practice it does not. The following screenshot shows the problem. White box is the parent's bounding box and the red box is the child's one. You can see that it is not contained within it's parent's. Can anyone explain this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
This is purely a guess, but I'd say the bounding boxes are used for collision, so it makes sense that each leaf would contain anything that could be collided with. In the picture the red box is not entirely in the white one, but it's still partially inside. The point is that you find the leaf the player is in using the BSP nodes and then perform the collision tests first based on the boxes, then any faces inside and finally their planes.

Share this post


Link to post
Share on other sites
Yeah, I know it. But the problem in this screenshot is that according to the algorithm the viewer should be in this red box of a leaf, but actually he is in a white bound box of the parent's node. So I cannot use PVS, because PVS gives visibility info only regarding particular leaf, not the whole node. I don't know what's the catch here, but my algorithm of finding a leaf for the viewer is quite straightforward:

int CBSPRenderer::FindClusterForViewer()
{
int node = 0;

for (; node >= 0; )
{
dnode_t* pnode = dnodes + node;
dplane_t* pplane = dplanes + pnode->planeNum;
float* normal = pplane->normal;
if (m_Camera.GetPosition() * CVector3D(normal[0], normal[1], normal[2]) > pplane->dist)
{
node = pnode->children[0];
}
else
{
node = pnode->children[1];
}
}

DbgDrawBBox(dleafs[-node].mins, dleafs[-node].maxs, CVector3D(1.0, 0.0, 0.0));
return dleafs[-node].cluster;
}

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!