1

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.

Chris528
  • 11
  • 2

1 Answers1

1

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.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • That explanation is a little too high level for me, could you explain how to implement that in a little more detail? – Chris528 Jul 29 '13 at 17:06
  • @Chris528: Using a BSP tree is the obvious thing, because they are the prime data structure the Id Tech engines, and in their legacy the Source engine are built upon; so if you want to process data made for those, you should use a BSP. BSP trees are a data structure that recursively splits space by planes. The planes of your brush are used by BSP tree based 3D engines to form actual volumes. BSPs are an extensive topic and I recommend this read ftp://ftp.sgi.com/other/bspfaq/faq/bspfaq.txt – datenwolf Jul 29 '13 at 18:57