anarky Posted June 22, 2011 Report Share Posted June 22, 2011 Hi,I am interested in Terrain systems and I have implemented my own basic terrain system for knowledge. I want to go further and was trying to understand 0AD code. I looked at the comments in code and wiki documentation unfortunately there is almost nothing about terrains. I also have a hard time to read the C++ code to understand the terrain rendering. Can someone explain which techniques are used in 0AD? I mean I see it is a patch system but can someone give a scenario like:I generate the terrain with heightmap, and the vertices are stored (there)... ? Or grid vertices are regenerated on the fly each time?View Culling?Which type of rendering?How does the patch system work?Are the terrain deformable afterwards? For example in-game events can change the terrain?Any information is welcome, time is not a concern /+ anarky +/ Quote Link to comment Share on other sites More sharing options...
Ykkrosh Posted June 23, 2011 Report Share Posted June 23, 2011 The CTerrain class stores the original heightmap as a 2D array of 16-bit ints (one for each tile vertex). It also stores an array of CPatch objects, each of which represents 16x16 (PATCH_SIZE) tiles, covering the whole terrain. CPatch stores the texture of each tile (via CMiniPatch).The renderer loops over every patch in the terrain, and if the 3D bounding box of the patch is visible to the camera then it reads the patch's CPatchRData. (That is, it does patch-based culling). If the patch doesn't already have a valid CPatchRData (e.g. this is the first time it has been visible, or the underlying terrain data has been modified since it was last rendered (since dynamic changes are supported)) then it computes a new CPatchRData. The CPatchRData stores OpenGL VBOs which contain all the vertex data needed for rendering the whole patch, so it just does some glDrawElements for each patch and that's about it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.