Beispiel #1
0
        [OvldGenCallTarget] public static void Polyline([OvldDefault(nameof(BlendMode))] ShapesBlendMode blendMode,
                                                        PolylinePath path,
                                                        [OvldDefault("false")] bool closed,
                                                        [OvldDefault(nameof(PolylineGeometry))] PolylineGeometry geometry,
                                                        [OvldDefault(nameof(PolylineJoins))] PolylineJoins joins,
                                                        [OvldDefault(nameof(LineThickness))] float thickness,
                                                        [OvldDefault(nameof(LineThicknessSpace))] ThicknessSpace thicknessSpace,
                                                        [OvldDefault(nameof(Color))] Color color)
        {
            if (path.EnsureMeshIsReadyToRender(closed, joins, out Mesh mesh) == false)
            {
                return;                 // no points defined in the mesh
            }
            switch (path.Count)
            {
            case 0:
                Debug.LogWarning("Tried to draw polyline with no points");
                return;

            case 1:
                Debug.LogWarning("Tried to draw polyline with only one point");
                return;
            }

            Material matPolyLine = ShapesMaterialUtils.GetPolylineMat(joins)[blendMode];

            ApplyGlobalProperties(matPolyLine);
            matPolyLine.SetFloat(ShapesMaterialUtils.propThickness, thickness);
            matPolyLine.SetFloat(ShapesMaterialUtils.propThicknessSpace, (int)thicknessSpace);
            matPolyLine.SetColor(ShapesMaterialUtils.propColor, color);
            matPolyLine.SetInt(ShapesMaterialUtils.propAlignment, (int)geometry);
            matPolyLine.SetInt(ShapesMaterialUtils.propScaleMode, (int)ScaleMode);
            if (joins == PolylineJoins.Miter)
            {
                DrawMesh(Vector3.zero, Quaternion.identity, mesh, matPolyLine);
            }
            else
            {
                Material matPolyLineJoins = ShapesMaterialUtils.GetPolylineJoinsMat(joins)[blendMode];
                ApplyGlobalProperties(matPolyLineJoins);
                matPolyLineJoins.SetFloat(ShapesMaterialUtils.propThickness, thickness);
                matPolyLineJoins.SetFloat(ShapesMaterialUtils.propThicknessSpace, (int)thicknessSpace);
                matPolyLineJoins.SetColor(ShapesMaterialUtils.propColor, color);
                matPolyLineJoins.SetInt(ShapesMaterialUtils.propAlignment, (int)geometry);
                matPolyLineJoins.SetInt(ShapesMaterialUtils.propScaleMode, (int)ScaleMode);
                DrawTwoSubmeshes(Vector3.zero, Quaternion.identity, mesh, matPolyLine, matPolyLineJoins);
            }
        }
Beispiel #2
0
        [OvldGenCallTarget] static void Polyline_Internal(PolylinePath path,
                                                          [OvldDefault("false")] bool closed,
                                                          [OvldDefault(nameof(PolylineGeometry))] PolylineGeometry geometry,
                                                          [OvldDefault(nameof(PolylineJoins))] PolylineJoins joins,
                                                          [OvldDefault(nameof(Thickness))] float thickness,
                                                          [OvldDefault(nameof(ThicknessSpace))] ThicknessSpace thicknessSpace,
                                                          [OvldDefault(nameof(Color))] Color color)
        {
            if (path.EnsureMeshIsReadyToRender(closed, joins, out Mesh mesh) == false)
            {
                return;                 // no points defined in the mesh
            }
            switch (path.Count)
            {
            case 0:
                Debug.LogWarning("Tried to draw polyline with no points");
                return;

            case 1:
                Debug.LogWarning("Tried to draw polyline with only one point");
                return;
            }

            void ApplyToMpb(MpbPolyline2D mpb)
            {
                mpb.thickness.Add(thickness);
                mpb.thicknessSpace.Add((int)thicknessSpace);
                mpb.color.Add(color.ColorSpaceAdjusted());
                mpb.alignment.Add((int)geometry);
                mpb.scaleMode.Add((int)ScaleMode);
            }

            if (DrawCommand.IsAddingDrawCommandsToBuffer)              // mark as used by this command to prevent destroy in dispose
            {
                path.RegisterToCommandBuffer(DrawCommand.CurrentWritingCommandBuffer);
            }

            using (new IMDrawer(mpbPolyline, ShapesMaterialUtils.GetPolylineMat(joins)[Draw.BlendMode], mesh, 0))
                ApplyToMpb(mpbPolyline);

            if (joins.HasJoinMesh())
            {
                using (new IMDrawer(mpbPolylineJoins, ShapesMaterialUtils.GetPolylineJoinsMat(joins)[Draw.BlendMode], mesh, 1))
                    ApplyToMpb(mpbPolylineJoins);
            }
        }
Beispiel #3
0
        [OvldGenCallTarget] static void Polyline([OvldDefault(nameof(BlendMode))] ShapesBlendMode blendMode,
                                                 PolylinePath path,
                                                 [OvldDefault("false")] bool closed,
                                                 [OvldDefault(nameof(PolylineGeometry))] PolylineGeometry geometry,
                                                 [OvldDefault(nameof(PolylineJoins))] PolylineJoins joins,
                                                 [OvldDefault(nameof(LineThickness))] float thickness,
                                                 [OvldDefault(nameof(LineThicknessSpace))] ThicknessSpace thicknessSpace,
                                                 [OvldDefault(nameof(Color))] Color color)
        {
            if (path.EnsureMeshIsReadyToRender(closed, joins, out Mesh mesh) == false)
            {
                return;                 // no points defined in the mesh
            }
            switch (path.Count)
            {
            case 0:
                Debug.LogWarning("Tried to draw polyline with no points");
                return;

            case 1:
                Debug.LogWarning("Tried to draw polyline with only one point");
                return;
            }

            void ApplyToMpb(MpbPolyline mpb)
            {
                mpb.thickness.Add(thickness);
                mpb.thicknessSpace.Add((int)thicknessSpace);
                mpb.color.Add(color);
                mpb.alignment.Add((int)geometry);
                mpb.scaleMode.Add((int)ScaleMode);
            }

            using (new IMDrawer(mpbPolyline, ShapesMaterialUtils.GetPolylineMat(joins)[blendMode], mesh, 0))
                ApplyToMpb(mpbPolyline);

            if (joins.HasJoinMesh())
            {
                using (new IMDrawer(mpbPolylineJoins, ShapesMaterialUtils.GetPolylineJoinsMat(joins)[blendMode], mesh, 1))
                    ApplyToMpb(mpbPolylineJoins);
            }
        }