/// <summary> /// Given an AABB Box Entity and a CircleEntity, checks if these objects are overlapping /// </summary> /// <returns> returns true if 'Circle' and 'Box' are overlapping each other </returns> public static bool DetectCollision(CircleEntity Circle, BoxEntity Box) { Vector Edge = new Vector(Circle.x, Circle.y); //if the circle is on the left if (Circle.x < Box.Min.x) { //edge x to check is set to left side Edge.x = Box.Min.x; } //if the circle is on the right else if (Circle.x > Box.Max.x) { //edge x to check is set to the right side Edge.x = Box.Max.x; } //if the circle is above box if (Circle.y < Box.Min.y) { //edge y to check is set on top Edge.y = Box.Min.y; } //if the circle is below else if (Circle.y > Box.Max.y) { //edge y to check is set on the bottom Edge.y = Box.Max.y; } Vector Distance = new Vector(Edge.x - Circle.x, Edge.y - Circle.y); float RadiusSquared = Circle.Radius * Circle.Radius; Console.WriteLine(); return(Mathf.Pow(Distance.x, 2) + Mathf.Pow(Distance.y, 2) < RadiusSquared); }
public void AddPlayer(BoxCollider box) { BoxEntity entity = new BoxEntity(); entity.collider = box; entity.aabb = GetAABB(box); m_playerEntities.Add(entity); }
void Start() { var comps = StaticWorld.GetComponentsInChildren <BoxCollider>(); foreach (BoxCollider box in comps) //遍历所有gameobject { BoxEntity entity = new BoxEntity(); entity.collider = box; entity.aabb = GetAABB(box); m_staticEntities.Add(entity); } }
/// <summary> /// Given a 2D Point in space, Checks if the point is inside the AABB Collider of type BoxEntitiy /// </summary> /// <param name="Point"></param> /// <param name="Box"></param> /// <returns></returns> public static bool PointVBox(Vector Point, BoxEntity Box) { if (Point.x < Box.Min.x || Point.x > Box.Max.x) { return(false); } if (Point.y < Box.Min.y || Point.y > Box.Max.y) { return(false); } return(true); }
/// <summary> /// Given 2 AABB colliders of type BoxEntity, checks if these objects are overlapping /// </summary> /// <returns></returns> public static bool DetectCollision(BoxEntity A, BoxEntity B) { if (A.Max.x < B.Min.x || A.Min.x > B.Max.x) { return(false); } if (A.Max.y < B.Min.y || A.Min.y > B.Max.y) { return(false); } return(true); }
public async Task Handle(IDomainEvent <BoxAggregate, BoxId, BoxCreatedEvent> domainEvent) { var entity = new BoxEntity { AggregateId = domainEvent.AggregateIdentity.Value, Barcode = domainEvent.AggregateEvent.Barcode.Value, Created = domainEvent.Timestamp, Modified = domainEvent.Timestamp }; using (var db = new StorageDbContext(_dbContextOptions)) { await db.AddAsync(entity).ConfigureAwait(false); await db.SaveChangesAsync().ConfigureAwait(false); } }
private static async Task CreateCollaboration(BoxEntity folder, string searchUserId, BoxClient auClient, TimeLimiter throttle) { var requestParams = new BoxCollaborationRequest() { Item = new BoxRequestEntity() { Type = BoxType.folder, Id = folder.Id }, Role = Config.SearchUserRole, AccessibleBy = new BoxCollaborationUserRequest() { Id = searchUserId } }; await throttle; await auClient.CollaborationsManager.AddCollaborationAsync(requestParams); }
public TestScene() { //BackgroundColor = Color.AliceBlue; /* * Random rand = new Random(); * for (int i = 0; i < 150; i++) * { * PlayerEntity e = new PlayerEntity(); * e.Position = new Vector2(rand.Next(SandboxGame.Width), rand.Next(SandboxGame.Height)); * AddEntity(e); * } */ PlayerEntity p = new PlayerEntity(); Create(p); BoxEntity box = new BoxEntity(p.Renderer.Material); box.Position = new Vector2(64, 64); Create(box); }
public void SetEntityKind(Entitykind Kind) { Entities = Kind; if (Entities != Entitykind.CtrlRectangle) { if (CRect != null) { CRect.Device = null; } } switch (Entities) { case Entitykind.Boxentity: { Box = new BoxEntity(new xyz(0, 0, 0), new xyz(4, 5, 6)); break; } case Entitykind.PolyCurveExtruder: { PolyCurveEx = new PolyCurveExtruder(); Loca _Loca = new Loca(); CurveArray Curves0 = new CurveArray(); Curves0.Count = 4; Curves0[0] = new Line(new xy(-3, -3), new xy(-3, 4)); Curves0[1] = new Line(new xy(-3, 4), new xy(4, 4)); Curves0[2] = new Line(new xy(4, 4), new xy(4, -3)); Curves0[3] = new Line(new xy(4, -3), new xy(-3, -3)); _Loca.Add(Curves0); OpenGlDevice.CheckError(); CurveArray Curves1 = new CurveArray(); Curves1.Count = 4; Curves1[0] = new Line(new xy(0, 0), new xy(1, 0)); Curves1[1] = new Line(new xy(1, 0), new xy(1, 1)); Curves1[2] = new Line(new xy(1, 1), new xy(0, 1)); Curves1[3] = new Line(new xy(0, 1), new xy(0, 0)); _Loca.Add(Curves1); PolyCurveEx.DownPlane = new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)); PolyCurveEx.UpPlane = new Plane(new xyz(0, 0, 4), new xyz(0, 0.5, 1)); PolyCurveEx.Loca = _Loca; PolyCurveEx.ShowUpPlane = true; PolyCurveEx.ShowDownPlane = true; PolyCurveEx.Height = -1; PolyCurveEx.Direction = new xyz(0, 1, 1); break; } case Entitykind.CoordinateAxis: { Axis = new CoordinateAxis(); Axis.FullSize = true; Axis.ShowText = true; Axis.TextHeight = 1; Axis.Color = Color.Black; Axis.Size = new xyz(10, 20, 30); Axis.Devider = new xyz(4, 4, 4); Axis.DeviderLineLength = 0.3; Axis.LeftAndRight = true; Axis.Dim3d = true; Axis.ShowDevider = true; break; } case Entitykind.TextEntity: { Text = new TextEntity(); Text.Text = "Drawing3d"; Text.Size = 4; Text.Italic = true; Text.Position = new xyz(-5, 0, 0); break; } case Entitykind.Interpolator: { Interpolator = new Interpolator3D(); Interpolator.Points = new xyz[, ] { { new xyz(-3, -3, 0), new xyz(-3, 0, 2), new xyz(-3, 3, 0), new xyz(-3, 6, -2) }, { new xyz(0, -3, 2), new xyz(0, 0, 3), new xyz(0, 3, 2), new xyz(0, 6, -2) }, { new xyz(3, -3, 3), new xyz(3, 0, 2), new xyz(3, 3, 1), new xyz(3, 6, -2) }, { new xyz(6, -3, 2), new xyz(6, 0, 0), new xyz(6, 3, 0), new xyz(6, 6, -2) } }; break; }; case Entitykind.Zoom: { Zoom = new RectCtrlZoom(this); Zoom.Device = this; Zoom.Color = Color.White; break; } case Entitykind.CtrlRectangle: { CRect = new CtrlRectangle(this); CRect.Color = Color.Black; CRect.MarkerColor = Color.Red; CRect.Creating = false; CRect.Rectangle = new RectangleF(-1, -1, 6, 5); CRect.CompileEnable = false; Triangle = new xyArray(); Triangle.data = new xy[] { new xy(0, 0), new xy(2, 2), new xy(4, 0), new xy(0, 0) }; CRect.TransformItems.Add(Triangle); // S = new SphereEntity(new xyz(0, 0, 0), 2); //S = new BoxEntity(new xyz(0, 0, 0), new xyz(4, 4, 4)); //S.CompileEnable = false; // CRect.TransformItems.Add(S); // CRect.LiveTransform = true; break; } case Entitykind.Profiler: { xyzArray A = new xyzArray(); A.data = new xyz[] { new xyz(-3, 0, 0), new xyz(-3, -4, 0), new xyz(3, -4, 0), new xyz(3, 0, 0) }; Loca _Loca = new Loca(); CurveArray Curves0 = new CurveArray(); Curves0.Count = 4; Curves0[0] = new Line(new xy(-1, -1), new xy(-1, 2)); Curves0[1] = new Line(new xy(-1, 2), new xy(2, 2)); Curves0[2] = new Line(new xy(2, 2), new xy(2, -1)); Curves0[3] = new Line(new xy(2, -1), new xy(-1, -1)); _Loca.Add(Curves0); OpenGlDevice.CheckError(); CurveArray Curves1 = new CurveArray(); Curves1.Count = 4; Curves1[0] = new Line(new xy(0, 0), new xy(1, 0)); Curves1[1] = new Line(new xy(1, 0), new xy(1, 1)); Curves1[2] = new Line(new xy(1, 1), new xy(0, 1)); Curves1[3] = new Line(new xy(0, 1), new xy(0, 0)); _Loca.Add(Curves1); Profil = new Profiler(); Profil.CompileEnable = false; Profil.Trace = A; Profil.Transverse = _Loca; Profil.CloseFirst = true; Profil.CloseLast = true; break; } case Entitykind.ActiveCursor: { // ActiveC.CrossColor = Color.Red; break; } case Entitykind.SphereEntity: { Sphere = new SphereEntity(new xyz(3, 2, 1), 4); // Sphere.CompileEnable = false; // Sphere = new SphereEntity(new xyz(0, 0, 0), 4); break; } case Entitykind.Cone: { Cone = new Cone(3, 5); break; } case Entitykind.Arrow: { Arrow = new Arrow(); Arrow.Transformation = Matrix.Translation(new xyz(5, 0, 0)); Arrow.SetShaftAndTop(new xyz(-10, 0, 0), new xyz(0, 0, 0)); Arrow.Size = 8; drawSphere(new xyz(0, 0, 0), 0.5); break; } } Selector.RefreshSnapBuffer(); }
protected virtual void PrintEntity(BoxEntity item) { Reporter.WriteInformation($"Item ID: {item.Id}"); Reporter.WriteInformation($"Item Type: {item.Type}"); }