Quantcast
Channel: X-Plane Developer » modeling
Viewing all articles
Browse latest Browse all 10

Draping Part 2: Draping a Polygon

$
0
0

In my previous post I described Z thrash and how polygon offset is used to fix it.  Now we can look at draping and runways.

The fundamental problem with sloped runways is that a runway is made up of tiles, but the ground underneath it may change slopes in unrelated locations.  The following diagram illustrates the problem.

This is a side view of a sloped runwy: the green line is the underlying bumpy terrain and the black line is the runway, divided into multiple tiles.  Recall from last time that we can only avoid Z-thrash using polygon offset if the two polygons are truly coplanar.  Therefore, we can look at four ways to handle the situation and evaluate them for quality:

  1. In the top picture, the runway simply runs right through the terrain.  This case won’t work, with or without polygon offset.  In some cases the terrain is on top, and in some cases the runway is on top.  The gap between the runway and terrain might be quite large for a significantly sloped runway.
  2. In the second picture, we move the runway up to clear all but the tallest part of the terrain.  This won’t Z-thrash, but it will look pretty bad.  There can be a large gap between the runway and the terrain; if you run your airplane off the side of the runway, you’re going to fall.  The gap between the runway and terrain will be quite noticeable.
  3. The third picture is close – each runway tile is clamped to the terrain.  But this still isn’t good enough; while most runway tiles now sit on the ground perfectly, a few will take a ‘short cut’ over or under the ground, like the case I have circled in red.  So we’ll have less Z thrash, but some parts of the runway will still be broken.
  4. The last picture is what we really need: we break the runway tiles up into even smaller pieces where the terrain makes a change.  The last tile on the right is now two tiles, each of which can sit perfectly on part of the terrain.  Only in this last case can we apply polygon offset and get a nice clean runway.

This last case is exactly what X-Plane does.  This technique is called draping – the sim ‘drapes’ the overlaid runway tiles on top of the runway like a rug.  The sim breaks the tiles into pieces so that each tile can sit perfectly on the underlying terrain.

The real work of draping is not just in figuring out where the terrain below the tile is, it is in cutting the tile into the appropriate pieces that can ‘sit right’.  The following pictures show this process in 3-d.

This is a screen-shot of a small piece of taxiway at KSAN.  I have drawn in the outline of the draped polygon in yellow and the terrain triangles in blue.  (The terrain triangles are quite large, so we can only see part of them running through the scene.

This is a wire frame of the problem at hand: we need to insert the yellow polygon into X-Plane, but we need to make sure that no triangles that we generate cross the blue line.  The blue lines essentially represent “ridge lines” in the underlying mesh.

If we just had to draw the yellow polygon, we could triangulate it using the thick gray lines shown in this picture.  However, this would not be good; the big gray triangle in the middle of this picture runways right across a blue line – there’s no way that this big gray triangle can “drape” properly across the ridge line.

This is what actually ends up happening.  The gray lines are cuts we need to triangulate the polygon; the red line are cuts we need to not cross the ridge line, and the purple lines are cuts we need to ensure that everything is broken down into triangles (since that’s what the video card really wants).  Once we have this triangulation, we can place every vertex on the ground and it will “drape” the way it should.

In my next post I’ll describe how you can use draping in your scenery to create images on the ground without Z thrash.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images