March 4th, 2009, 03:39 AM
Quadtree + Surface (Terrain)
I was working on a terrain system a while back, but had to put it on the back burner for another project. Anyway one of the major problems i kept having was sub dividing my surface.
Lets say i had a surface that was 256x256 in size, i then wanted to subdivide it into 4 128x128 surfaces. Sounds easy enough...
The problem i got was i would allocate 128x128 verts on all 4 new surfaces then would copy over the data, although there was a major problem. The cut in the main surface would run along the 128th point. So one new surface would have point 128 and the neighbour surface would have point 129 (or point 1 for them), so there is now 1 face missing per row.
My first thought was to take 129 verts onto the neighbouring surface and then duplicate the 128th point, although it felt like a hack and it seemed to have problems lining them up.
Basically im just wondering if there is some better way to do this, im looking at it from each surface having their own vertex buffer/array so they all act independantly without needing to know about their neighbours etc, i am also splitting on a per vertex basis to the power of 2, so 1024x256 would get divided into 512x128 chunks.
Ive looked at loads of quadtree articles, but they all seem to just waffle on about fancy pants words and not get to the point of the actual splitting up, or maybe its just the articles i read.
Im doing this in C# with XNA, but i know enough C++ or most other languages so any code examples would be welcome as the logic should be the same!
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!