Exemplo n.º 1
0
        public void Fill(SVGData svg)
        {
            MeshData.Clear();

            // convert curves into discrete points
            BezierToVertex.Scale = Scale;
            BezierToVertex.GetContours(svg, MeshData);

            // triangulate mesh
            Triangulation.Delaunay = Delaunay;
            Triangulation.Interior = Interior;
            Triangulation.Exterior = Exterior;
            Triangulation.Infinity = Infinity;
            Triangulation.BuildTriangles(MeshData);

            if (Mesh == null)
            {
                Mesh = new Mesh();
                Mesh.MarkDynamic();
            }

            MeshData.MakeUnityFriendly();
            MeshData.Upload(Mesh);

            var filter = GetComponent <MeshFilter>();

            if (filter != null)
            {
                filter.sharedMesh = Mesh;
            }
        }
Exemplo n.º 2
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            if (_bezierToVertex == null)
            {
                _bezierToVertex = new BezierToVertex
                {
                    WorkBufferPool = _workBufferPool,
                    Scale          = 1
                }
            }
            ;

            if (_triangulation == null)
            {
                _triangulation = new Triangulation
                {
                    Delaunay       = false,
                    Interior       = true,
                    Exterior       = false,
                    Infinity       = false,
                    WorkBufferPool = _workBufferPool
                }
            }
            ;


            var selfRectTransform = (RectTransform)transform;
            var selfRect          = selfRectTransform.rect;
            var offset            = new Vector2(-selfRectTransform.pivot.x * selfRect.width,
                                                (1 - selfRectTransform.pivot.y) * selfRect.height);
            var svgData = BuildWave(selfRect,
                                    _waveCenterY * selfRect.height,
                                    _waveHorRadius * selfRect.width,
                                    _waveVertRadius * selfRect.height,
                                    _sideWidth * selfRect.width);

            _meshData.Clear();
            _bezierToVertex.GetContours(svgData, _meshData);
            _triangulation.BuildTriangles(_meshData);

            _meshData.MakeUnityFriendly();
            _meshData.Upload(vh, offset, color);
        }