3D OpenGL Engine

BlitzPlus Forums/BlitzPlus Programming/3D OpenGL Engine

Got BSP trees working! The commands are fairly simple:
;Create a CSG brush
brus=CreateBrush()
AddFace brus,1,0,0,-1
AddFace brus,-1,0,0,-1
AddFace brus,0,1,0,-1
AddFace brus,0,-1,0,-1
AddFace brus,0,0,1,-1
AddFace brus,0,0,-1,-1

;Compile CSG brush into a solid object
CompileBrush brus

;Create a new BSP tree
root=CreateBSPTree()

;Add faces of CSG brush to BSP tree
For f=1 to CountFaces(brus)
face=GetFace(brus,f)
AddBSPNode face,root
Next


The demo clearly shows that the BSP tree is working. Faces that get split along a node are currently deleted, but I can fix that pretty easily. I'm using boxes here, but the routines are written using plane equations, and will work on any CSG brush.