Heightfield terrain

Hi all !
The new version of Panda3d can support heightfield terrain, but what is the method ? I don’t found information about it in the manual (maybe because it is new)
The terrain use CLOD ?
Thx, and sorry for my english

Yeah, I am interested in knowing what techniques/algorithms are being used also. I am tinkering with this new class and so far it looks really useful. Great job! Enlighten us plz!

OK. So the basic idea is this: the tesselator sets up a bunch of concentric rings, like a dartboard. All terrain inside the first ring is at full resolution. All terrain inside the second ring is at half-resolution. All terrain inside the third ring is at quarter-resolution. And so forth.

Each ring has a radius twice as big as the previous. So if the innermost ring has a radius of 50 feet, the next ring has a radius of 100 feet, the next 200 feet, etc. Each ring covers four times the area as the previous. However, since each ring is at one half the resolution of the previous, the number of polygons in each ring is the same as the number of polygons in the previous.

The rings aren’t actually circular, they’re square. I may do circular someday, but square is easier for now.

The algorithm is as follows. First, I chop the terrain into 128x128 cells. Each cell is processed by a recursive algorithm. The recursive algorithm is: if the cell needs to be subdivided into four subcells, then subdivide, otherwise just output a big quad.

The decision whether to subdivide a cell is subdivided based on the following rule: find the center of the cell. Find the innermost concentric ring containing the center of the cell. If the resolution of the ring is higher than the resolution of the cell, subdivide the cell.

Then there’s the business about a low-res cell adjacent to a high-res cell. This may cause T-junctions. To avoid this problem, I use this rule: whenever the decision is made not to subdivide the current cell, I then check its neighbors. At most one neighbor might be subdivided. If one of the neighbors is subdivided, then the current cell is not rendered as a quad - instead, it’s rendered as a pentagon that interfaces nicely to the three non-subdivided neighbors and the one subdivided neighbor.

Then there’s the question of chopping all this up into reasonable-sized geoms, and arranging them into a nice structured scene graph.

To do it, the recursive routine that subdivides a cell has the option: subdivide and collect all the resulting triangles into one big geom, or subdivide into four separate geomnodes. It chooses the latter option if it predicts that the number of triangles it is going to generate exceeds a certain threshold.