public unsafe void CalculateNormals()
{
Vector3 normal;
HardwareVertexBuffer buffer =
terrain.vertexBufferBinding.GetBuffer( NORMAL );
IntPtr norm = buffer.Lock( BufferLocking.Discard );
float* normPtr = (float*)norm.ToPointer();
int count = 0;
for ( int j = 0; j < size; j++ )
{
for ( int i = 0; i < size; i++ )
{
GetNormalAt( GetVertex( i, j, 0 ), GetVertex( i, j, 2 ), out normal );
normPtr[ count++ ] = normal.x;
normPtr[ count++ ] = normal.y;
normPtr[ count++ ] = normal.z;
}
}
buffer.Unlock();
}