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()); } }
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); }
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); } }
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); } }