normals for a terrain

BlitzMax Forums/BlitzMax OpenGL Programming/normals for a terrain

I'm going to give you enough info to research and do this yourself. You'll feel better than if someone handed it to you on a plate, and trust me, it's not really difficult and you'll realise that it's not "too much math" at all.

To compute the normal of a plane (your quad) you take the cross-product of 2 vectors on that plane (you can easily compute 2 vectors from your quad by using 3 of its vertices). Here's the math for that.

http://www.lighthouse3d.com/opengl/maths/

That gives you a vector which points 90degrees to the plane.

Next (if you're going to use it for lighting calculations) that vector needs to be 'normalised' - that is to say its length needs to be 1. You do this by dividing the vector by its length. To compute its length use pythagoras theorem. In 3d that is, length = sqrt( (x*x) + (y*y) + (z*z) )