CHAPTER 5 ■ GETTING THE MOST OUT OF VERTICES
460
{
ray.Direction /= 2.0f;
Vector3 nextPoint = ray.Position + ray.Direction;
float heightAtNextPoint = terrain.GetExactHeightAt(nextPoint.X,
➥
-nextPoint.Z);
if (nextPoint.Y > heightAtNextPoint)
{
ray.Position = nextPoint;
currentError = ray.Position.Y - heightAtNextPoint;
}
if (counter++ == 1000) break;
}
return ray.Position;
}
Note that if the while loop is iterated for 1,000 times, this code will break out of the while
loop.
5-11. Load Data from an XML File
The Problem
YouwanttoloaddatafromanXMLfileintoyourXNAgameproject.Youcan do this by read-
ing from the file when your XNA project starts using default .NET file I/O functionality, but this
will not work when running the game on ...