Exemple #1
0
        public void BoundingBoxIntersectCustom()
        {
            var point  = new VRageMath.Vector3D(5d, 3.5d, 4d);
            var vector = new VRageMath.Vector3D(-0.03598167d, 0.0110336d, 0.9992915d);
            var box    = new VRageMath.BoundingBoxD(new VRageMath.Vector3D(3d, 3d, 2d), new VRageMath.Vector3D(7d, 4d, 6d));

            VRageMath.Vector3D?p = box.IntersectsRayAt(point, vector * 1000);

            Assert.AreEqual(new VRageMath.Vector3D(4.9176489098920966d, 3.5151384795308953d, 6.00000000000319d), p.Value, "Should Equal");
        }
Exemple #2
0
        public void BoundingBoxIntersectKeen()
        {
            var point  = new VRageMath.Vector3D(5d, 3.5d, 4d);
            var vector = new VRageMath.Vector3D(-0.03598167d, 0.0110336d, 0.9992915d);
            var box    = new VRageMath.BoundingBoxD(new VRageMath.Vector3D(3d, 3d, 2d), new VRageMath.Vector3D(7d, 4d, 6d));
            var ray    = new VRageMath.RayD(point, vector);

            double?f = box.Intersects(ray);

            Assert.AreEqual(0, f, "Should Equal");
        }
Exemple #3
0
        void UpdateBoundingFrustum()
        {
            //  Update frustum
            BoundingFrustum.Matrix    = ViewProjectionMatrix;
            BoundingFrustumFar.Matrix = ViewProjectionMatrixFar;

            //  Update bounding box
            BoundingBox = BoundingBoxD.CreateInvalid();
            BoundingBox.Include(ref BoundingFrustum);

            //  Update bounding sphere
            BoundingSphere = MyUtils.GetBoundingSphereFromBoundingBox(ref BoundingBox);
        }
Exemple #4
0
 bool IMyCamera.IsInFrustum(BoundingBoxD boundingBox)
 {
     return IsInFrustum(boundingBox);
 }
Exemple #5
0
 public bool IsInFrustum(BoundingBoxD boundingBox)
 {
     return IsInFrustum(ref boundingBox);
 }
Exemple #6
0
 //  Checks if specified bounding box is in actual bounding frustum
 //  IMPORTANT: If you observe bad result of this test, check how you transform your bounding box.
 //  Don't use BoundingBox.Transform. Instead transform box manualy and then create new box.
 public bool IsInFrustum(ref BoundingBoxD boundingBox)
 {
     VRageMath.ContainmentType result;
     BoundingFrustum.Contains(ref boundingBox, out result);
     return result != VRageMath.ContainmentType.Disjoint;
 }
Exemple #7
0
        void UpdateBoundingFrustum()
        {
            //  Update frustum
            BoundingFrustum.Matrix = ViewProjectionMatrix;
            BoundingFrustumFar.Matrix = ViewProjectionMatrixFar;

            //  Update bounding box
            BoundingBox = BoundingBoxD.CreateInvalid();
            BoundingBox.Include(ref BoundingFrustum);

            //  Update bounding sphere
            BoundingSphere = MyUtils.GetBoundingSphereFromBoundingBox(ref BoundingBox);
        }
 /// <summary>
 /// Creates an instance of BoundingBox from BoundingBoxD (helper for transformed BBs)
 /// </summary>
 /// <param name="bbd"></param>
 public BoundingBox(BoundingBoxD bbd)
 {
     this.Min = bbd.Min;
     this.Max = bbd.Max;
 }
Exemple #9
0
        public void BoundingBoxIntersectCustom()
        {
            var point = new VRageMath.Vector3D(5d, 3.5d, 4d);
            var vector = new VRageMath.Vector3D(-0.03598167d, 0.0110336d, 0.9992915d);
            var box = new VRageMath.BoundingBoxD(new VRageMath.Vector3D(3d, 3d, 2d), new VRageMath.Vector3D(7d, 4d, 6d));

            VRageMath.Vector3D? p = box.IntersectsRayAt(point, vector * 1000);

            Assert.AreEqual(new VRageMath.Vector3D(4.9176489098920966d, 3.5151384795308953d, 6.00000000000319d), p.Value, "Should Equal");
        }
Exemple #10
0
 public bool IsInFrustum(BoundingBoxD boundingBox)
 {
     return(IsInFrustum(ref boundingBox));
 }
Exemple #11
0
 //  Checks if specified bounding box is in actual bounding frustum
 //  IMPORTANT: If you observe bad result of this test, check how you transform your bounding box.
 //  Don't use BoundingBox.Transform. Instead transform box manualy and then create new box.
 public bool IsInFrustum(ref BoundingBoxD boundingBox)
 {
     VRageMath.ContainmentType result;
     BoundingFrustum.Contains(ref boundingBox, out result);
     return(result != VRageMath.ContainmentType.Disjoint);
 }
