Yeah, it is a mesh (memblock matrix), but there is a similar function to get ground height for this kind of "matrix" and that function can be found in the file "makematrixmem.dba" which also has a lot more functions.
The lightmapping is almost completely done by the two gosubs. First you'll need to calculate the normals and if you have that data and you have the height data and you have all the arrays initialized that I use too, you can simply call the createlightmap function to do the lightmapping. So now you know this, you can make your own functions.
I can also explain the technique used, so you can make your own code for it. I also explained it on the LLRGT forum, so I'll also put it on here.
Now to explain the technique, I can best show how it works in 2D. The same way can be done in 3d. This is only for the shadows. The lighting itself is not so hard to do.
Below you'll see an image of a basic 2d terrain (blue line). You can also see the sunlight direction. This technique works with some sort of 'shadow' value.
Ok. Let's say that P1 is in the light. That means his shadow value is 0. To calculate the shadow value of P2 we don't need all the points that came before him, we only need the shadow value of P1. So how do we calculate this shadow value for P2? Simple! . We go from P2 and the go against the sun direction until we reach the x-position of P1. Then we can calculate the difference of that height with the height of P1 which is called DH1. If we say that in this case DH1 is negative, then we can calculate the shadow value, by subtracting DH1 from the shadow value of P1. So if this new shadow value is positive you are in the shadow. If the shadow value is negative, you should set it to 0 again, because the point will be in direct light. Then you can repeat this process for P3 and P4 and you'll find out that when you get to P4 the shadow value will be 0 again which is correct because P4 should be in the light again.
This same technique can be used in 3d, however it isn't perfect, because a terrain is made out of triangles and not square planes. However this small error is not very noticable, so we just use it, for speed. But still it is harder in 3d. You need to go against the sun direction until you reach one of the sides of the squares where the point is in. This is usually between two points. So then you would need to interpolate the height and the shadow value to those coordinates. The rest will work the same.
This shadow value technique has some advantages. You can use the shadow value to see if you are near the edge of a shadow or not. Say you have an edge variable you could say that when the shadow value is higher than that edge value you give it the shadow color and when it is below the edge variable you can interpolate the lighting from shadow color to light color. This will result in soft edges. Also it is easy to increase the lightmap detail. Since we are dealing with square planes (well, almost) we can just interpolate the shadow values of the points you already have to get the new shadow values, which will create the right effect. I used that technique for the screenshot, which is actually the same as the realtime demo with the only difference being that I increased the resolution to 1024x1024 instead of 64x64. Does it look blurry? No, because instead of interpolating the light colors, I interpolate the shadow values.
And that's how it basically works. I hope I made some sense .
Kevil