コード例 #1
0
        static void ApplyDashSettings(Material mat, DashStyle style, float thickness, bool useType = true)
        {
            bool dashed = style?.size > 0f;

            mat.SetFloat(ShapesMaterialUtils.propDashSize, dashed ? style.GetNetAbsoluteSize(true, thickness) : 0);
            if (dashed)
            {
                if (useType)
                {
                    mat.SetInt(ShapesMaterialUtils.propDashType, (int)style.type);
                    if (style.type.HasModifier())
                    {
                        mat.SetInt(ShapesMaterialUtils.propDashShapeModifier, (int)style.shapeModifier);
                    }
                }

                mat.SetInt(ShapesMaterialUtils.propDashSpace, (int)style.space);
                mat.SetInt(ShapesMaterialUtils.propDashSnap, (int)style.snap);
                mat.SetFloat(ShapesMaterialUtils.propDashOffset, style.offset);
                mat.SetFloat(ShapesMaterialUtils.propDashSpacing, style.GetNetAbsoluteSpacing(true, thickness));
            }
        }
コード例 #2
0
ファイル: Draw.cs プロジェクト: samuelhegner/Flocking_Unity2D
        [OvldGenCallTarget] public static void Line([OvldDefault(nameof(BlendMode))] ShapesBlendMode blendMode,
                                                    [OvldDefault(nameof(LineGeometry))] LineGeometry geometry,
                                                    [OvldDefault(nameof(LineEndCaps))] LineEndCap endCaps,
                                                    [OvldDefault(nameof(LineThicknessSpace))] ThicknessSpace thicknessSpace,
                                                    Vector3 start,
                                                    Vector3 end,
                                                    [OvldDefault(nameof(Color))] Color colorStart,
                                                    [OvldDefault(nameof(Color))] Color colorEnd,
                                                    [OvldDefault(nameof(LineThickness))] float thickness,
                                                    [OvldDefault(nameof(LineDashStyle))] DashStyle dashStyle = null)
        {
            Material mat = ShapesMaterialUtils.GetLineMat(geometry, endCaps)[blendMode];

            ApplyGlobalProperties(mat);
            mat.SetColor(ShapesMaterialUtils.propColor, colorStart);
            mat.SetColor(ShapesMaterialUtils.propColorEnd, colorEnd);
            mat.SetVector(ShapesMaterialUtils.propPointStart, start);
            mat.SetVector(ShapesMaterialUtils.propPointEnd, end);
            mat.SetFloat(ShapesMaterialUtils.propThickness, thickness);
            mat.SetInt(ShapesMaterialUtils.propAlignment, (int)geometry);
            mat.SetInt(ShapesMaterialUtils.propThicknessSpace, (int)thicknessSpace);
            mat.SetInt(ShapesMaterialUtils.propScaleMode, (int)ScaleMode);
            bool dashed = dashStyle?.size > 0f;

            mat.SetFloat(ShapesMaterialUtils.propDashSize, dashed ? dashStyle.GetNetAbsoluteSize(true, thickness) : 0);
            if (dashed)
            {
                if (geometry != LineGeometry.Volumetric3D)
                {
                    mat.SetInt(ShapesMaterialUtils.propDashType, (int)dashStyle.type);
                }
                mat.SetInt(ShapesMaterialUtils.propDashSpace, (int)dashStyle.space);
                mat.SetInt(ShapesMaterialUtils.propDashSnap, (int)dashStyle.snap);
                mat.SetFloat(ShapesMaterialUtils.propDashOffset, dashStyle.offset);
                mat.SetFloat(ShapesMaterialUtils.propDashSpacing, dashStyle.GetNetAbsoluteSpacing(true, thickness));
            }

            DrawMesh(Vector3.zero, Quaternion.identity, ShapesMeshUtils.GetLineMesh(geometry, endCaps), mat);
        }
