コード例 #1
0
            private static VECTOR3 _Extrude(ICoreScene3D dc, ReadOnlySpan <PointNode> nodes, bool closed, int divisions, ColorStyle color, bool flipFaces)
            {
                Span <POINT3> aa = stackalloc POINT3[divisions];
                Span <POINT3> bb = stackalloc POINT3[divisions];

                var maixAxis = _GetMainAxis(nodes);

                if (closed)
                {
                    var n = nodes[nodes.Length - 1];

                    n._FillSection(aa, divisions, maixAxis + n.Axis);
                    // aa.Reverse();
                }

                for (int s = 0; s < nodes.Length; ++s)
                {
                    var n = nodes[s];

                    n._FillSection(bb, divisions, maixAxis + n.Axis);

                    if (s > 0 || closed)
                    {
                        for (int i = 0; i < bb.Length; ++i)
                        {
                            var j = (i + 1) % bb.Length;

                            if (flipFaces)
                            {
                                dc.DrawConvexSurface(POINT3.Array(aa[i], aa[j], bb[j], bb[i]), color);
                            }
                            else
                            {
                                dc.DrawConvexSurface(POINT3.Array(aa[j], aa[i], bb[i], bb[j]), color);
                            }
                        }
                    }

                    bb.CopyTo(aa);
                }

                return(maixAxis);
            }
コード例 #2
0
            private readonly void _DrawCap(ICoreScene3D dc, ColorStyle fillColor, LineCapStyle cap, Span <POINT3> corners, bool dir)
            {
                var axis = Direction * (Diameter * 0.5f);

                if (dir)
                {
                    axis = -axis;
                }

                switch (cap)
                {
                case LineCapStyle.Round:
                    for (int i = 0; i < corners.Length; ++i)
                    {
                        var j = (i + 1) % corners.Length;

                        var i0 = corners[i].XYZ;
                        var j0 = corners[j].XYZ;
                        var i1 = VECTOR3.Lerp(Point, i0 + axis, 0.7f);
                        var j1 = VECTOR3.Lerp(Point, j0 + axis, 0.7f);

                        dc.DrawConvexSurface(POINT3.Array(i0, j0, j1, i1), fillColor);
                        dc.DrawConvexSurface(POINT3.Array(Point + axis, i1, j1), fillColor);
                    }
                    break;

                case LineCapStyle.Triangle:
                    for (int i = 0; i < corners.Length; ++i)
                    {
                        var j = (i + 1) % corners.Length;
                        dc.DrawConvexSurface(POINT3.Array(Point + axis, corners[i], corners[j]), fillColor);
                    }
                    break;


                default: dc.DrawConvexSurface(corners, fillColor); break;
                }
            }