internal Rayd CastFromCamera(GraphicsDevice graphicsDevice, Vector2 mouseVector) { Matrixd worldd = Matrixd.CreateRotationZ(-cameraRotX) * Matrixd.CreateRotationX(cameraRotY); double distance = 9 * Math.Pow(0.5, cameraZoom); Matrixd viewd = CameraMatrixManager.GetWorldViewd(distance); Matrixd projectiond = CameraMatrixManager.GetWorldProjectiond(distance, graphicsDevice.Viewport.AspectRatio); return(Rayd.CastFromCamera(graphicsDevice, mouseVector.X, mouseVector.Y, projectiond, viewd, worldd)); }
// yup, it returns lat/long only in the range you'd expect internal Vector3d GetLatLongOfCoord(GraphicsDevice graphicsDevice, double x, double y) { Matrixd worldd = Matrixd.CreateRotationZ(-cameraRotX) * Matrixd.CreateRotationX(cameraRotY); double distance = 9 * Math.Pow(0.5, cameraZoom); Matrixd viewd = CameraMatrixManager.GetWorldViewd(distance); Matrixd projectiond = CameraMatrixManager.GetWorldProjectiond(distance, graphicsDevice.Viewport.AspectRatio); Rayd ray = Rayd.CastFromCamera(graphicsDevice, x, y, projectiond, viewd, worldd); Vector3d intersection = ray.IntersectionSphere(new Vector3d(0, 0, 0), 1); // angle 0 if (intersection == null) { return(null); } return(ToLatLong(intersection)); }