Ejemplo n.º 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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 bool IMyCamera.IsInFrustum(BoundingBoxD boundingBox)
 {
     return IsInFrustum(boundingBox);
 }
Ejemplo n.º 5
0
 public bool IsInFrustum(BoundingBoxD boundingBox)
 {
     return IsInFrustum(ref boundingBox);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
 /// <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;
 }
Ejemplo n.º 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");
        }
Ejemplo n.º 10
0
 public bool IsInFrustum(BoundingBoxD boundingBox)
 {
     return(IsInFrustum(ref boundingBox));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 12
0
 public void Intersects(ref BoundingBoxD box, out double?result)
 {
     box.Intersects(ref this, out result);
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 15
0
 bool IMyCamera.IsInFrustum(BoundingBoxD boundingBox)
 {
     return(IsInFrustum(boundingBox));
 }
Ejemplo n.º 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");
        }
Ejemplo n.º 17
0
 IMyVoxelBase IMyVoxelMaps.GetVoxelMapWhoseBoundingBoxIntersectsBox(ref VRageMath.BoundingBoxD boundingBox, IMyVoxelBase ignoreVoxelMap)
 {
     return(GetVoxelMapWhoseBoundingBoxIntersectsBox(ref boundingBox, ignoreVoxelMap as Game.Entities.MyVoxelBase));
 }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 19
0
 public BoundingBox(BoundingBoxD bbd)
 {
     this.Min = (Vector3)bbd.Min;
     this.Max = (Vector3)bbd.Max;
 }