Beispiel #1
0
        protected virtual void DrawPolygonBody(Body body, Silver.Weight.Raw.Shapes.Polygon polygon)
        {
            System.Windows.Shapes.Polygon poly = body.UserData as System.Windows.Shapes.Polygon;
            ROVector2f[] points = polygon.GetVertices(body.GetPosition(), body.Rotation);
            if (poly == null)
            {
                poly = new System.Windows.Shapes.Polygon();

                poly.StrokeThickness = 2;
                poly.Stroke = new SolidColorBrush(Colors.Yellow);

                PointCollection pts = new PointCollection();

                for (int i = 0; i < points.Length; i++)
                {

                    pts[i] = new Point((double)points[i].X, (double)points[i].Y);

                }
                poly.Points = pts;
                canvas.Children.Add(poly);
                body.UserData = poly;
            }
            else
            {
                PointCollection pts = new PointCollection();
                for (int i = 0; i < points.Length; i++)
                {
                    pts[i] = new Point((double)points[i].X, (double)points[i].Y);
                }
                poly.Points = pts;
            }
        }