コード例 #3
0
 [OvldGenCallTarget] static void Line_Internal([OvldDefault(nameof(LineEndCaps))] LineEndCap endCaps,
                                               [OvldDefault(nameof(LineThicknessSpace))] ThicknessSpace thicknessSpace,
                                               Vector3 start,
                                               Vector3 end,
                                               [OvldDefault(nameof(Color))] Color colorStart,
                                               [OvldDefault(nameof(Color))] Color colorEnd,
                                               [OvldDefault(nameof(LineThickness))] float thickness,
                                               [OvldDefault(nameof(LineDashStyle))] DashStyle dashStyle = null)
 {
     using (new IMDrawer(
                metaMpb: mpbLine,
                sourceMat: ShapesMaterialUtils.GetLineMat(Draw.LineGeometry, endCaps)[Draw.BlendMode],
                sourceMesh: ShapesMeshUtils.GetLineMesh(Draw.LineGeometry, endCaps, DetailLevel))) {
         MetaMpb.ApplyDashSettings(mpbLine, dashStyle, thickness);
         mpbLine.color.Add(colorStart.ColorSpaceAdjusted());
         mpbLine.colorEnd.Add(colorEnd.ColorSpaceAdjusted());
         mpbLine.pointStart.Add(start);
         mpbLine.pointEnd.Add(end);
         mpbLine.thickness.Add(thickness);
         mpbLine.alignment.Add((float)Draw.LineGeometry);
         mpbLine.thicknessSpace.Add((float)thicknessSpace);
         mpbLine.scaleMode.Add((float)ScaleMode);
     }
 }
コード例 #4
0
        static void DiscCore(ShapesBlendMode blendMode, ThicknessSpace spaceRadius, ThicknessSpace spaceThickness, bool hollow, bool sector, Vector3 pos, Quaternion rot, float radius, float thickness, Color colorInnerStart, Color colorOuterStart, Color colorInnerEnd, Color colorOuterEnd, DashStyle dashStyle = null, float angleRadStart = 0f, float angleRadEnd = 0f, ArcEndCap arcEndCaps = ArcEndCap.None)
        {
            if (sector && Mathf.Abs(angleRadEnd - angleRadStart) < 0.0001f)
            {
                return;
            }
            Material mat = ShapesMaterialUtils.GetDiscMaterial(hollow, sector)[blendMode];

            ApplyGlobalProperties(mat);
            mat.SetFloat(ShapesMaterialUtils.propRadius, radius);
            mat.SetInt(ShapesMaterialUtils.propRadiusSpace, (int)spaceRadius);
            mat.SetInt(ShapesMaterialUtils.propAlignment, (int)Draw.DiscGeometry);
            if (hollow)
            {
                mat.SetInt(ShapesMaterialUtils.propThicknessSpace, (int)spaceThickness);
                mat.SetFloat(ShapesMaterialUtils.propThickness, thickness);
                mat.SetInt(ShapesMaterialUtils.propScaleMode, (int)ScaleMode);
            }

            if (sector)
            {
                mat.SetFloat(ShapesMaterialUtils.propAngStart, angleRadStart);
                mat.SetFloat(ShapesMaterialUtils.propAngEnd, angleRadEnd);
                if (hollow)
                {
                    mat.SetFloat(ShapesMaterialUtils.propRoundCaps, (int)arcEndCaps);
                }
            }

            mat.SetColor(ShapesMaterialUtils.propColor, colorInnerStart);
            mat.SetColor(ShapesMaterialUtils.propColorOuterStart, colorOuterStart);
            mat.SetColor(ShapesMaterialUtils.propColorInnerEnd, colorInnerEnd);
            mat.SetColor(ShapesMaterialUtils.propColorOuterEnd, colorOuterEnd);

            ApplyDashSettings(mat, dashStyle, thickness);

            DrawMesh(pos, rot, ShapesMeshUtils.QuadMesh, mat);
        }
