Well I have a good idea to store the information in data format. You can use a 2D array to hold the bits each bit is a relative distance from the previous point. You will need to twine two bit streams into one stream. Now, generating good looking terrain from a stream of bits is only as good as the algorithm to generate the bits. Lets say you figure out how to generate the bits. Now to build the mesh, each 2 bits is a point on the mesh, you just have to connect the points to get the mesh back. Start from a corner in the grid. I will choose the top left corner to start. The data in binary would look like this, 0 means the value has not changed, 00 means it goes negative, and 1 means it is one value higher or lower than the previous value. You will need to count the negatives since it is only written once. You will also need to start at zero, or some other value that you will always start at. The bit stream...
Code: Select all
X: axis
011001111
Y:axis
011001111
2D Array:
001111000011111111
Broken down:
00,11,11,00,00,11,11,11,11
Table Format:
0,1,2,2,1,0,-1,-2
1,2,3,3,2,1,0,-1
2,3,4,4,3,2,1,0
2,3,4,4,3,2,1,0
1,2,3,3,2,1,0,-1
0,1,2,2,1,0,-1,-2
-1,0,1,1,0,-1,-2,-3
-2,-1,0,0,-1,-2,-3,-4
Which looks like...
Now, you should notice that this will only produce a linear surface, if you need sharp contours you will need to add extra bits. Use 000 as a scaling bit. Its up to you to decide whats best for your scaling parameters and how the bit stream evolves into incorporating things like that. However the idea is shown. You can implement it.