コード例 #1
0
ファイル: DragHitShape.cs プロジェクト: wwwK/AsteroidMiner
        /// <summary>
        /// This overload returns a point on the shape that is closest to the point passed in
        /// </summary>
        public Point3D?CastRay(Point3D point)
        {
            Point3D?retVal = null;

            switch (_shape)
            {
            case ShapeType.Line:
                #region Line

                retVal = Math3D.GetClosestPoint_Line_Point(_point, _direction, point);

                #endregion
                break;

            case ShapeType.Lines:
                #region Lines

                retVal = CastRay_LinesCircles(_lines, null, point);

                #endregion
                break;

            case ShapeType.Plane:
                #region Plane

                retVal = Math3D.GetClosestPoint_Plane_Point(_plane, point);

                #endregion
                break;

            case ShapeType.Circle:
                #region Circle

                retVal = Math3D.GetClosestPoint_Circle_Point(_plane, _point, _radius, point);

                #endregion
                break;

            case ShapeType.Circles:
                #region Circles

                retVal = CastRay_LinesCircles(null, _circles, point);

                #endregion
                break;

            case ShapeType.LinesCircles:
                #region LinesCircles

                retVal = CastRay_LinesCircles(_lines, _circles, point);

                #endregion
                break;

            case ShapeType.Cylinder:
                #region Cylinder

                retVal = Math3D.GetClosestPoint_Cylinder_Point(_point, _direction, _radius, point);

                #endregion
                break;

            case ShapeType.Sphere:
                #region Sphere

                retVal = Math3D.GetClosestPoint_Sphere_Point(_point, _radius, point);

                #endregion
                break;

            case ShapeType.Mesh:
                throw new ApplicationException("finish this");

            case ShapeType.None:
                retVal = null;
                break;

            default:
                throw new ApplicationException("Unknown ShapeType: " + _shape.ToString());
            }

            return(retVal);
        }