How to calculate the points of a brush from a source engine vmf?

439 views Asked by At

I'm trying to render the brushes from a Source engine .vmf file in C++, using OpenGL.

The .vmf stores solid brushes as a series of planes which I would like to use to calculate the points for each brush. I'm pretty sure this would be done exactly the same as for all Quake engine based .map files as well.

Basically each point of the brush is the point where 3 planes intersect. I found a similar question to mine on stackoverflow and the explanation is to get the unit normals for the 3 planes, then use equation 8 on this page mathworld.wolfram.com/Plane-PlaneIntersection.html. My problem is that I have no idea how to implement that

Here's some code for a single 6 sided cube shaped brush:

    "plane" "(0 0 256) (0 256 256) (256 256 256)"
    "plane" "(0 256 0) (0 0 0) (256 0 0)"
    "plane" "(0 0 0) (0 256 0) (0 256 256)"
    "plane" "(256 256 0) (256 0 0) (256 0 256)"
    "plane" "(0 256 0) (256 256 0) (256 256 256)"
    "plane" "(256 0 0) (0 0 0) (0 0 256)"

I really have no idea where to start, any help would be appreciated, thanks.

1

There are 1 answers

2
datenwolf On

The usual way to do this is to populate a BSP tree with the planes. With the BSP in place it's quite easy to perform boolean operations, like "take all these planes and emit the (convex) volume bounded by them", the intersections of the planes are edges, the interesction of the edges are points.