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


Terrain quadtree

Recommended Posts

Cybird    122
Well I am currently trying to implement quadtree for my terrain engine. I Currently load successfully a heightmap, filling one large vertex buffer and one index buffer. I know basics principles about implementation. 1) There is one Index Buffer (dynamic) for each node. So i need to divide my terrain into sub-patches of to say xXx units. If i create an index buffer for each leaves, and render them individually, they will not be connected, so I need to add indices to the IB, right? 2) If i can build the IB from the full heightmap without problems, how can i compute the indices of "squares" in the original HM? trying to subdivide HM into patches, but i dont know if it have any mathematical relationship or a pattern for having the indices of a square. Ex: 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 how can i have the indices of the square made of "2" if i already have computed the "complete" index buffer? thx

Share this post

Link to post
Share on other sites
flaXen    122
Not be connected? What? If you drew the terrain in patches (ie quadtree patches), they WOULD appear to "connect" to neighboring patches even tho they weren't drawn in the same call. There's no requirement saying a model/whatever has to be drawn in a single call to avoid cracks. In fact, models which have multiple textures are drawn in texture segments anway.

If you decide to render quadtree patches individually (rather than a single DrawPrimitive call w/ a single IB), you probably don't need an IB since you could use tristrips instead (faster anyway). This COULD get slow if you draw too many patches individually.

Generating the indices for the dynamic IB is easily done if the verts are in some incremental order. It gets tricky if there is no order (ie storing different LODs, etc. in the same VB). If you can't dynamically generate the indices, you could just copy around parts of the original IB to the dynamic IB and render with that and the original VB.

I think there's another post floating around this board where someone else doing terrain also used quadtrees and a dynamic IB. The author complained about memcpy being slow in reference to creating the dynamic IB (SHOULDN'T be true). You might check that out...

[edited by - flaxen on March 16, 2003 10:40:33 PM]

[edited by - flaxen on March 16, 2003 10:42:36 PM]

Share this post

Link to post
Share on other sites