Ejemplo n.º 1
0
        void ICoreScene3D.DrawConvexSurface(ReadOnlySpan <Point3> vertices, ColorStyle style)
        {
            Span <XYZ> clippedVertices = stackalloc XYZ[vertices.Length * 2];

            var cvertices = _FrustumNearPlane.ClipPolygonToPlane(clippedVertices, Point3.AsNumerics(vertices));

            if (cvertices < 3)
            {
                return;
            }

            clippedVertices = clippedVertices.Slice(0, cvertices);

            Span <Point2> points = stackalloc Point2[clippedVertices.Length];

            for (int i = 0; i < points.Length; ++i)
            {
                var v = clippedVertices[i];

                points[i] = _ProjectPoint(v).SelectXY();
            }


            _RenderTarget.DrawConvexPolygon(points, style);
        }
Ejemplo n.º 2
0
        void IScene3D.DrawSurface(ReadOnlySpan <Point3> vertices, SurfaceStyle brush)
        {
            Span <XYZ> clippedVertices = stackalloc XYZ[vertices.Length * 2];

            var cvertices = _FrustumNearPlane.ClipPolygonToPlane(clippedVertices, Point3.AsNumerics(vertices));

            if (cvertices < 3)
            {
                return;
            }

            clippedVertices = clippedVertices.Slice(0, cvertices);

            Span <Point2> points = stackalloc Point2[clippedVertices.Length];

            var center = XYZ.Zero;

            for (int i = 0; i < points.Length; ++i)
            {
                var v = clippedVertices[i];

                center   += v;
                points[i] = _ProjectPoint(v).SelectXY();
            }

            center /= points.Length;

            brush = brush.WithOutline(_ProjectRadius(center, brush.Style.OutlineWidth));

            _RenderTarget.DrawPolygon(points, brush.Style);
        }