Skip to main content
gamedev.net
🔒 Locked

BSP-Trees

Started by CProgrammer 5 replies 950+ views
Original Post
CProgrammer
CProgrammer
Could someone give me an easy example of a BSP-Tree that only sorts in a back-front order and doesnt check overlaps or other details. Just the core.
Waverider
Waverider
Can't remember who I did this for before...


void ParseBSPTree(strNode *p_Node)
{
// If left is null, right is null too and this is a leaf
if (p_Node->left == NULL )
{
RenderPolygons(p_Node->polygonset);
return;
}

// Branch according to placement of viewpoint in relation to partition
if ( ViewpointInFrontOfPartition(p_Node->partition))
{
ParseBSPTree(p_Node->left);
ParseBSPTree(p_Node->right);
}
else
{
ParseBSPTree(p_Node->right);
ParseBSPTree(p_Node->left);
}
}


Whether you go left or right depends on how the tree was built. If left is behind the partition, then you should get a back-to-front render.

Hopefully this helps.

[edited by - Waverider on October 9, 2002 10:31:33 AM]
It's not what you're taught, it's what you learn.
CProgrammer
CProgrammer
Thanks but do you maybe have a link to a finished non pseudocode simple example of a BSP-tree. I can learn better from complete example code than from theorie.
Thanks in advance CProgrammer
Waverider
Waverider
Sorry, I haven't progressed that far yet, and don't have any links.

[edited by - Waverider on October 9, 2002 11:13:37 AM]
It's not what you're taught, it's what you learn.
Fuzztrek
Fuzztrek
here's some info: http://www.gamedev.net/reference/articles/article657.asp

¬_¬

[edited by - Fuzztrek on October 9, 2002 11:39:53 AM]
CProgrammer
CProgrammer
Thanks fuzztrek this looks very interesting
CProgrammer
CProgrammer
I guess this article can be learned from but just in case someone has this ill ask again.
Does someone know where i can get code that only sorts the polygons with the partitionplanes(no splitting if on plane)
and then uses this to draw back-front.
Basically as simple BSP as it gets.

-CProgrammer

Topic Locked

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

Sign in to reply to this topic.