コード例 #5
0
        static void DiscCore(ShapesBlendMode blendMode, ThicknessSpace spaceRadius, ThicknessSpace spaceThickness, bool hollow, bool sector, Vector3 pos, Quaternion rot, float radius, float thickness, Color colorInnerStart, Color colorOuterStart, Color colorInnerEnd, Color colorOuterEnd, DashStyle dashStyle = null, float angleRadStart = 0f, float angleRadEnd = 0f, ArcEndCap arcEndCaps = ArcEndCap.None)
        {
            if (sector && Mathf.Abs(angleRadEnd - angleRadStart) < 0.0001f)
            {
                return;
            }
            Material mat = ShapesMaterialUtils.GetDiscMaterial(hollow, sector)[blendMode];

            mat.SetFloat(ShapesMaterialUtils.propRadius, radius);
            mat.SetInt(ShapesMaterialUtils.propRadiusSpace, (int)spaceRadius);
            if (hollow)
            {
                mat.SetInt(ShapesMaterialUtils.propThicknessSpace, (int)spaceThickness);
                mat.SetFloat(ShapesMaterialUtils.propThickness, thickness);
                mat.SetInt(ShapesMaterialUtils.propScaleMode, (int)ScaleMode);
            }

            if (sector)
            {
                mat.SetFloat(ShapesMaterialUtils.propAngStart, angleRadStart);
                mat.SetFloat(ShapesMaterialUtils.propAngEnd, angleRadEnd);
                if (hollow)
                {
                    mat.SetFloat(ShapesMaterialUtils.propRoundCaps, (int)arcEndCaps);
                }
            }

            mat.SetColor(ShapesMaterialUtils.propColor, colorInnerStart);
            mat.SetColor(ShapesMaterialUtils.propColorOuterStart, colorOuterStart);
            mat.SetColor(ShapesMaterialUtils.propColorInnerEnd, colorInnerEnd);
            mat.SetColor(ShapesMaterialUtils.propColorOuterEnd, colorOuterEnd);

            bool dashed = dashStyle?.size > 0f;

            mat.SetFloat(ShapesMaterialUtils.propDashSize, dashed ? dashStyle.GetNetAbsoluteSize(true, thickness) : 0);
            if (dashed)
            {
                mat.SetInt(ShapesMaterialUtils.propDashType, (int)dashStyle.type);
                mat.SetInt(ShapesMaterialUtils.propDashSpace, (int)dashStyle.space);
                mat.SetInt(ShapesMaterialUtils.propDashSnap, (int)dashStyle.snap);
                mat.SetFloat(ShapesMaterialUtils.propDashOffset, dashStyle.offset);
                mat.SetFloat(ShapesMaterialUtils.propDashSpacing, dashStyle.GetNetAbsoluteSpacing(true, thickness));
            }

            DrawMesh(pos, rot, ShapesMeshUtils.QuadMesh, mat);
        }
コード例 #6
0
        static void DiscCore(bool hollow, bool sector, float radius, float thickness, Color colorInnerStart, Color colorOuterStart, Color colorInnerEnd, Color colorOuterEnd, DashStyle dashStyle = null, float angleRadStart = 0f, float angleRadEnd = 0f, ArcEndCap arcEndCaps = ArcEndCap.None)
        {
            if (sector && Mathf.Abs(angleRadEnd - angleRadStart) < 0.0001f)
            {
                return;
            }

            using (new IMDrawer(mpbDisc, ShapesMaterialUtils.GetDiscMaterial(hollow, sector)[Draw.BlendMode], ShapesMeshUtils.QuadMesh[0])) {
                MetaMpb.ApplyDashSettings(mpbDisc, dashStyle, thickness);
                mpbDisc.radius.Add(radius);
                mpbDisc.radiusSpace.Add((int)Draw.DiscRadiusSpace);
                mpbDisc.alignment.Add((int)Draw.DiscGeometry);
                mpbDisc.thicknessSpace.Add((int)Draw.RingThicknessSpace);
                mpbDisc.thickness.Add(thickness);
                mpbDisc.scaleMode.Add((int)ScaleMode);
                mpbDisc.angStart.Add(angleRadStart);
                mpbDisc.angEnd.Add(angleRadEnd);
                mpbDisc.roundCaps.Add((int)arcEndCaps);
                mpbDisc.color.Add(colorInnerStart.ColorSpaceAdjusted());
                mpbDisc.colorOuterStart.Add(colorOuterStart.ColorSpaceAdjusted());
                mpbDisc.colorInnerEnd.Add(colorInnerEnd.ColorSpaceAdjusted());
                mpbDisc.colorOuterEnd.Add(colorOuterEnd.ColorSpaceAdjusted());
            }
        }