static void DrawOutline(IChiselHandleRenderer renderer, ChiselSphereDefinition definition, Vector3[] vertices, LineMode lineMode)
        {
            var sides = definition.horizontalSegments;

            var extraVertices = 2;
            var bottomVertex  = 1;
            var topVertex     = 0;

            var rings = (vertices.Length - extraVertices) / sides;

            var prevColor = renderer.color;
            var color     = prevColor;

            color.a *= 0.6f;

            renderer.color = color;
            for (int i = 0, j = extraVertices; i < rings; i++, j += sides)
            {
                renderer.DrawLineLoop(vertices, j, sides, lineMode: lineMode, thickness: kHorzLineThickness, dashSize: kLineDash);
            }

            for (int k = 0; k < sides; k++)
            {
                renderer.DrawLine(vertices[topVertex], vertices[extraVertices + k], lineMode: lineMode, thickness: kVertLineThickness);
                for (int i = 0, j = extraVertices; i < rings - 1; i++, j += sides)
                {
                    renderer.DrawLine(vertices[j + k], vertices[j + k + sides], lineMode: lineMode, thickness: kVertLineThickness);
                }
                renderer.DrawLine(vertices[bottomVertex], vertices[extraVertices + k + ((rings - 1) * sides)], lineMode: lineMode, thickness: kVertLineThickness);
            }
            renderer.color = prevColor;
        }
Esempio n. 2
0
        static void DrawOutline(IChiselHandleRenderer renderer, ChiselCapsuleDefinition definition, Vector3[] vertices, LineMode lineMode)
        {
            var sides = definition.sides;

            // TODO: share this logic with GenerateCapsuleVertices

            var topHemisphere    = definition.haveRoundedTop;
            var bottomHemisphere = definition.haveRoundedBottom;
            var topSegments      = topHemisphere    ? definition.topSegments    : 0;
            var bottomSegments   = bottomHemisphere ? definition.bottomSegments : 0;

            var extraVertices = definition.extraVertexCount;
            var bottomVertex  = definition.bottomVertex;
            var topVertex     = definition.topVertex;

            var rings      = definition.ringCount;
            var bottomRing = (bottomHemisphere) ? (rings - bottomSegments) : rings - 1;
            var topRing    = (topHemisphere) ? (topSegments - 1) : 0;

            var prevColor = renderer.color;
            var color     = prevColor;

            color.a *= 0.6f;

            for (int i = 0, j = extraVertices; i < rings; i++, j += sides)
            {
                if ((!definition.haveRoundedTop && i == topRing) ||
                    (!definition.haveRoundedBottom && i == bottomRing))
                {
                    continue;
                }
                bool isCapRing = (i == topRing || i == bottomRing);
                if (isCapRing)
                {
                    continue;
                }
                renderer.color = (isCapRing ? prevColor : color);
                renderer.DrawLineLoop(vertices, j, sides, lineMode: lineMode, thickness: (isCapRing ? kCapLineThickness : kHorzLineThickness), dashSize: (isCapRing ? 0 : kLineDash));
            }

            renderer.color = color;
            for (int k = 0; k < sides; k++)
            {
                if (topHemisphere)
                {
                    renderer.DrawLine(vertices[topVertex], vertices[extraVertices + k], lineMode: lineMode, thickness: kVertLineThickness);
                }
                for (int i = 0, j = extraVertices; i < rings - 1; i++, j += sides)
                {
                    renderer.DrawLine(vertices[j + k], vertices[j + k + sides], lineMode: lineMode, thickness: kVertLineThickness);
                }
                if (bottomHemisphere)
                {
                    renderer.DrawLine(vertices[bottomVertex], vertices[extraVertices + k + ((rings - 1) * sides)], lineMode: lineMode, thickness: kVertLineThickness);
                }
            }
            renderer.color = prevColor;
        }
Esempio n. 3
0
        static void DrawOutline(IChiselHandleRenderer renderer, ChiselTorusDefinition definition, float3[] vertices, LineMode lineMode)
        {
            var horzSegments = definition.settings.horizontalSegments;
            var vertSegments = definition.settings.verticalSegments;

            if (definition.settings.totalAngle != 360)
            {
                horzSegments++;
            }

            var prevColor = renderer.color;

            prevColor.a *= 0.8f;
            var color = prevColor;

            color.a *= 0.6f;

            renderer.color = color;
            for (int i = 0, j = 0; i < horzSegments; i++, j += vertSegments)
            {
                renderer.DrawLineLoop(vertices, j, vertSegments, lineMode: lineMode, thickness: kVertLineThickness);
            }

            for (int k = 0; k < vertSegments; k++)
            {
                for (int i = 0, j = 0; i < horzSegments - 1; i++, j += vertSegments)
                {
                    renderer.DrawLine(vertices[j + k], vertices[j + k + vertSegments], lineMode: lineMode, thickness: kHorzLineThickness);
                }
            }
            if (definition.settings.totalAngle == 360)
            {
                for (int k = 0; k < vertSegments; k++)
                {
                    renderer.DrawLine(vertices[k], vertices[k + ((horzSegments - 1) * vertSegments)], lineMode: lineMode, thickness: kHorzLineThickness);
                }
            }
            renderer.color = prevColor;
        }
        static void DrawOutline(IChiselHandleRenderer renderer, ChiselHemisphereDefinition definition, Vector3[] vertices, LineMode lineMode)
        {
            var sides = definition.horizontalSegments;

            var topSegments   = Mathf.Max(definition.verticalSegments, 0);
            var bottomCap     = false;
            var topCap        = (topSegments != 0);
            var extraVertices = ((topCap) ? 1 : 0) + ((bottomCap) ? 1 : 0);
            var bottomVertex  = 0;
            //var topVertex		= (bottomCap) ? 1 : 0;

            var rings      = (vertices.Length - extraVertices) / sides;
            var bottomRing = 0;

            var prevColor = renderer.color;
            var color     = prevColor;

            color.a *= 0.6f;

            for (int i = 0, j = extraVertices; i < rings; i++, j += sides)
            {
                renderer.color = ((i == bottomRing) ? prevColor : color);
                renderer.DrawLineLoop(vertices, j, sides, lineMode: lineMode, thickness: ((i == bottomRing) ? kCapLineThickness : kHorzLineThickness), dashSize: ((i == bottomRing) ? 0 : kLineDash));
            }

            renderer.color = color;
            for (int k = 0; k < sides; k++)
            {
                for (int i = 0, j = extraVertices; i < rings - 1; i++, j += sides)
                {
                    renderer.DrawLine(vertices[j + k], vertices[j + k + sides], lineMode: lineMode, thickness: kVertLineThickness);
                }
                if (topCap)
                {
                    renderer.DrawLine(vertices[bottomVertex], vertices[extraVertices + k + ((rings - 1) * sides)], lineMode: lineMode, thickness: kVertLineThickness);
                }
            }
            renderer.color = prevColor;
        }