Пример #1
0
 private void UpdateShape()
 {
     this.shapeLookup     = Shape.GetRoseCurve(this.leafs, this.detail, this.center, true);
     this.shapeTriIndices = Triangulate.Edge(this.shapeLookup);
     this.edgeCount       = this.shapeLookup.Length;
     this.flagShapeUpdate = false;
 }
Пример #2
0
        void UpdateShape()
        {
            shapeLookup = Shape.GetRoseCurve(leafs, detail, center, true);

            shapeTriIndices = Triangulate.Edge(shapeLookup);

            edgeCount       = shapeLookup.Length;
            flagShapeUpdate = false;
        }
Пример #3
0
        private static bool Snip(int u, int v, int w, int n, int[] V)
        {
            Vector3 _t1 = Triangulate.shape[V[u]];
            Vector3 _t2 = Triangulate.shape[V[v]];
            Vector3 _t3 = Triangulate.shape[V[w]];

            if (Mathf.Epsilon > (_t2.x - _t1.x) * (_t3.y - _t1.y) - (_t2.y - _t1.y) * (_t3.x - _t1.x))
            {
                return(false);
            }
            for (int index = 0; index < n; ++index)
            {
                if (index != u && index != v && index != w)
                {
                    Vector3 _p1 = Triangulate.shape[V[index]];
                    if (Triangulate.OverlapsPoint(_t1, _t2, _t3, _p1))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #4
0
        public static int[] Edge(Vector3[] _shape)
        {
            Triangulate.shape = _shape;
            List <int> intList = new List <int>();
            int        length  = Triangulate.shape.Length;

            if (length < 3)
            {
                return(intList.ToArray());
            }
            int[] V = new int[length];
            if ((double)Triangulate.Area() > 0.0)
            {
                for (int index = 0; index < length; ++index)
                {
                    V[index] = index;
                }
            }
            else
            {
                for (int index = 0; index < length; ++index)
                {
                    V[index] = length - 1 - index;
                }
            }
            int n    = length;
            int num1 = 2 * n;
            int num2 = 0;
            int v    = n - 1;

            while (n > 2)
            {
                if (num1-- <= 0)
                {
                    return(intList.ToArray());
                }
                int u = v;
                if (n <= u)
                {
                    u = 0;
                }
                v = u + 1;
                if (n <= v)
                {
                    v = 0;
                }
                int w = v + 1;
                if (n <= w)
                {
                    w = 0;
                }
                if (Triangulate.Snip(u, v, w, n, V))
                {
                    int num3 = V[u];
                    int num4 = V[v];
                    int num5 = V[w];
                    intList.Add(num3);
                    intList.Add(num4);
                    intList.Add(num5);
                    ++num2;
                    int index1 = v;
                    for (int index2 = v + 1; index2 < n; ++index2)
                    {
                        V[index1] = V[index2];
                        ++index1;
                    }
                    --n;
                    num1 = 2 * n;
                }
            }
            intList.Reverse();
            return(intList.ToArray());
        }