Sign in to follow this  

how to properly use bsp trees in game

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

im working on a very simple engine for a school project, i just want to be able to draw a single ok sized room, texture it, and be able to walk around with proper collision. with the ability to eventually extend it to a fuller engine. ive done this before but i used glut, drew the entire level straight from vertexs i put in, and had a very messy series of ifs for my collision checking against every wall. since then ive done alot of researching and have made tons of smaller programs. this time im using winapi and i want to use a bsp tree. i know how to create, search, add to and walk bsp trees. my question is how do i properly store the vertex data on the tree? and where to store the data to make sure the right vertexes are in the right order on the tree. of course ive googled it and read through many tutorials but i dont really get if i should be putting the vertex data on every leaf or only the last leaves on the tree. the tutorials also said to determine which direction to walk the tree depending on which direction the camera is facing, but how would i compare the camera position to the tree? just compare it to the main divisions vertex data? i also want to be able to generate the tree from a file but i dont know how to export and import files from modlers and since the room is going to be a simple room i just want to be able to import the points from a text file, how do i know the proper order to list them in the file to have them in the right spot for the tree. lastly, how would i set up the ceilign and floor? or would i have to do something like in the doom1 engine? if this is too much to explain, a point to a good tutorial would be fine. i know how to program bsp trees, i just dont know how to use them the right way in a game.

Share this post


Link to post
Share on other sites
BSP 101:
Vertices are stored in an array;
Faces contain data about texture, lightmap etc as well as indexes of the vertices it uses (to form triangle fans);
Each leaf contains the cluster index and indexes to the faces that should be drawn if the cluster is visible. Note that different leaves might contain the same face, so you should keep count of the faces you draw.

PS: If you know a good way to find the leaf the camera is in please paste code, cause I'm getting invalid leaves with my algorithm.

Share this post


Link to post
Share on other sites

This topic is 3859 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this