normals for a terrain

BlitzMax Forums/BlitzMax OpenGL Programming/normals for a terrain

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

I'm creating a simple heightmap for my isometric game.
But I have some problems with the calculation of normals to make the lighting look nice. The problem is that I have no idea of how to do it.
A google search gives me a lot of stuff, but they all use vectors, something I don't use. And they also talks about triangles, I'm using a quad.
They talk a lot about math and I suck at it. :P

This is the code for a tile:
Type Tile

	Field y1:Float, y2:Float, y3:Float, y4:Float
	Field nx:Float[4], ny:Float[4], nz:Float[4] ' Normal for this tile

	' Resources	
	Field gold:Int, metal:Int, stone:Int	
	
	
	Method CalcNormal()
		'TODO: Implement me!
                ' I make the normal point straight up for the moment.
		For Local n = 0 Until 4
			nx[n] = 0
			ny[n] = 1
			nz[n] = 0
		Next
	EndMethod
	
	Method Render( x:Float, z:Float )
	
		glBindTexture( GL_TEXTURE_2D, Textures.grass )
		glBegin( GL_QUADS )	
			glNormal3f( nx[0],ny[0],nz[0] ) ; glTexCoord2f(0, 0) ; glVertex3f( x,y1,z )
			glNormal3f( nx[1],ny[0],nz[1] ) ; glTexCoord2f(1, 0) ; glVertex3f( x+1,y2,z )
			glNormal3f( nx[2],ny[0],nz[2] ) ; glTexCoord2f(1, 1) ; glVertex3f( x+1,y3,z+1 )
			glNormal3f( nx[3],ny[0],nz[3] ) ; glTexCoord2f(0, 1) ; glVertex3f( x,y4,z+1 )
		glEnd()
	EndMethod
	
EndType


CalcNormal() really needs some work. But I don't know how to fix it. :P
Each corner of a tile has a height (y1 to y4) and a normal nx[],ny[],nz[].
Can anyone give me some help on this?