Archived

This topic is now archived and is closed to further replies.

rjwr10

Stan Melax Plane shifting BSP

Recommended Posts

Hey all, In my engine i''m trying to implement stan melax''s plane shifting bsp theory, details at: http://www.melax.com/bsp/index.html Anyhow, I''m trying to get my engine to be able to load his example worlds. The BSP tree is added at the end of a world geometry file (he uses a basic text format) heres a demo file: vertices, faces texcoords, blah area_bsp 0.000000 0.000000 1.000000 -4.000000 0.000000 0.000000 1.000000 0.000000 NULL 1.000000 0.000000 0.000000 9.000000 0.000000 1.000000 0.000000 9.000000 1.000000 0.000000 0.000000 13.000000 0.000000 -1.000000 0.000000 -11.000000 NULL 1.000000 0.000000 0.000000 20.000000 NULL 0.000000 1.000000 0.000000 20.000000 NULL NULL 0.000000 -1.000000 0.000000 -12.000000 NULL NULL *snip* they get long, obviously... anyhow, each line is of the form (x,y,z,d), xyz is the normal coords of the plane and d is the distance of the plane from the origin. The plane on the area_bsp line is the head of the tree. I have them loaded in a binary tree fine, but my question is, when I traverse the tree, how do i know if a leaf is a solid or an empty leaf. All the leaves are just NULL in the file. Has anyone worked with Melax'' demos? Can anyone provide some insight? Heres what I''m doing right now (pseudocode) CollidePointBSP(node, point3) { if(node->isleaf) // if it is NULL in file return true; classifypoint(point3, node->plane) //front or back if(test == front) return CollidePointBSP(node->right, point3); else if(test == back) return CollidePointBSP(node->left, point3); else //point is coplanar with the plane return false; //what do i return when coplanar? } Thanks a lot, rj

Share this post


Link to post
Share on other sites