예제 #1
0
        private void AddRingSegment(MeshProxy proxy, Vector3 center, Vector3 normal, Vector3 startPointer,
                                    float innerRadius, float outerRadius, float angle)
        {
            var subdivisions = (int)(angle / 8);
            var angleStep    = angle / subdivisions;

            if (normal.y < 0)
            {
                center       += (innerRadius + outerRadius) * startPointer;
                startPointer *= -1;
            }

            for (int i = 0; i < subdivisions; i++)
            {
                if (normal.y > 0)
                {
                    var firstPointer  = Quaternion.AngleAxis(i * angleStep, normal) * startPointer;
                    var secondPointer = Quaternion.AngleAxis((i + 1) * angleStep, normal) * startPointer;
                    proxy.AddQuad(center + outerRadius * firstPointer, center + innerRadius * firstPointer,
                                  center + outerRadius * secondPointer, center + innerRadius * secondPointer, Vector2.zero,
                                  Vector2.right, Vector2.up, Vector2.one);
                }
                else
                {
                    var firstPointer  = Quaternion.AngleAxis(i * angleStep, normal) * startPointer;
                    var secondPointer = Quaternion.AngleAxis((i + 1) * angleStep, normal) * startPointer;
                    proxy.AddQuad(center + innerRadius * firstPointer, center + outerRadius * firstPointer,
                                  center + innerRadius * secondPointer, center + outerRadius * secondPointer, Vector2.zero,
                                  Vector2.right, Vector2.up, Vector2.one);
                }
            }
        }
예제 #2
0
        private void AddCircleSegment(MeshProxy proxy, Vector3 center, Vector3 startPointer, float angle, int subdivisions, bool ccw = false)
        {
            var angleStep = angle / subdivisions;
            var axis      = ccw ? Vector3.down : Vector3.up;

            for (int i = 0; i < subdivisions; i++)
            {
                proxy.AddQuad(center, center + Quaternion.AngleAxis(i * angleStep, axis) * startPointer,
                              center,
                              center + Quaternion.AngleAxis((i + 1) * angleStep, axis) * startPointer, 0.5f * Vector2.right,
                              Vector2.right, new Vector2(0.5f, 1), Vector2.one);
            }
        }
예제 #3
0
        private void AddSegment(MeshProxy proxy, Vector3 p1, Vector3 p2, Vector3 t1,
                                Vector3?t2n = null)
        {
            var t2 = t2n ?? t1;

            //Debug.DrawLine(p1 - t1, p1 - t1 + 0.1f * Vector3.up, Color.white, 12);
            //yield return new WaitForSeconds(0.25f);
            //Debug.DrawLine(p1 + t1, p1 + t1 + 0.1f * Vector3.up, Color.cyan, 11.75f);
            //yield return new WaitForSeconds(0.25f);
            //Debug.DrawLine(p2 - t2, p2 - t2 + 0.1f * Vector3.up, Color.black, 11.5f);
            //yield return new WaitForSeconds(0.25f);
            //Debug.DrawLine(p2 + t2, p2 + t2 + 0.1f * Vector3.up, Color.red, 11.25f);
            //yield return new WaitForSeconds(0.25f);
            proxy.AddQuad(
                p1 - t1,
                p1 + t1,
                p2 - t2,
                p2 + t2,
                Vector2.zero,
                Vector2.right,
                Vector2.up,
                Vector2.one);
        }
예제 #4
0
        private void AddCap(MeshProxy proxy, LineData line, Vector3 point, Vector3 direction, Vector3 t, bool endCap)
        {
            Vector3 end;
            var     capType = endCap ? line.EndCap : line.StartCap;
            var     capSize = endCap ? line.EndCapSize : line.StartCapSize;

            switch (capType)
            {
            case LineCapType.None:
                break;

            case LineCapType.Sharp:
                end = point + capSize * direction;
                proxy.AddQuad(point - t, point, end, point,
                              Vector2.zero, 0.5f * Vector2.right, Vector2.up, new Vector2(0.5f, 1));
                proxy.AddQuad(point, point + t, point, end,
                              0.5f * Vector2.right, Vector2.right, new Vector2(0.5f, 1), Vector2.one);
                break;

            case LineCapType.Arrow:
                end = point + capSize * direction;
                var center      = point + 0.5f * capSize * direction;
                var tNormalized = t.normalized;
                proxy.AddQuad(point - t, point, point - capSize * tNormalized, center,
                              Vector2.zero, 0.5f * Vector2.right, Vector2.up, new Vector2(0.5f, 1));
                proxy.AddQuad(point - capSize * tNormalized, center, end, center,
                              Vector2.zero, 0.5f * Vector2.right, Vector2.up, new Vector2(0.5f, 1));
                proxy.AddQuad(center, end, center, point + capSize * tNormalized,
                              0.5f * Vector2.right, Vector2.right, new Vector2(0.5f, 1), Vector2.one);
                proxy.AddQuad(point + t, point + capSize * tNormalized, point, center,
                              Vector2.right, Vector2.one, 0.5f * Vector2.right, new Vector2(0.5f, 1));
                break;

            case LineCapType.Round:
                AddCircleSegment(proxy, point, t, 180, 10, true);
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }