Exemplo n.º 1
0
        /*
         *     C5----C6
         *    / |    /|
         *   C1----C2 |
         *   |  C8  | C7
         *   | /    |/     C3->C7  Forward
         *   C4----C3
         */

        public static void ExtractBoxColliderWorldPointsV2(BoxDefinition BoxDefinition, out Vector3 C1, out Vector3 C2, out Vector3 C3, out Vector3 C4, out Vector3 C5, out Vector3 C6, out Vector3 C7, out Vector3 C8)
        {
            ExtractBoxColliderLocalPoints(BoxDefinition.LocalCenter, BoxDefinition.LocalSize, out Vector3 lC1, out Vector3 lC2, out Vector3 lC3, out Vector3 lC4, out Vector3 lC5,
                                          out Vector3 lC6, out Vector3 lC7, out Vector3 lC8);

            var boxLocalToWorld = BoxDefinition.LocalToWorld;

            C1 = boxLocalToWorld.MultiplyPoint(lC1);
            C2 = boxLocalToWorld.MultiplyPoint(lC2);
            C3 = boxLocalToWorld.MultiplyPoint(lC3);
            C4 = boxLocalToWorld.MultiplyPoint(lC4);
            C5 = boxLocalToWorld.MultiplyPoint(lC5);
            C6 = boxLocalToWorld.MultiplyPoint(lC6);
            C7 = boxLocalToWorld.MultiplyPoint(lC7);
            C8 = boxLocalToWorld.MultiplyPoint(lC8);
        }
Exemplo n.º 2
0
 public static FrustumPointsPositions ConvertBoxColliderToFrustumPoints(BoxDefinition BoxDefinition)
 {
     ExtractBoxColliderWorldPointsV2(BoxDefinition, out Vector3 FC1, out Vector3 FC2, out Vector3 FC3, out Vector3 FC4, out Vector3 FC5, out Vector3 FC6, out Vector3 FC7, out Vector3 FC8);
     return(new FrustumPointsPositions(FC1, FC2, FC3, FC4, FC5, FC6, FC7, FC8));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Procedurally generates probe points on a <see cref="BoxDefinition"/>.
        /// If the provided density is too high, a minimum set of points (represented by Box corners) are provided.
        /// </summary>
        public static VisibilityProbe GenerateAndAlocateVisibilityProbeLocalPointsFrom(float ProbeDensityPerUnit, BoxDefinition BoxDefinition)
        {
            Intersection.ExtractBoxColliderLocalPoints(BoxDefinition.LocalCenter, BoxDefinition.LocalSize,
                                                       out Vector3 C1, out Vector3 C2, out Vector3 C3, out Vector3 C4, out Vector3 C5, out Vector3 C6, out Vector3 C7, out Vector3 C8);

            float BoxWidth  = Vector3.Distance(C1, C2);
            float BoxHeight = Vector3.Distance(C1, C4);
            float BoxDepth  = Vector3.Distance(C1, C5);

            CalculateProbeNumberAndIntervalFromDensity(BoxWidth, ProbeDensityPerUnit, out int WidthNumberOfProbe, out float WidthDistanceBetweenProbes);
            CalculateProbeNumberAndIntervalFromDensity(BoxHeight, ProbeDensityPerUnit, out int HeightNumberOfProbe, out float HeightDistanceBetweenProbes);
            CalculateProbeNumberAndIntervalFromDensity(BoxDepth, ProbeDensityPerUnit, out int DepthNumberOfProbe, out float DepthDistanceBetweenProbes);

            int             totalNumberOfProbe = (WidthNumberOfProbe + HeightNumberOfProbe - 2 + DepthNumberOfProbe - 2) * 4;
            VisibilityProbe VisibilityProbe    = VisibilityProbe.Allocate(totalNumberOfProbe);

            int probeCounter = 0;

            FeedVisibilityProbe(C1, C2, true, true, WidthNumberOfProbe, WidthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C4, C3, true, true, WidthNumberOfProbe, WidthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C5, C6, true, true, WidthNumberOfProbe, WidthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C8, C7, true, true, WidthNumberOfProbe, WidthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);


            FeedVisibilityProbe(C1, C4, false, false, HeightNumberOfProbe, HeightDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C2, C3, false, false, HeightNumberOfProbe, HeightDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C5, C8, false, false, HeightNumberOfProbe, HeightDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C6, C7, false, false, HeightNumberOfProbe, HeightDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);


            FeedVisibilityProbe(C1, C5, false, false, DepthNumberOfProbe, DepthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C2, C6, false, false, DepthNumberOfProbe, DepthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C4, C8, false, false, DepthNumberOfProbe, DepthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);
            FeedVisibilityProbe(C3, C7, false, false, DepthNumberOfProbe, DepthDistanceBetweenProbes, ref VisibilityProbe, ref probeCounter);

            return(VisibilityProbe);
        }