Quote: "Im quite useless when it comes to the more advanced math. Where exactly are you adding the normals to the terrain?"
Maths has nothing to do with it - it's all in the code:
` ** make terrain
xscale#=3: yscale#=0.6: zscale#=3
make object terrain 1 ` create the terrain object
set terrain heightmap 1, "terrainB.png" ` set the heightmap
set terrain scale 1, xscale#, yscale#, zscale# ` set the scale
set terrain split 1, nTiles ` split nTiles by nTiles
set terrain tiling 1, 16 ` detail map tiling
set terrain texture 1, 1, 2 ` base and detail texture
build terrain 1 ` finally build the terrain
width#=object size x(1): depth#=object size z(1)
` ** fiddle with Advanced Terrain structure
` to include normals and exclude vertex diffuse
convert object fvf 1, 530 ` XYZ+NORMAL+TEX2
` set object normals 1 ` this method gives visible seams
terrainNormalGenerator(1) ` this method seems OK (!)
It should be obvious from that snippet that:
1. I first build the terrain (
build terrain, etc,

).
2. I convert the terrain's format to include normals (remember the terrain IS object 1).
3. I then calculate the normals using the function
terrainNormalGenerator() (there's a clue in the name of the function I think).
The function
terrainNormalGenerator() is then doing the following
4. First find the dimensions of the terrain - max width, distance between neighbouring vertices, etc.
5. Then find the heights of each vertex using the vertexdata commands and store them in an array.
6. Finally calculate the normals at each vertex using the height data from step 5 and the XZ interval data from step 4 (again there's a clue in the use of the command
set vertexdata normals 
).
Hope this helps.
I can try to explain the maths involved if I must ...
[I haven't attempted to smooth or average the normals by looking at all polys adjacent to a vertex as is sometimes done - it might be possible to improve on my calculation by doing that but, in my demos, the extra effort didn't seem to be worthwhile. Notice that I didn't use the built-in DBPro
set object normals command - that gives visible seams between AT limbs when lit at certain angles.]