Exemplo n.º 1
0
        public float MinDistanceToObstacle(Vector3 point)
        {
            const float R = 0;
            Vector3     c = point;

            return(AllObstacles.Aggregate(float.MaxValue, (current, obstacle) => TestOneObstacleOverlap(current, R, obstacle.Radius, c, obstacle.Center)));
        }
Exemplo n.º 2
0
        public static void AddOneObstacle()
        {
            if (obstacleCount < maxObstacleCount)
            {
                // pick a random center and radius,
                // loop until no overlap with other obstacles and the home base
                float   r;
                Vector3 c;
                float   minClearance;
                float   requiredClearance = Globals.Seeker.Radius * 4;               // 2 x diameter
                do
                {
                    r            = Utilities.Random(1.5f, 4);
                    c            = Vector3Helpers.RandomVectorOnUnitRadiusXZDisk() * Globals.MaxStartRadius * 1.1f;
                    minClearance = float.MaxValue;
                    System.Diagnostics.Debug.WriteLine(String.Format("[{0}, {1}, {2}]", c.X, c.Y, c.Z));
                    for (int so = 0; so < AllObstacles.Count; so++)
                    {
                        minClearance = TestOneObstacleOverlap(minClearance, r, AllObstacles[so].Radius, c, AllObstacles[so].Center);
                    }

                    minClearance = TestOneObstacleOverlap(minClearance, r, Globals.HomeBaseRadius - requiredClearance, c, Globals.HomeBaseCenter);
                }while (minClearance < requiredClearance);

                // add new non-overlapping obstacle to registry
                AllObstacles.Add(new SphericalObstacle(r, c));
                obstacleCount++;
            }
        }
Exemplo n.º 3
0
 public static void RemoveOneObstacle()
 {
     if (obstacleCount > 0)
     {
         obstacleCount--;
         AllObstacles.RemoveAt(obstacleCount);
     }
 }
Exemplo n.º 4
0
        public static void RemoveOneObstacle()
        {
            if (ObstacleCount <= 0)
            {
                return;
            }

            ObstacleCount--;
            AllObstacles.RemoveAt(ObstacleCount);
        }
Exemplo n.º 5
0
        public static void AddOneObstacle()
        {
            if (obstacleCount < maxObstacleCount)
            {
                // pick a random center and radius,
                // loop until no overlap with other obstacles and the home base
                //float r = 15;
                //Vector3 c = Vector3.Up * r * (-0.5f * maxObstacleCount + obstacleCount);
                float   r = Utilities.Random(0.5f, 2);
                Vector3 c = Vector3Helpers.RandomVectorInUnitRadiusSphere() * worldRadius * 1.1f;

                // add new non-overlapping obstacle to registry
                AllObstacles.Add(new SphericalObstacle(r, c));
                obstacleCount++;
            }
        }
Exemplo n.º 6
0
        private static void AddOneObstacle()
        {
            if (_obstacleCount >= MAX_OBSTACLE_COUNT)
            {
                return;
            }

            // pick a random center and radius,
            // loop until no overlap with other obstacles and the home base
            //float r = 15;
            //Vector3 c = Vector3.Up * r * (-0.5f * maxObstacleCount + obstacleCount);
            float   r = RandomHelpers.Random(0.5f, 2);
            Vector3 c = Vector3Helpers.RandomVectorInUnitRadiusSphere() * WORLD_RADIUS * 1.1f;

            // add new non-overlapping obstacle to registry
            AllObstacles.Add(new SphericalObstacle(r, c));
            _obstacleCount++;
        }
Exemplo n.º 7
0
        public static void AddOneObstacle(float radius)
        {
            // pick a random center and radius,
            // loop until no overlap with other obstacles and the home base
            float   r;
            Vector3 c;
            float   minClearance;
            float   requiredClearance = Globals.Seeker.Radius * 4;           // 2 x diameter

            do
            {
                r            = RandomHelpers.Random(1.5f, 4);
                c            = Vector3Helpers.RandomVectorOnUnitRadiusXZDisk() * Globals.MAX_START_RADIUS * 1.1f;
                minClearance = AllObstacles.Aggregate(float.MaxValue, (current, t) => TestOneObstacleOverlap(current, r, t.Radius, c, t.Center));

                minClearance = TestOneObstacleOverlap(minClearance, r, radius - requiredClearance, c, Globals.HomeBaseCenter);
            }while (minClearance < requiredClearance);

            // add new non-overlapping obstacle to registry
            AllObstacles.Add(new SphericalObstacle(r, c));
            ObstacleCount++;
        }