Ejemplo n.º 1
0
        [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);

            ApplyDashSettings(mat, dashStyle, thickness, useType: geometry != LineGeometry.Volumetric3D);

            DrawMesh(Vector3.zero, Quaternion.identity, ShapesMeshUtils.GetLineMesh(geometry, endCaps), mat);
        }
Ejemplo n.º 2
0
 [OvldGenCallTarget] 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)
 {
     using (new IMDrawer(
                metaMpb: mpbLine,
                sourceMat: ShapesMaterialUtils.GetLineMat(geometry, endCaps)[blendMode],
                sourceMesh: ShapesMeshUtils.GetLineMesh(geometry, endCaps, DetailLevel))) {
         MetaMpb.ApplyDashSettings(mpbLine, dashStyle, thickness);
         mpbLine.color.Add(colorStart);
         mpbLine.colorEnd.Add(colorEnd);
         mpbLine.pointStart.Add(start);
         mpbLine.pointEnd.Add(end);
         mpbLine.thickness.Add(thickness);
         mpbLine.alignment.Add((float)geometry);
         mpbLine.thicknessSpace.Add((float)thicknessSpace);
         mpbLine.scaleMode.Add((float)ScaleMode);
     }
 }
Ejemplo n.º 3
0
        [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);
        }
Ejemplo n.º 4
0
 [OvldGenCallTarget] static void Line_Internal([OvldDefault(nameof(LineEndCaps))] LineEndCap endCaps,
                                               [OvldDefault(nameof(ThicknessSpace))] ThicknessSpace thicknessSpace,
                                               Vector3 start,
                                               Vector3 end,
                                               [OvldDefault(nameof(Color))] Color colorStart,
                                               [OvldDefault(nameof(Color))] Color colorEnd,
                                               [OvldDefault(nameof(Thickness))] float thickness)
 {
     using (new IMDrawer(
                metaMpb: mpbLine,
                sourceMat: ShapesMaterialUtils.GetLineMat(Draw.LineGeometry, endCaps)[Draw.BlendMode],
                sourceMesh: ShapesMeshUtils.GetLineMesh(Draw.LineGeometry, endCaps, DetailLevel))) {
         MetaMpb.ApplyDashSettings(mpbLine, 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);                   // this is redundant for 3D lines, but, that's okay, fixing that makes things messier
         mpbLine.thicknessSpace.Add((float)thicknessSpace);
         mpbLine.scaleMode.Add((float)ScaleMode);
     }
 }