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"); }
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"); }
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); }
bool IMyCamera.IsInFrustum(BoundingBoxD boundingBox) { return IsInFrustum(boundingBox); }
public bool IsInFrustum(BoundingBoxD boundingBox) { return IsInFrustum(ref boundingBox); }
// 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; }
/// <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; }
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"); }
public bool IsInFrustum(BoundingBoxD boundingBox) { return(IsInFrustum(ref boundingBox)); }
// 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); }
public void Intersects(ref BoundingBoxD box, out double?result) { box.Intersects(ref this, out result); }
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)); }
bool IMyCamera.IsInFrustum(BoundingBoxD boundingBox) { return(IsInFrustum(boundingBox)); }
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)); }
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)); } } }
public BoundingBox(BoundingBoxD bbd) { this.Min = (Vector3)bbd.Min; this.Max = (Vector3)bbd.Max; }