Beispiel #1
0
        public List <Vector3> GetBoxFaceCornerPoints(BoxFace boxFace)
        {
            var points = new Vector3[BoxFaceCornerPoints.Count];

            Vector3 boxFaceCenter = GetBoxFaceCenter(boxFace);
            Vector2 boxFaceXZSize = GetBoxFaceSizeAlongFaceLocalXZAxes(boxFace, Vector3.one);
            Vector2 halfXZSize    = boxFaceXZSize * 0.5f;

            points[(int)BoxFaceCornerPoint.TopLeft]     = boxFaceCenter - BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x + BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y;
            points[(int)BoxFaceCornerPoint.TopRight]    = boxFaceCenter + BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x + BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y;
            points[(int)BoxFaceCornerPoint.BottomRight] = boxFaceCenter + BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x - BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y;
            points[(int)BoxFaceCornerPoint.BottomLeft]  = boxFaceCenter - BoxFaces.GetFaceRightAxis(boxFace) * halfXZSize.x - BoxFaces.GetFaceLookAxis(boxFace) * halfXZSize.y;

            return(new List <Vector3>(points));
        }
Beispiel #2
0
        public Vector3 GetBoxPoint(BoxPoint boxPoint)
        {
            Vector3 center  = Center;
            Vector3 extents = Extents;

            switch (boxPoint)
            {
            case BoxPoint.Center:

                return(center);

            case BoxPoint.FrontTopLeft:

                return(center - BoxFaces.GetFaceRightAxis(BoxFace.Front) * extents.x +
                       BoxFaces.GetFaceLookAxis(BoxFace.Front) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Front) * extents.z);

            case BoxPoint.FrontTopRight:

                return(center + BoxFaces.GetFaceRightAxis(BoxFace.Front) * extents.x +
                       BoxFaces.GetFaceLookAxis(BoxFace.Front) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Front) * extents.z);

            case BoxPoint.FrontBottomRight:

                return(center + BoxFaces.GetFaceRightAxis(BoxFace.Front) * extents.x -
                       BoxFaces.GetFaceLookAxis(BoxFace.Front) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Front) * extents.z);

            case BoxPoint.FrontBottomLeft:

                return(center - BoxFaces.GetFaceRightAxis(BoxFace.Front) * extents.x -
                       BoxFaces.GetFaceLookAxis(BoxFace.Front) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Front) * extents.z);

            case BoxPoint.BackTopLeft:

                return(center - BoxFaces.GetFaceRightAxis(BoxFace.Back) * extents.x +
                       BoxFaces.GetFaceLookAxis(BoxFace.Back) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Back) * extents.z);

            case BoxPoint.BackTopRight:

                return(center + BoxFaces.GetFaceRightAxis(BoxFace.Back) * extents.x +
                       BoxFaces.GetFaceLookAxis(BoxFace.Back) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Back) * extents.z);

            case BoxPoint.BackBottomRight:

                return(center + BoxFaces.GetFaceRightAxis(BoxFace.Back) * extents.x -
                       BoxFaces.GetFaceLookAxis(BoxFace.Back) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Back) * extents.z);

            case BoxPoint.BackBottomLeft:

                return(center - BoxFaces.GetFaceRightAxis(BoxFace.Back) * extents.x -
                       BoxFaces.GetFaceLookAxis(BoxFace.Back) * extents.y +
                       BoxFaces.GetFaceNormal(BoxFace.Back) * extents.z);

            default:

                return(Vector3.zero);
            }
        }