Exemple #12
0
 public void Intersects(ref BoundingBoxD box, out double?result)
 {
     box.Intersects(ref this, out result);
 }
Exemple #13
0
 public double?Intersects(BoundingBoxD box) =>
 box.Intersects(this);
        // Determine if this box contains, intersects, or is disjoint from the given BoundingBox.
        public ContainmentType Contains(ref BoundingBox box)
        {
            BoundingBoxD boxD = (BoundingBoxD)box;

            return(Contains(ref boxD));
        }
Exemple #15
0
 bool IMyCamera.IsInFrustum(BoundingBoxD boundingBox)
 {
     return(IsInFrustum(boundingBox));
 }
Exemple #16
0
        public void BoundingBoxIntersectKeen()
        {
            var point = new VRageMath.Vector3D(5d, 3.5d, 4d);
            var vector = new VRageMath.Vector3D(-0.03598167d, 0.0110336d, 0.9992915d);
            var box = new VRageMath.BoundingBoxD(new VRageMath.Vector3D(3d, 3d, 2d), new VRageMath.Vector3D(7d, 4d, 6d));
            var ray = new VRageMath.RayD(point, vector);

            double? f = box.Intersects(ray);

            Assert.AreEqual(0, f, "Should Equal");
        }
 IMyVoxelBase IMyVoxelMaps.GetVoxelMapWhoseBoundingBoxIntersectsBox(ref VRageMath.BoundingBoxD boundingBox, IMyVoxelBase ignoreVoxelMap)
 {
     return(GetVoxelMapWhoseBoundingBoxIntersectsBox(ref boundingBox, ignoreVoxelMap as Game.Entities.MyVoxelBase));
 }
Exemple #18
0
        public static void ShowMessageToUsersInRange(IMyFunctionalBlock block, string message, int time = 2000, bool bIsError = false)
        {
            bool isMe = false;

            if (MyAPIGateway.Players == null || MyAPIGateway.Entities == null || MyAPIGateway.Session == null || MyAPIGateway.Utilities == null)
            {
                return;
            }

            if (MyAPIGateway.Multiplayer.IsServer || MyAPIGateway.Session.Player == null)
            {
                // DS, look for players
                VRageMath.BoundingBoxD box = block.GetTopMostParent().PositionComp.WorldAABB;

                List <IMyEntity>    entities = MyAPIGateway.Entities.GetEntitiesInAABB(ref box);
                HashSet <IMyPlayer> players  = new HashSet <IMyPlayer>();

                foreach (var entity in entities)
                {
                    if (entity == null)
                    {
                        continue;
                    }

                    var player = MyAPIGateway.Players.GetPlayerControllingEntity(entity);

                    if (player != null && entity.PositionComp.WorldAABB.Intersects(box))
                    {
                        players.Add(player);
                    }
                }

                foreach (var player in players)
                {
                    MessageUtils.SendMessageToPlayer(player.SteamUserId, new MessageText()
                    {
                        Message = message, Timeout = time, Error = bIsError
                    });
                }
            }
            else
            {
                if (MyAPIGateway.Players == null || MyAPIGateway.Entities == null || MyAPIGateway.Session == null || MyAPIGateway.Utilities == null ||
                    MyAPIGateway.Session.Player == null || MyAPIGateway.Session.Player.Controller == null ||
                    MyAPIGateway.Session.Player.Controller.ControlledEntity == null)
                {
                    return;
                }

                VRageMath.BoundingBoxD box = block.GetTopMostParent().PositionComp.WorldAABB;

                List <IMyEntity> entities = MyAPIGateway.Entities.GetEntitiesInAABB(ref box);

                foreach (var entity in entities)
                {
                    if (entity == null)
                    {
                        continue;
                    }

                    if (entity.EntityId == MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetTopMostParent().EntityId&&
                        entity.PositionComp.WorldAABB.Intersects(box))
                    {
                        isMe = true;
                        break;
                    }
                }

                if ((MyAPIGateway.Players.GetPlayerControllingEntity(block.GetTopMostParent()) != null &&
                     MyAPIGateway.Session.Player != null &&
                     MyAPIGateway.Session.Player.PlayerID == MyAPIGateway.Players.GetPlayerControllingEntity(block.GetTopMostParent()).PlayerID) ||
                    isMe)
                {
                    MyAPIGateway.Utilities.ShowNotification(message, time, (bIsError ? MyFontEnum.Red : MyFontEnum.White));
                }
            }
        }
Exemple #19
0
 public BoundingBox(BoundingBoxD bbd)
 {
     this.Min = (Vector3)bbd.Min;
     this.Max = (Vector3)bbd.Max;
 }