bool CalculateIsAboveHorizonToCamera(DoubleVector3 cameraLocation, DoubleVector3 planetLocation, DoubleVector3 closestVertex)
        {
            // Taken from http://www.crappycoding.com/2009/04/

            // TODO: This algorithm is poor.  Implement this algorithm instead:
            // http://www.gamedev.net/community/forums/mod/journal/journal.asp?jn=263350&reply_id=3173799

            // TODO: sometimes the mesh is so large and we're so close the surface that none of the sampled
            // vertices are above the horizon.  That causes problems when we want to do early termination
            // when we do a draw walk on the QuadNode tree (see comments there).  Can we add a test here to
            // see if we're inside the mesh's bounding box?

            var planetToCamera = DoubleVector3.Normalize(cameraLocation - planetLocation);
            var planetToMesh   = DoubleVector3.Normalize(closestVertex - planetLocation);

            var horizonAngle = Math.Acos(_planetRadius * 0.99 / DoubleVector3.Distance(planetLocation, cameraLocation));
            var angleToMesh  = Math.Acos(DoubleVector3.Dot(planetToCamera, planetToMesh));

            return(horizonAngle > angleToMesh);
        }
Beispiel #2
0
 void UpdateStatistics(DoubleVector3 cameraLocation)
 {
     _statistics.CameraAltitude = DoubleVector3.Distance(_location, cameraLocation) - _radius;
 }