public static void DrawExtent(this SpriteBatch spriteBatch, IExtent extent, Color color, Matrix transformFromWorldToCamera) { ICompositeExtent composite = extent as ICompositeExtent; if (null != composite) { DrawCompositeExtent(spriteBatch, composite, color, transformFromWorldToCamera); return; } IPolygonExtent poly = extent as IPolygonExtent; if (null != poly) { DrawPolygon(spriteBatch, poly, color, transformFromWorldToCamera); return; } ICircularExtent circle = extent as ICircularExtent; if (null != circle) { DrawCircle(spriteBatch, circle, color, transformFromWorldToCamera); return; } throw new NotImplementedException("can only draw extents that are either polygons or circles"); }
public static bool AreInIntersectionExtentVsExtent(IPolygonExtent a, IExtent b) { ICompositeExtent composite = b as ICompositeExtent; if (null != composite) { return(a.Intersects(composite)); } composite = a as ICompositeExtent; if (null != composite) { return(b.Intersects(composite)); } ICircularExtent circle = b as ICircularExtent; if (null != circle) { _tempCircleB.Reset(b); return(circle.Intersects(_tempCircleB)); } IPolygonExtent polygon = b as IPolygonExtent; if (null != polygon) { return(a.Intersects(polygon)); } throw new InvalidOperationException("Extent must be a circle or polygon"); }
public bool Intersects(IExtent other) { if (null == other) { return(false); } ICompositeExtent composite = other as ICompositeExtent; if (null != composite) { return(Intersects(composite)); } IPolygonExtent polygon = other as IPolygonExtent; if (null != polygon) { return(Intersects(polygon)); } ICircularExtent circle = other as ICircularExtent; if (null != circle) { return(Intersects(circle)); } throw new NotImplementedException("otherExtent must be either circle or polygon"); }
protected override void LoadContent() { _textures = new Texture2DCache(typeof(Textures)); _spriteBatch = new SpriteBatch(Globals.GraphicsDevice); _markerAnchor_Blue = StaticSprite.Acquire(_textures[(int)Textures.Marker_Blue], new Vector2(4, 4)); _markerAnchor_Blue.LayerDepth = 0; _renderParamsTemplate.GetTexture_MarkCenter = new Getter <ISprite>(() => { return(_markerAnchor_Blue); }); _markerTopLeft_Red = StaticSprite.Acquire(_textures[(int)Textures.Marker_Red], new Vector2(4, 4)); _markerTopLeft_Red.LayerDepth = 0; _renderParamsTemplate.GetTexture_MarkOrigin = new Getter <ISprite>(() => { return(_markerTopLeft_Red); }); _markerCompositeAnchor_Green = StaticSprite.Acquire(_textures[(int)Textures.Marker_Green], new Vector2(4, 4)); _markerCompositeAnchor_Green.LayerDepth = 0; _renderParamsTemplate.GetTexture_MarkTopLeft = new Getter <ISprite>(() => { return(_markerCompositeAnchor_Green); }); List <Vector2> vertices = new List <Vector2>(); vertices.Add(new Vector2(100, 100)); vertices.Add(new Vector2(150, 50)); vertices.Add(new Vector2(200, 100)); vertices.Add(new Vector2(120, 120)); _polygon = new PolygonExtent(); _polygon.Reset(vertices); _polygon.ReAnchor(_polygon.ActualCenter); _contentLoaded = true; }
private static void DrawPolygon(this SpriteBatch spriteBatch, IPolygonExtent extent, Color color, Matrix transformFromWorldToCamera) { for (int i = 0; i < extent.ReferenceRegion.NumSides; i++) { _extentTraceVertices[i] = Vector2.Transform(extent.ReferenceRegion.Vertices[i], extent.TranslateFrom); } spriteBatch.DrawPolygon(_extentTraceVertices, extent.NumSides, color, transformFromWorldToCamera); }
public override bool Intersects(IPolygonExtent other) { foreach (var child in Items) { if (child.Intersects(other)) { return(true); } } return(false); }
public static void DrawPolygonExtent(this SpriteBatch spriteBatch, IPolygonExtent extent, Matrix transformFromWorldToCamera, RenderParams renderParams) { if (RenderMode.TraceBoundingBox == (renderParams.Mode & RenderMode.TraceBoundingBox)) { DrawBoundingBox(spriteBatch, extent, renderParams.TraceBoundingBoxColor, transformFromWorldToCamera); DrawCircle(spriteBatch, extent.ActualCenter, extent.InnerRadius, renderParams.TraceBoundingBoxColor, transformFromWorldToCamera); DrawCircle(spriteBatch, extent.ActualCenter, extent.OuterRadius, renderParams.TraceBoundingBoxColor, transformFromWorldToCamera); } if (RenderMode.TraceRenderingExtent == (renderParams.Mode & RenderMode.TraceRenderingExtent)) { DrawPolygon(spriteBatch, extent, renderParams.TraceRenderingExtentColor, transformFromWorldToCamera); DrawKeyPoints(spriteBatch, extent, renderParams, transformFromWorldToCamera); } }
public static void DrawKeyPoints(this SpriteBatch spriteBatch, IPolygonExtent extent, RenderParams renderParams, Matrix transformFromWorldToCamera) { ISprite marker; if (null != renderParams.GetTexture_MarkCenter) { marker = renderParams.GetTexture_MarkCenter(); marker.RenderingExtent.Anchor = Vector2.Transform(extent.ReferenceRegion.Center, extent.TranslateFrom); DrawSprite(spriteBatch, marker, transformFromWorldToCamera); } if (null != renderParams.GetTexture_MarkOrigin) { marker = renderParams.GetTexture_MarkOrigin(); marker.RenderingExtent.Anchor = Vector2.Transform(extent.Origin, extent.TranslateFrom); DrawSprite(spriteBatch, marker, transformFromWorldToCamera); } }
public static bool AreInIntersectionCircleVsExtent(ICircularExtent a, IExtent b) { ICircularExtent circle = b as ICircularExtent; if (null != circle) { return(a.Intersects(circle)); } IPolygonExtent polygon = b as IPolygonExtent; if (null != polygon) { return(a.Intersects(polygon)); } throw new InvalidOperationException("Extent must be a circle or polygon"); }
public static bool AreInIntersectionCircleVsCircle(IPolygonExtent a, IExtent b) { ICircularExtent circle = b as ICircularExtent; if (null != circle) { _tempCircleA.Reset(a); return(circle.Intersects(_tempCircleA)); } IPolygonExtent polygon = b as IPolygonExtent; if (null != polygon) { _tempCircleB.Reset(polygon); return(a.Intersects(_tempCircleB)); } throw new InvalidOperationException("Extent must be a circle or polygon"); }
protected override void LoadContent() { _textures = new Texture2DCache(typeof(Textures)); _spriteBatch = new SpriteBatch(Globals.GraphicsDevice); _fonts = new SpriteFontCache(typeof(Fonts)); _markerIntersect_Blue = StaticSprite.Acquire(_textures[(int)Textures.Marker_Blue], new Vector2(4, 4)); _markerIntersect_Blue.LayerDepth = 0; _markerPoint_Red = StaticSprite.Acquire(_textures[(int)Textures.Marker_Red], new Vector2(4, 4)); _markerPoint_Red.LayerDepth = 0; _markerPoint_Red.RenderingExtent.Anchor = new Vector2(_xValue, _yValue); var vertices = new List <Vector2>(); vertices.Add(new Vector2(22, 122)); vertices.Add(new Vector2(66, 23)); vertices.Add(new Vector2(150, 5)); vertices.Add(new Vector2(293, 78)); vertices.Add(new Vector2(256, 194)); vertices.Add(new Vector2(230, 86)); vertices.Add(new Vector2(202, 175)); vertices.Add(new Vector2(113, 157)); vertices.Add(new Vector2(168, 69)); vertices.Add(new Vector2(165, 148)); vertices.Add(new Vector2(203, 60)); vertices.Add(new Vector2(105, 50)); vertices.Add(new Vector2(77, 140)); vertices.Add(new Vector2(40, 147)); _insidePolygon = XenString.Acquire(); _insidePolygon.Reset(_fonts[(int)Fonts.Arial], "Inside!"); _polygonExtent = new PolygonExtent(); _polygonExtent.Reset(vertices); }
private static void DrawPolygon(this SpriteBatch spriteBatch, IPolygonExtent extent, Color color) { DrawPolygon(spriteBatch, extent, color, Matrix.Identity); }
public override bool Intersects(IPolygonExtent other) { return(ShapeUtility.Intersects(other, this)); }
public abstract bool Intersects(IPolygonExtent other);
public static bool AreInIntersectionExtentVsCircle(IPolygonExtent a, IExtent b) { _tempCircleB.Reset(b); return(a.Intersects(_tempCircleB)); }
public static void DrawPolygonExtent(this SpriteBatch spriteBatch, IPolygonExtent extent) { DrawPolygonExtent(spriteBatch, extent, RenderParams.Default); }
public static void DrawPolygonExtent(this SpriteBatch spriteBatch, IPolygonExtent extent, Matrix transformFromWorldToCamera) { DrawPolygonExtent(spriteBatch, extent, transformFromWorldToCamera, RenderParams.Default); }
public static void DrawPolygonExtent(this SpriteBatch spriteBatch, IPolygonExtent extent, RenderParams renderParams) { DrawPolygonExtent(spriteBatch, extent, Matrix.Identity, renderParams); }