terrain height


09-06-2015 16:54:00

i want to know the height of terrain >>> i used this code in tutorial (mogre tutorial intermediate 2)
// Setup the scene query
Vector3 camPos = camera.Position;
Ray cameraRay = new Ray(new Vector3(camPos.x, 5000.0f, camPos.z),Vector3.NEGATIVE_UNIT_Y);
RaySceneQueryResult result = mRaySceneQuery.Execute();
RaySceneQueryResult.Enumerator itr = (RaySceneQueryResult.Enumerator)(result.GetEnumerator());

but it sometimes give me an exception when it reach to the phrase:
RaySceneQueryResult result = mRaySceneQuery.Execute();
the exception is: Attemped to read or write protected memory.This is often indicate that other memory is corrupted

help me please ??