コード例 #1
0
ファイル: ShapeFactory.cs プロジェクト: wyb314/Physics2D.Net
 public static IShape CreateMultiPolygon(Vector2D[][] polygons, Scalar gridSpacing, ScalarColor4[][] colors)
 {
     if (polygons.Length == 1)
     {
         return(CreatePolygon(polygons[0], gridSpacing, colors[0]));
     }
     else
     {
         MultiPolygonShape shape = new MultiPolygonShape(polygons, gridSpacing);
         shape.Tag = DrawableFactory.CreateMultiPolygon(polygons, colors);
         return(shape);
     }
 }
コード例 #2
0
ファイル: ShapeFactory.cs プロジェクト: wyb314/Physics2D.Net
 public static IShape CreateColoredMultiPolygon(Vector2D[][] polygons, Scalar gridSpacing)
 {
     if (polygons.Length == 1)
     {
         return(CreateColoredPolygon(polygons[0], gridSpacing));
     }
     else
     {
         MultiPolygonShape shape   = new MultiPolygonShape(polygons, gridSpacing);
         ScalarColor3[][]  colors  = new ScalarColor3[polygons.Length][];
         Vector2D[][]      reduced = new Vector2D[polygons.Length][];
         for (int index = 0; index < polygons.Length; ++index)
         {
             reduced[index] = VertexHelper.Reduce(polygons[index]);
             colors[index]  = CreateColor3Array(reduced[index].Length);
         }
         shape.Tag = DrawableFactory.CreateMultiPolygon(reduced, colors);
         return(shape);
     }
 }
コード例 #3
0
ファイル: ShapeFactory.cs プロジェクト: wyb314/Physics2D.Net
        public static IShape CreateSprite(SurfacePolygons surfacePolygons, Surface bumpmap, bool xInverted, bool yInverted, int reduce, Scalar subdivide, Scalar gridSpacing, Light light)
        {
            Vector2D[][] polygons = surfacePolygons.Polygons;
            for (int index = 1; index < reduce; index++)
            {
                polygons = VertexHelper.ReduceRange(polygons, index);
            }
            polygons = VertexHelper.SubdivideRange(polygons, subdivide);
            Vector2D centroid = surfacePolygons.Offset;
            IShape   shape;

            if (polygons.Length == 1)
            {
                shape = new PolygonShape(polygons[0], gridSpacing);
            }
            else
            {
                shape = new MultiPolygonShape(polygons, gridSpacing);
            }
            shape.Tag = DrawableFactory.CreateSprite(surfacePolygons.Surface, bumpmap, xInverted, yInverted, centroid, light);
            return(shape);
        }