Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
 public override bool Intersects(ICompositeExtent other)
 {
     foreach (var child in Items)
     {
         if (child.Intersects(other))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
 private static void DrawCompositeExtent(this SpriteBatch spriteBatch, ICompositeExtent 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 );
     foreach (var child in extent.Items)
     {
         DrawExtent(spriteBatch, child, color, transformFromWorldToCamera);
     }
 }
Ejemplo n.º 6
0
 public override bool Intersects(ICompositeExtent other)
 {
     return(other.Intersects(this));
 }
Ejemplo n.º 7
0
 private static void DrawCompositeExtent(this SpriteBatch spriteBatch, ICompositeExtent extent, Color color)
 {
     DrawCompositeExtent(spriteBatch, extent, color, Matrix.Identity);
 }
Ejemplo n.º 8
0
 public abstract bool Intersects(ICompositeExtent other);