Archived

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

mictian

rendering the Bezier patches in a q3 style BSP

Recommended Posts

mictian    138
does anybody know how to render the bezier patches from a quake 3 BSP file? (and if so please shed some light on the subject for me...)

Share this post


Link to post
Share on other sites
MENTAL    383
when Face.Type is 2, you have a patch.

Now, whereas Face.VertStart and Face.VertNum are usually the verts for rendering triangles, when you're dealing with a patch they contain the control co-ordinates for the patch, and form a large grid of points.

This grid is specified by Face.Size[0] (x) and Face.Size[1] (y). The size will always be an odd number due to the face that quake 3's patches are always 3x3 and they share edges.

Unfortunatly, the control points arn't stored from end to end with the first patch first and the last patch last. This is to save memory and to allow edge sharing. Anyway, your grid will look something like this:


v0----v1----v2----v3----v4----v5----v6----v7----v8
| 0 | 0 | 1 | 1 | 2 | 2 | 3 | 3 |
| | | | | | | | |
v9----v10---v11---v12---v13---v14---v15---v16---v17
| 0 | 0 | 1 | 1 | 2 | 2 | 3 | 3 |
| | | | | | | | |
v18---v19---v20---v21---v22---v23---v24---v25---v26
| 4 | 4 | 5 | 5 | 6 | 6 | 7 | 7 |
| | | | | | | | |
v27---v28---v29---v30---v31---v32---v33---v34---v35
| 4 | 4 | 5 | 5 | 6 | 6 | 7 | 7 |
| | | | | | | | |
v36---v37---v38---v39---v40---v41---v52---v43---v44


The numbers in the middle indicate which patch the squares belong to.

As can see, Patch 0 shares the edge v2-v11-v20 with Patch 1. It also shares the edge v18-v19-v20 with Patch 4.

Anyway, that's how you get the patch information out of the quake3. I won't tell you how to render them, as it's a topic that's been gone over time and time again (do a search for "3x3 Bezier patch" rendering).

A good idea is to precompute the patches and store them in a vertex buffer while loading the map. That way you don't have to calculate the patches each frame. Quake3 stores several LODs and changes to them when the camera is far away from the patch. Again, precompute these before hand (i think it uses 3 or 4 levels, the quality of which depends on your settings).

hope it helps

[edited by - MENTAL on August 11, 2003 5:48:28 AM]

Share this post


Link to post
Share on other sites