示例#1
0
        public Plane GetBoxFacePlane(BoxFace boxFace)
        {
            switch (boxFace)
            {
            case BoxFace.Back:

                return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Back), GetBoxPoint(BoxPoint.BackBottomLeft)));

            case BoxFace.Front:

                return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Front), GetBoxPoint(BoxPoint.FrontBottomLeft)));

            case BoxFace.Left:

                return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Left), GetBoxPoint(BoxPoint.FrontBottomLeft)));

            case BoxFace.Right:

                return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Right), GetBoxPoint(BoxPoint.FrontBottomRight)));

            case BoxFace.Top:

                return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Top), GetBoxPoint(BoxPoint.FrontTopLeft)));

            case BoxFace.Bottom:

                return(new Plane(BoxFaces.GetFaceNormal(BoxFace.Bottom), GetBoxPoint(BoxPoint.FrontBottomLeft)));

            default:

                return(new Plane());
            }
        }
示例#2
0
 public void NextExtensionPlane()
 {
     if (CanActivateNextExtensionPlane())
     {
         _extensionPlaneBoxFace = BoxFaces.GetNext(_extensionPlaneBoxFace);
         SceneView.RepaintAll();
     }
 }
示例#3
0
        private void CorrectHitDataForThinPlanes()
        {
            float boxSizeAlongHitNormal = _hitBox.GetSizeAlongDirection(_hitNormal);

            if (boxSizeAlongHitNormal < 1e-4f &&
                Vector3.Dot(_hitNormal, SceneViewCamera.Camera.transform.forward) > 0.0f)
            {
                _hitFace   = BoxFaces.GetOpposite(_hitFace);
                _hitNormal = _hitBox.GetBoxFacePlane(_hitFace).normal;
            }
        }
 public void NextExtensionPlane()
 {
     if (Settings.TileConnectionSettings.UseTileConnections)
     {
         Debug.LogWarning("The extension plane can not be changed when using tile connections. For 3D tiles it will always reside at the bottom of the tiles (in local space) " +
                          "and for 2D sprites it will reside behind the sprite plane (in local space).");
     }
     if (CanActivateNextExtensionPlane())
     {
         _extensionPlaneBoxFace = BoxFaces.GetNext(_extensionPlaneBoxFace);
         SceneView.RepaintAll();
     }
 }
示例#5
0
        public CoordinateSystem GetBoxFaceCoordinateSystem(BoxFace boxFace)
        {
            var coordSystem = new CoordinateSystem();

            Vector3 origin      = GetBoxFaceCenter(boxFace);
            Vector3 boxFaceUp   = BoxFaces.GetFaceNormal(boxFace);
            Vector3 boxFaceLook = BoxFaces.GetFaceLookAxis(boxFace);

            coordSystem.SetOriginPosition(origin);
            coordSystem.SetRotation(Quaternion.LookRotation(boxFaceLook, boxFaceUp));

            return(coordSystem);
        }
示例#6
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));
        }
示例#7
0
        public Vector3 GetBoxFaceCenter(BoxFace boxFace)
        {
            Vector3 center  = Center;
            Vector3 extents = Extents;

            switch (boxFace)
            {
            case BoxFace.Back:

                return(center + BoxFaces.GetFaceNormal(BoxFace.Back) * extents.z);

            case BoxFace.Front:

                return(center + BoxFaces.GetFaceNormal(BoxFace.Front) * extents.z);

            case BoxFace.Left:

                return(center + BoxFaces.GetFaceNormal(BoxFace.Left) * extents.x);

            case BoxFace.Right:

                return(center + BoxFaces.GetFaceNormal(BoxFace.Right) * extents.x);

            case BoxFace.Top:

                return(center + BoxFaces.GetFaceNormal(BoxFace.Top) * extents.y);

            case BoxFace.Bottom:

                return(center + BoxFaces.GetFaceNormal(BoxFace.Bottom) * extents.y);

            default:

                return(Vector3.zero);
            }
        }
示例#8
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);
            }
        }